Skip to content

Commit

Permalink
adding logging
Browse files Browse the repository at this point in the history
  • Loading branch information
harshitsinghvi22 committed May 10, 2024
1 parent 5b752a8 commit c419d14
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions internal/integration_tests/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ func performBackgroundInstall(t *testing.T, componentsToParallelInstall []helmCo

func installMinio(namespace string, tenantName string) error {
stdout, stderr, err := RunCommand(exec.Command("kubectl", "minio", "version"))
printStdOutStdErr(stdout, stderr, []string{"kubectl", "minio", "version"})
if !strings.Contains(strings.ToLower(string(stdout)), "kubectl-plugin version") {
if err != nil {
log.Printf("%v", string(stderr))
Expand All @@ -742,6 +743,7 @@ func installMinio(namespace string, tenantName string) error {
}

stdout, stderr, err = RunCommand(exec.Command("kubectl", "minio", "init", "-n", namespace))
printStdOutStdErr(stdout, stderr, []string{"kubectl", "minio", "init", "-n", namespace})
if !strings.Contains(strings.ToLower(string(stdout)), "To open Operator UI, start a port forward using this command") {
if err != nil {
log.Printf("%v", string(stderr))
Expand All @@ -750,6 +752,7 @@ func installMinio(namespace string, tenantName string) error {
}

stdout, stderr, err = RunCommand(exec.Command("kubectl", "minio", "tenant", "create", tenantName, "--servers", "2", "--volumes", "4", "--capacity", "10Gi", "--disable-tls", "-n", namespace))
printStdOutStdErr(stdout, stderr, []string{"kubectl", "minio", "tenant", "create", tenantName, "--servers", "2", "--volumes", "4", "--capacity", "10Gi", "--disable-tls", "-n", namespace})
if err != nil {
log.Printf("%v", string(stderr))
return err
Expand All @@ -770,6 +773,7 @@ func deleteMinio(namespace string) error {
func getMiniIOKeys(namespace string, tenantName string) (string, string, error) {
secretName := fmt.Sprintf("%s-user-1", tenantName)
stdout, stderr, err := RunCommand(exec.Command("kubectl", "get", "secret", secretName, "-n", namespace, "--template={{.data.CONSOLE_ACCESS_KEY}}"))
printStdOutStdErr(stdout, stderr, []string{"kubectl", "get", "secret", secretName, "-n", namespace, "--template={{.data.CONSOLE_ACCESS_KEY}}"})
if err != nil {
log.Printf("%v", string(stderr))
return "", "", err
Expand All @@ -781,6 +785,7 @@ func getMiniIOKeys(namespace string, tenantName string) (string, string, error)
}

stdout, stderr, err = RunCommand(exec.Command("kubectl", "get", "secret", secretName, "-n", namespace, "--template={{.data.CONSOLE_SECRET_KEY}}"))
printStdOutStdErr(stdout, stderr, []string{"kubectl", "get", "secret", secretName, "-n", namespace, "--template={{.data.CONSOLE_SECRET_KEY}}"})
if err != nil {
log.Printf("%v", string(stderr))
return "", "", err
Expand Down Expand Up @@ -829,15 +834,23 @@ func kCreateMinioSecret(namespace string, tenantName string, secretName string)
}

func createMinioBucket(accessKey string, secretKey string, endpoint string) error {
_, stderr, err := RunCommand(exec.Command("mc", "alias", "set", "myminio", endpoint, accessKey, secretKey))
stdout, stderr, err := RunCommand(exec.Command("mc", "alias", "set", "myminio", endpoint, accessKey, secretKey))
printStdOutStdErr(stdout, stderr, []string{"mc", "alias", "set", "myminio", endpoint, accessKey, secretKey})
if err != nil {
log.Printf("%v", string(stderr))
return err
}
_, stderr, err = RunCommand(exec.Command("mc", "mb", "myminio/helm-backup-test"))
stdout, stderr, err = RunCommand(exec.Command("mc", "mb", "myminio/helm-backup-test"))
printStdOutStdErr(stdout, stderr, []string{"mc", "mb", "myminio/helm-backup-test"})
if err != nil {
log.Printf("%v", string(stderr))
return err
}
return nil
}

func printStdOutStdErr(stdOut []byte, stderr []byte, command []string) {
log.Printf("Command = %v \n", command)
log.Printf("stdout = %s \n", string(stdOut))
log.Printf("stderr = %s \n", string(stderr))
}

0 comments on commit c419d14

Please sign in to comment.