Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions test/e2e/argocd_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package e2e

import (
"bytes"
"fmt"
"os/exec"
"path/filepath"
Expand All @@ -30,15 +31,36 @@ import (
"k8s.io/apimachinery/pkg/types"
)

func runCommandWithOutput(cmdList ...string) (string, string, error) {

// Output the commands to be run, so that if the test fails we can determine why
fmt.Println(cmdList)

cmd := exec.Command(cmdList[0], cmdList[1:]...)
var stdout bytes.Buffer
var stderr bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stderr

err := cmd.Run()
stdoutStr := stdout.String()
stderrStr := stderr.String()

// Output the stdout/sterr text, so that if the test fails we can determine why
fmt.Println(stdoutStr, stderrStr)

return stdoutStr, stderrStr, err

}

var _ = Describe("Argo CD metrics controller", func() {
Context("Check if monitoring resources are created", func() {
It("Role is created", func() {
buildYAML := filepath.Join("..", "appcrs", "build_appcr.yaml")
ocPath, err := exec.LookPath("oc")
Expect(err).NotTo(HaveOccurred())

cmd := exec.Command(ocPath, "apply", "-f", buildYAML)
err = cmd.Run()
_, _, err = runCommandWithOutput(ocPath, "apply", "-f", buildYAML)
Expect(err).NotTo(HaveOccurred())
// Alert delay
time.Sleep(60 * time.Second)
Expand Down
15 changes: 5 additions & 10 deletions test/e2e/gitopsservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ var _ = Describe("GitOpsServiceController", func() {
ocPath, err := exec.LookPath("oc")
Expect(err).NotTo(HaveOccurred())

cmd := exec.Command(ocPath, "apply", "-f", imageYAML)
err = cmd.Run()
_, _, err = runCommandWithOutput(ocPath, "apply", "-f", imageYAML)
Expect(err).NotTo(HaveOccurred())
})

Expand Down Expand Up @@ -191,8 +190,7 @@ var _ = Describe("GitOpsServiceController", func() {
nonDefaultAppCR := filepath.Join("..", "appcrs", "non_default_appcr.yaml")
ocPath, err := exec.LookPath("oc")
Expect(err).NotTo(HaveOccurred())
cmd := exec.Command(ocPath, "apply", "-f", nonDefaultAppCR)
_, err = cmd.CombinedOutput()
_, _, err = runCommandWithOutput(ocPath, "apply", "-f", nonDefaultAppCR)
if err != nil {
Expect(err).NotTo(HaveOccurred())
}
Expand Down Expand Up @@ -321,8 +319,7 @@ var _ = Describe("GitOpsServiceController", func() {
ocPath, err := exec.LookPath("oc")
Expect(err).NotTo(HaveOccurred())
schedulerYAML := filepath.Join("..", "appcrs", "scheduler_appcr.yaml")
cmd := exec.Command(ocPath, "apply", "-f", schedulerYAML)
_, err = cmd.CombinedOutput()
_, _, err = runCommandWithOutput(ocPath, "apply", "-f", schedulerYAML)
Expect(err).NotTo(HaveOccurred())

Eventually(func() error {
Expand Down Expand Up @@ -420,8 +417,7 @@ var _ = Describe("GitOpsServiceController", func() {
nginxAppCr := filepath.Join("..", "appcrs", "nginx_appcr.yaml")
ocPath, err := exec.LookPath("oc")
Expect(err).NotTo(HaveOccurred())
cmd := exec.Command(ocPath, "apply", "-f", nginxAppCr)
err = cmd.Run()
_, _, err = runCommandWithOutput(ocPath, "apply", "-f", nginxAppCr)
Expect(err).NotTo(HaveOccurred())

Eventually(func() error {
Expand Down Expand Up @@ -487,8 +483,7 @@ var _ = Describe("GitOpsServiceController", func() {
nginxAppCr := filepath.Join("..", "appcrs", "nginx_default_ns_appcr.yaml")
ocPath, err := exec.LookPath("oc")
Expect(err).NotTo(HaveOccurred())
cmd := exec.Command(ocPath, "apply", "-f", nginxAppCr)
err = cmd.Run()
_, _, err = runCommandWithOutput(ocPath, "apply", "-f", nginxAppCr)
Expect(err).NotTo(HaveOccurred())

Eventually(func() error {
Expand Down
Loading