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

fix(test): export KUBECONFIG to oc only if set #280

Conversation

sthaha
Copy link
Collaborator

@sthaha sthaha commented Oct 18, 2023

Previously, when KUBECONFIG is not set, instead of oc defaulting to ~/.kube/config, it uses KUBECONFIG that points no where and tests fail as follows:

❯ go test -v ./tests/e2e/... -run Node -count=1 -timeout=15m
=== RUN   TestNodeSelector
Running command cmd oc args [get node -o jsonpath={.items[*].metadata.name}]
    kepler_test.go:90:
                Error:          Received unexpected error: exit status 1
                Messages:       failed to get node names
    kepler_test.go:91:
                Error:          Should not be zero, but was 0
                Messages:       got zero nodes
--- FAIL: TestNodeSelector (0.08s)
panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

This commit fixes the issue by exporting KUBECONFIG only if it is not empty.

Previously, when KUBECONFIG is not set, instead of oc defaulting to
~/.kube/config, it uses KUBECONFIG that points no where and tests fail
as follows:
```
❯ go test -v ./tests/e2e/... -run Node -count=1 -timeout=15m
=== RUN   TestNodeSelector
Running command cmd oc args [get node -o jsonpath={.items[*].metadata.name}]
    kepler_test.go:90:
                Error:          Received unexpected error: exit status 1
                Messages:       failed to get node names
    kepler_test.go:91:
                Error:          Should not be zero, but was 0
                Messages:       got zero nodes
--- FAIL: TestNodeSelector (0.08s)
panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

```

This commit fixes the issue by exporting KUBECONFIG only if it is
not empty.

Signed-off-by: Sunil Thaha <sthaha@redhat.com>
@sthaha sthaha requested a review from vimalk78 October 18, 2023 02:13
Copy link
Collaborator

@vimalk78 vimalk78 left a comment

Choose a reason for hiding this comment

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

lgtm

@vimalk78 vimalk78 merged commit aab30a6 into sustainable-computing-io:v1alpha1 Oct 18, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants