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:
Justin Santa Barbara 2017-08-09 21:26:21 -04:00
parent ca1ebbfc25
commit 4767ee9e31
2 changed files with 23 additions and 1 deletions

View File

@ -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"

View File

@ -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() {