Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A couple of e2e fixes #16676

Merged
merged 2 commits into from
Nov 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 33 additions & 3 deletions test/e2e/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,9 @@ var _ = Describe("Kubectl client", func() {

// Build the static kubectl
By("Finding a static kubectl for upload")
testStaticKubectlPath := path.Join(testContext.RepoRoot, "platforms/linux/386/kubectl")
_, err = os.Stat(testStaticKubectlPath)
testStaticKubectlPath, err := findBinary("kubectl", "linux/386")
if err != nil {
Logf("No kubectl in %s. Attempting a local build...", testStaticKubectlPath)
Logf("No kubectl found: %v.\nAttempting a local build...", err)
// Fall back to trying to build a local static kubectl
kubectlContainerPath := path.Join(testContext.RepoRoot, "/examples/kubectl-container/")
if _, err := os.Stat(path.Join(testContext.RepoRoot, "hack/build-go.sh")); err != nil {
Expand Down Expand Up @@ -1201,3 +1200,34 @@ func streamingUpload(file *os.File, fileName string, postBodyWriter *multipart.W
Failf("Unable to close the writer for file upload. Error: %s", err)
}
}

var binPrefixes = []string{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"_output/dockerized/bin",
"_output/local/bin",
"platforms",
}

// findBinary searches through likely paths to find the specified binary. It
// takes the one that has been built most recently. Platform should be
// specified as '<os>/<arch>'. For example: 'linux/amd64'.
func findBinary(binName string, platform string) (string, error) {
var binTime time.Time
var binPath string

for _, pre := range binPrefixes {
tryPath := path.Join(testContext.RepoRoot, pre, platform, binName)
fi, err := os.Stat(tryPath)
if err != nil {
continue
}
if fi.ModTime().After(binTime) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It would be nice to log if a version was chosen because of a later build. I could see some confusion as to why one binary was chosen over another until reading the code.

binPath = tryPath
binTime = fi.ModTime()
}
}

if len(binPath) > 0 {
return binPath, nil
}
return binPath, fmt.Errorf("Could not find %v for %v", binName, platform)
}
8 changes: 4 additions & 4 deletions test/e2e/serviceloadbalancers.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (h *haproxyControllerTester) start(namespace string) (err error) {
// Create a replication controller with the given configuration.
rc := rcFromManifest(h.cfg)
rc.Namespace = namespace
rc.Spec.Template.Labels["rcName"] = rc.Name
rc.Spec.Template.Labels["name"] = rc.Name

// Add the --namespace arg.
// TODO: Remove this when we have proper namespace support.
Expand All @@ -102,15 +102,15 @@ func (h *haproxyControllerTester) start(namespace string) (err error) {
if err != nil {
return
}
if err = waitForRCPodsRunning(h.client, namespace, h.rcName); err != nil {
if err = waitForRCPodsRunning(h.client, namespace, rc.Name); err != nil {
return
}
h.rcName = rc.Name
h.rcNamespace = rc.Namespace

// Find the pods of the rc we just created.
labelSelector := labels.SelectorFromSet(
labels.Set(map[string]string{"rcName": h.rcName}))
labels.Set(map[string]string{"name": h.rcName}))
pods, err := h.client.Pods(h.rcNamespace).List(
labelSelector, fields.Everything())
if err != nil {
Expand Down Expand Up @@ -164,7 +164,7 @@ func (s *ingManager) start(namespace string) (err error) {
for _, rcPath := range s.rcCfgPaths {
rc := rcFromManifest(rcPath)
rc.Namespace = namespace
rc.Spec.Template.Labels["rcName"] = rc.Name
rc.Spec.Template.Labels["name"] = rc.Name
rc, err = s.client.ReplicationControllers(rc.Namespace).Create(rc)
if err != nil {
return
Expand Down