Skip to content

Commit

Permalink
RHOAIENG-15772: tests(odh-nbc): write envtest kubeconfig to disk upon…
Browse files Browse the repository at this point in the history
… request

This helps with debugging because it's then possible to do e.g.

```
KUBECONFIG=/tmp/envtest.kubeconfig k9s
```

and investigate the cluster while the test is paused on a breakpoint.
  • Loading branch information
jiridanek committed Nov 14, 2024
1 parent 363bcdb commit 91ba6ad
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/odh-notebook-controller/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"crypto/tls"
"fmt"
"net"
"os"
"path/filepath"
"testing"
"time"
Expand Down Expand Up @@ -129,6 +130,16 @@ var _ = BeforeSuite(func() {
})
Expect(err).NotTo(HaveOccurred())

if kubeconfigPath, found := os.LookupEnv("DEBUG_WRITE_KUBECONFIG"); found {
user := envtest.User{Name: "MasterOfTheSystems", Groups: []string{"system:masters"}}
authedUser, err := envTest.ControlPlane.AddUser(user, nil)
Expect(err).NotTo(HaveOccurred())
config, err := authedUser.KubeConfig()
Expect(err).NotTo(HaveOccurred())
err = os.WriteFile(kubeconfigPath, config, 0600)
Expect(err).NotTo(HaveOccurred())
}

// Setup notebook controller
err = (&OpenshiftNotebookReconciler{
Client: mgr.GetClient(),
Expand Down

0 comments on commit 91ba6ad

Please sign in to comment.