mirror of https://github.com/kubernetes/kops.git
Read the channel from the local filesystem during tests
Another step towards working totally offline (which may never be fully achievable, because of the need to hash assets). But should ensure that when we update the stable channel, we are testing against that version in the tests, otherwise it is easy to break master.
This commit is contained in:
parent
ca1ebbfc25
commit
4767ee9e31
|
@ -27,7 +27,8 @@ import (
|
|||
"net/url"
|
||||
)
|
||||
|
||||
const DefaultChannelBase = "https://raw.githubusercontent.com/kubernetes/kops/master/channels/"
|
||||
var DefaultChannelBase = "https://raw.githubusercontent.com/kubernetes/kops/master/channels/"
|
||||
|
||||
const DefaultChannel = "stable"
|
||||
const AlphaChannel = "alpha"
|
||||
|
||||
|
|
|
@ -24,15 +24,21 @@ import (
|
|||
"io/ioutil"
|
||||
"k8s.io/kops/cloudmock/aws/mockec2"
|
||||
"k8s.io/kops/cloudmock/aws/mockroute53"
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||
"k8s.io/kops/util/pkg/vfs"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type IntegrationTestHarness struct {
|
||||
TempDir string
|
||||
T *testing.T
|
||||
|
||||
// The original kops DefaultChannelBase value, restored on Close
|
||||
originalDefaultChannelBase string
|
||||
}
|
||||
|
||||
func NewIntegrationTestHarness(t *testing.T) *IntegrationTestHarness {
|
||||
|
@ -45,6 +51,17 @@ func NewIntegrationTestHarness(t *testing.T) *IntegrationTestHarness {
|
|||
|
||||
vfs.Context.ResetMemfsContext(true)
|
||||
|
||||
// Replace the default channel path with a local filesystem path, so we don't try to retrieve it from a server
|
||||
{
|
||||
channelPath, err := filepath.Abs(path.Join("../../channels/"))
|
||||
if err != nil {
|
||||
t.Fatalf("error resolving stable channel path: %v", err)
|
||||
}
|
||||
channelPath += "/"
|
||||
h.originalDefaultChannelBase = kops.DefaultChannelBase
|
||||
kops.DefaultChannelBase = "file://" + channelPath
|
||||
}
|
||||
|
||||
return h
|
||||
}
|
||||
|
||||
|
@ -59,6 +76,10 @@ func (h *IntegrationTestHarness) Close() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if h.originalDefaultChannelBase != "" {
|
||||
kops.DefaultChannelBase = h.originalDefaultChannelBase
|
||||
}
|
||||
}
|
||||
|
||||
func (h *IntegrationTestHarness) SetupMockAWS() {
|
||||
|
|
Loading…
Reference in New Issue