Changing --name-prefix or using another environment file (e.g. envs/regional-dr-kubevirt.yaml) breaks the e2e tests:
2024-05-02T02:15:19.900+0[3](https://github.com/nirs/ramen/actions/runs/8916064713/job/24486818817#step:10:3)00 ERROR e2e/main_test.go:38 unable to create new testing context {"error": "failed to create clients for hub cluster: failed to build config from kubeconfig (/home/github/.config/drenv/rdr-rdr/kubeconfigs/rdr-hub): stat /home/github/.config/drenv/rdr-rdr/kubeconfigs/rdr-hub: no such file or directory"}
The issue is hard-coding the environment name (rdr) and --name-prefix (rdr-) for getting the stored kubeconfig files.
The right way to get the cluster configs is to pass the environment file to the test using an argument:
This provides not only the context names but the topology (regional, metro) and if volsync is enabled in the environment (it is not in the kubevirt environment). We can extend it later with more useful details as needed.
Then you can load the default kubeconfig from ~/home/.kube/config and create a config using one one of the context names from the env file (hub, dr1, dr2).
To support --name-prefix when starting the environment we need to add a --name-prefix argument to the tests and add the provided prefix to the cluster names.
Another way is to use e2e/config.yaml but we better remove this hack and use the environment file format to describe environments.
Full log:
Run cp ~/.config/drenv/rdr/config.yaml e2e/config.yaml
cp ~/.config/drenv/rdr/config.yaml e[2](https://github.com/nirs/ramen/actions/runs/8916064713/job/24486818817#step:10:2)e/config.yaml
make e2e-rdr
shell: /usr/bin/bash -e {0}
env:
MAX_WORKERS: 4
ENV_NAME: rdr
ENV_FILE: envs/regional-dr.yaml
/home/github/actions-runner/_work/ramen/ramen/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
/home/github/actions-runner/_work/ramen/ramen/bin/controller-gen rbac:roleName=operator-role crd:generateEmbeddedObjectMeta=true webhook paths="./..." output:crd:artifacts:config=config/crd/bases
./e2e/rdr-e2e.sh
Running tests...
2024-05-02T02:15:19.900+0[3](https://github.com/nirs/ramen/actions/runs/8916064713/job/24486818817#step:10:3)00 ERROR e2e/main_test.go:38 unable to create new testing context {"error": "failed to create clients for hub cluster: failed to build config from kubeconfig (/home/github/.config/drenv/rdr-rdr/kubeconfigs/rdr-hub): stat /home/github/.config/drenv/rdr-rdr/kubeconfigs/rdr-hub: no such file or directory"}
github.com/ramendr/ramen/e2e_test.TestMain
/home/github/actions-runner/_work/ramen/ramen/e2e/main_test.go:38
main.main
_testmain.go:[4](https://github.com/nirs/ramen/actions/runs/8916064713/job/24486818817#step:10:4)9
runtime.main
/usr/lib/golang/src/runtime/proc.go:2[6](https://github.com/nirs/ramen/actions/runs/8916064713/job/24486818817#step:10:6)7
panic: failed to create clients for hub cluster: failed to build config from kubeconfig (/home/github/.config/drenv/rdr-rdr/kubeconfigs/rdr-hub): stat /home/github/.config/drenv/rdr-rdr/kubeconfigs/rdr-hub: no such file or directory
goroutine 1 [running]:
github.com/ramendr/ramen/e2e_test.TestMain(0x4[7](https://github.com/nirs/ramen/actions/runs/8916064713/job/24486818817#step:10:7)2e1a?)
/home/github/actions-runner/_work/ramen/ramen/e2e/main_test.go:40 +0x27[8](https://github.com/nirs/ramen/actions/runs/8916064713/job/24486818817#step:10:8)
main.main()
_testmain.go:49 +0x1c6
exit status 2
FAIL github.com/ramendr/ramen/e2e 0.031s
Changing --name-prefix or using another environment file (e.g. envs/regional-dr-kubevirt.yaml) breaks the e2e tests:
The issue is hard-coding the environment name (rdr) and --name-prefix (rdr-) for getting the stored kubeconfig files.
The right way to get the cluster configs is to pass the environment file to the test using an argument:
And get the context names from the ramen object:
This provides not only the context names but the topology (regional, metro) and if volsync is enabled in the environment (it is not in the kubevirt environment). We can extend it later with more useful details as needed.
Then you can load the default kubeconfig from ~/home/.kube/config and create a config using one one of the context names from the env file (hub, dr1, dr2).
To support --name-prefix when starting the environment we need to add a --name-prefix argument to the tests and add the provided prefix to the cluster names.
Another way is to use e2e/config.yaml but we better remove this hack and use the environment file format to describe environments.
Full log: