diff --git a/backend/src/v2/cmd/driver/main.go b/backend/src/v2/cmd/driver/main.go index a796b5aaba2..8ea71626e2d 100644 --- a/backend/src/v2/cmd/driver/main.go +++ b/backend/src/v2/cmd/driver/main.go @@ -77,9 +77,12 @@ func main() { flag.Parse() glog.Infof("Setting log level to: '%s'", *logLevel) - flag.Set("v", *logLevel) + err := flag.Set("v", *logLevel) + if err != nil { + glog.Warningf("Failed to set log level: %s", err.Error()) + } - err := drive() + err = drive() if err != nil { glog.Exitf("%v", err) } diff --git a/backend/src/v2/cmd/launcher-v2/main.go b/backend/src/v2/cmd/launcher-v2/main.go index b8ced5a3f7e..a77111cd60e 100644 --- a/backend/src/v2/cmd/launcher-v2/main.go +++ b/backend/src/v2/cmd/launcher-v2/main.go @@ -56,7 +56,10 @@ func run() error { ctx := context.Background() glog.Infof("Setting log level to: '%s'", *logLevel) - flag.Set("v", *logLevel) + err := flag.Set("v", *logLevel) + if err != nil { + glog.Warningf("Failed to set log level: %s", err.Error()) + } if *copy != "" { // copy is used to copy this binary to a shared volume diff --git a/backend/src/v2/compiler/argocompiler/argo_test.go b/backend/src/v2/compiler/argocompiler/argo_test.go index 7ebf98ff49f..ae18d922cac 100644 --- a/backend/src/v2/compiler/argocompiler/argo_test.go +++ b/backend/src/v2/compiler/argocompiler/argo_test.go @@ -18,6 +18,7 @@ import ( "flag" "fmt" "io/ioutil" + "os" "strings" "testing" @@ -36,6 +37,7 @@ func Test_argo_compiler(t *testing.T) { jobPath string // path of input PipelineJob to compile platformSpecPath string // path of possible input PlatformSpec to compile argoYAMLPath string // path of expected output argo workflow YAML + envVars []string }{ { jobPath: "../testdata/hello_world.json", @@ -71,6 +73,23 @@ func Test_argo_compiler(t *testing.T) { for _, tt := range tests { t.Run(fmt.Sprintf("%+v", tt), func(t *testing.T) { job, platformSpec := load(t, tt.jobPath, tt.platformSpecPath) + if tt.envVars != nil { + for _, envVar := range tt.envVars { + parts := strings.Split(strings.ReplaceAll(envVar, " ", ""), "=") + err := os.Setenv(parts[0], parts[1]) + if err != nil { + t.Fatalf("Failed to set environment variable '%s' with error: %s", parts[0], err.Error()) + } + + // Unset after test cases has ended + defer func() { + err := os.Unsetenv(parts[0]) + if err != nil { + t.Fatalf("Failed to unset env variable '%s' with error: %s", parts[0], err.Error()) + } + }() + } + } if *update { wf, err := argocompiler.Compile(job, platformSpec, nil) if err != nil {