Skip to content

Commit

Permalink
Integration: Add testcase for login using crc-admin context
Browse files Browse the repository at this point in the history
  • Loading branch information
jsliacan authored and praveenkumar committed Mar 17, 2023
1 parent c24e650 commit bdda869
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/integration/resize_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package test_test

import (
"os/exec"
"runtime"

. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -28,6 +29,25 @@ var _ = Describe("vary VM parameters: memory cpus, disk", Label("openshift-prese
}
})

It("login to cluster using crc-admin context", func() {

err := AddOCToPath()
Expect(err).NotTo(HaveOccurred())

cmd := exec.Command("oc", "config", "use-context", "crc-admin")
err = cmd.Run()
Expect(err).NotTo(HaveOccurred())

cmd = exec.Command("oc", "whoami")
out, err := cmd.Output()
Expect(err).NotTo(HaveOccurred())
Expect(string(out)).To(ContainSubstring("kubeadmin"))

cmd = exec.Command("oc", "get", "co")
err = cmd.Run()
Expect(err).NotTo(HaveOccurred())
})

It("check VM's memory size", func() {
out, err := SendCommandToVM("cat /proc/meminfo")
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -137,4 +157,5 @@ var _ = Describe("vary VM parameters: memory cpus, disk", Label("openshift-prese

})
})

})
20 changes: 20 additions & 0 deletions test/integration/utilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"io"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -113,3 +115,21 @@ func SendCommandToVM(cmd string) (string, error) {
}
return string(out), nil
}

func AddOCToPath() error {
path := os.ExpandEnv("${HOME}/.crc/bin/oc:$PATH")
if runtime.GOOS == "windows" {
userHomeDir, err := os.UserHomeDir()
if err != nil {
return err
}
unexpandedPath := filepath.Join(userHomeDir, ".crc/bin/oc;${PATH}")
path = os.ExpandEnv(unexpandedPath)
}
err := os.Setenv("PATH", path)
if err != nil {
return err
}

return nil
}

0 comments on commit bdda869

Please sign in to comment.