From 4cf845998da69ca44a50bcd75cee2be7b9cbbf51 Mon Sep 17 00:00:00 2001 From: Jonathan Knight Date: Tue, 27 Feb 2024 15:53:10 +0300 Subject: [PATCH] Fix viper --- api/v1/create_job_coherencespec_test.go | 12 ++++++++ api/v1/create_statefulset_test.go | 26 ++++++++++++----- controllers/webhook/webhook_controller.go | 4 +-- pkg/runner/cmd_initialise.go | 5 ++-- pkg/runner/cmd_operator_test.go | 10 +++---- pkg/runner/runner.go | 23 ++++++++++----- pkg/runner/runner_application_test.go | 12 ++++---- pkg/runner/runner_application_type_test.go | 18 ++++++------ pkg/runner/runner_coherence_test.go | 32 ++++++++++---------- pkg/runner/runner_initialise_test.go | 6 ++-- pkg/runner/runner_jvm_jibclasspath_test.go | 10 +++---- pkg/runner/runner_jvm_memory_test.go | 34 +++++++++++----------- pkg/runner/runner_jvm_test.go | 24 +++++++-------- pkg/runner/runner_persistence_test.go | 8 ++--- pkg/runner/runner_spring_test.go | 10 +++---- pkg/runner/runner_test.go | 6 ++-- test/e2e/local/status_query_test.go | 8 ++--- 17 files changed, 140 insertions(+), 108 deletions(-) diff --git a/api/v1/create_job_coherencespec_test.go b/api/v1/create_job_coherencespec_test.go index 49e301a16..fb8ec0094 100644 --- a/api/v1/create_job_coherencespec_test.go +++ b/api/v1/create_job_coherencespec_test.go @@ -450,6 +450,10 @@ func TestCreateJobWithGlobalLabels(t *testing.T) { labelsExpected["one"] = "value-one" labelsExpected["two"] = "value-two" + podLabelsExpected := jobExpected.Spec.Template.Labels + podLabelsExpected["one"] = "value-one" + podLabelsExpected["two"] = "value-two" + // assert that the Job is as expected assertJobCreation(t, deployment, jobExpected) } @@ -477,6 +481,14 @@ func TestCreateJobWithGlobalAnnotations(t *testing.T) { annExpected["two"] = "value-two" jobExpected.Annotations = annExpected + podAnnExpected := jobExpected.Spec.Template.Annotations + if podAnnExpected == nil { + podAnnExpected = make(map[string]string) + } + podAnnExpected["one"] = "value-one" + podAnnExpected["two"] = "value-two" + jobExpected.Spec.Template.Annotations = podAnnExpected + // assert that the Job is as expected assertJobCreation(t, deployment, jobExpected) } diff --git a/api/v1/create_statefulset_test.go b/api/v1/create_statefulset_test.go index 7500a3b2d..d1a022685 100644 --- a/api/v1/create_statefulset_test.go +++ b/api/v1/create_statefulset_test.go @@ -677,13 +677,17 @@ func TestCreateStatefulSetWithGlobalLabels(t *testing.T) { // Create the test deployment deployment := createTestCoherenceDeployment(spec) // Create expected StatefulSet - jobExpected := createMinimalExpectedStatefulSet(deployment) - labelsExpected := jobExpected.Labels + stsExpected := createMinimalExpectedStatefulSet(deployment) + labelsExpected := stsExpected.Labels labelsExpected["one"] = "value-one" labelsExpected["two"] = "value-two" + podLabelsExpected := stsExpected.Spec.Template.Labels + podLabelsExpected["one"] = "value-one" + podLabelsExpected["two"] = "value-two" + // assert that the Job is as expected - assertStatefulSetCreation(t, deployment, jobExpected) + assertStatefulSetCreation(t, deployment, stsExpected) } func TestCreateStatefulSetWithGlobalAnnotations(t *testing.T) { @@ -700,15 +704,23 @@ func TestCreateStatefulSetWithGlobalAnnotations(t *testing.T) { // Create the test deployment deployment := createTestCoherenceDeployment(spec) // Create expected Job - jobExpected := createMinimalExpectedStatefulSet(deployment) - annExpected := jobExpected.Annotations + stsExpected := createMinimalExpectedStatefulSet(deployment) + annExpected := stsExpected.Annotations if annExpected == nil { annExpected = make(map[string]string) } annExpected["one"] = "value-one" annExpected["two"] = "value-two" - jobExpected.Annotations = annExpected + stsExpected.Annotations = annExpected + + podAnnExpected := stsExpected.Spec.Template.Annotations + if podAnnExpected == nil { + podAnnExpected = make(map[string]string) + } + podAnnExpected["one"] = "value-one" + podAnnExpected["two"] = "value-two" + stsExpected.Spec.Template.Annotations = podAnnExpected // assert that the Job is as expected - assertStatefulSetCreation(t, deployment, jobExpected) + assertStatefulSetCreation(t, deployment, stsExpected) } diff --git a/controllers/webhook/webhook_controller.go b/controllers/webhook/webhook_controller.go index 460cef928..318cf97ca 100644 --- a/controllers/webhook/webhook_controller.go +++ b/controllers/webhook/webhook_controller.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -119,7 +119,7 @@ func (r *CertReconciler) Reconcile(ctx context.Context, request reconcile.Reques // It also returns the duration after which a certificate rotation should be scheduled. func (r *CertReconciler) ReconcileResources(ctx context.Context) error { var err error - secretName := viper.GetString(operator.FlagWebhookSecret) + secretName := operator.GetViper().GetString(operator.FlagWebhookSecret) namespace := operator.GetNamespace() updateSecret := true diff --git a/pkg/runner/cmd_initialise.go b/pkg/runner/cmd_initialise.go index 23f02277f..639bc6fb6 100644 --- a/pkg/runner/cmd_initialise.go +++ b/pkg/runner/cmd_initialise.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -11,6 +11,7 @@ import ( v1 "github.com/oracle/coherence-operator/api/v1" "github.com/oracle/coherence-operator/pkg/utils" "github.com/spf13/cobra" + "github.com/spf13/viper" "os" ) @@ -186,7 +187,7 @@ func initialiseWithEnv(cmd *cobra.Command, getEnv EnvFunction) (bool, error) { } if len(c) != 0 { fmt.Printf("Running post initialisation command: %s\n", c) - _, err = ExecuteWithArgs(nil, c) + _, err = ExecuteWithArgsAndViper(nil, c, viper.GetViper()) return true, err } diff --git a/pkg/runner/cmd_operator_test.go b/pkg/runner/cmd_operator_test.go index 1b55d0808..4ead725e8 100644 --- a/pkg/runner/cmd_operator_test.go +++ b/pkg/runner/cmd_operator_test.go @@ -24,7 +24,7 @@ func TestBasicOperator(t *testing.T) { args := []string{"operator", "--dry-run"} env := EnvVarsFromDeployment(d) - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) @@ -47,7 +47,7 @@ func TestOperatorWithSingleGlobalLabel(t *testing.T) { args := []string{"operator", "--dry-run", "--global-label", "one=value-one"} env := EnvVarsFromDeployment(d) - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) @@ -71,7 +71,7 @@ func TestOperatorWithMultipleGlobalLabels(t *testing.T) { } env := EnvVarsFromDeployment(d) - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) @@ -93,7 +93,7 @@ func TestOperatorWithSingleGlobalAnnotation(t *testing.T) { args := []string{"operator", "--dry-run", "--global-annotation", "one=value-one"} env := EnvVarsFromDeployment(d) - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) @@ -117,7 +117,7 @@ func TestOperatorWithMultipleGlobalAnnotations(t *testing.T) { } env := EnvVarsFromDeployment(d) - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 0f5a81676..b308e9db5 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -93,8 +93,7 @@ type Execution struct { } // NewRootCommand builds the root cobra command that handles our command line tool. -func NewRootCommand(env map[string]string) (*cobra.Command, *viper.Viper) { - v := viper.New() +func NewRootCommand(env map[string]string, v *viper.Viper) *cobra.Command { operator.SetViper(v) // rootCommand is the Cobra root Command to execute @@ -127,7 +126,7 @@ func NewRootCommand(env map[string]string) (*cobra.Command, *viper.Viper) { rootCmd.AddCommand(jShellCommand()) rootCmd.AddCommand(sleepCommand()) - return rootCmd, v + return rootCmd } func initializeConfig(cmd *cobra.Command, v *viper.Viper, env map[string]string) error { @@ -174,7 +173,10 @@ func initializeConfig(cmd *cobra.Command, v *viper.Viper, env map[string]string) // Bind the current command's flags to viper bindFlags(cmd, v) - _ = v.BindPFlags(cmd.Parent().Flags()) + parent := cmd.Parent() + if parent != nil { + _ = v.BindPFlags(cmd.Parent().Flags()) + } _ = v.BindPFlags(cmd.PersistentFlags()) return nil } @@ -199,12 +201,17 @@ func bindFlags(cmd *cobra.Command, v *viper.Viper) { // Execute runs the runner with a given environment. func Execute() (Execution, error) { - return ExecuteWithArgs(nil, nil) + return ExecuteWithArgsAndViper(nil, nil, viper.GetViper()) +} + +// ExecuteWithArgsAndNewViper runs the runner with a given environment and argument overrides. +func ExecuteWithArgsAndNewViper(env map[string]string, args []string) (Execution, error) { + return ExecuteWithArgsAndViper(env, args, viper.New()) } -// ExecuteWithArgs runs the runner with a given environment and argument overrides. -func ExecuteWithArgs(env map[string]string, args []string) (Execution, error) { - cmd, v := NewRootCommand(env) +// ExecuteWithArgsAndViper runs the runner with a given environment and argument overrides. +func ExecuteWithArgsAndViper(env map[string]string, args []string, v *viper.Viper) (Execution, error) { + cmd := NewRootCommand(env, v) if len(args) > 0 { cmd.SetArgs(args) diff --git a/pkg/runner/runner_application_test.go b/pkg/runner/runner_application_test.go index 14721bc35..93ac3153b 100644 --- a/pkg/runner/runner_application_test.go +++ b/pkg/runner/runner_application_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -36,7 +36,7 @@ func TestApplicationArgsEmpty(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -66,7 +66,7 @@ func TestApplicationArgs(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "Foo", "Bar") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -100,7 +100,7 @@ func TestApplicationArgsWithEnvVarExpansion(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "foo-value", "bar-value") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -130,7 +130,7 @@ func TestApplicationMain(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := ReplaceArg(GetMinimalExpectedArgs(), "$DEFAULT$", "com.oracle.test.Main") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -163,7 +163,7 @@ func TestApplicationWorkingDirectory(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgsWithoutAppClasspath() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_application_type_test.go b/pkg/runner/runner_application_type_test.go index fa576ee5b..3c66e6c77 100644 --- a/pkg/runner/runner_application_type_test.go +++ b/pkg/runner/runner_application_type_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -34,7 +34,7 @@ func TestApplicationTypeNone(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -65,7 +65,7 @@ func TestApplicationTypeNoneWithMain(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := ReplaceArg(GetMinimalExpectedArgs(), DefaultMain, "com.foo.Bar") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -95,7 +95,7 @@ func TestApplicationTypeCoherence(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -126,7 +126,7 @@ func TestApplicationTypeCoherenceWithMain(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := ReplaceArg(GetMinimalExpectedArgs(), DefaultMain, "com.foo.Bar") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -156,7 +156,7 @@ func TestApplicationTypeJava(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -187,7 +187,7 @@ func TestApplicationTypeJavaWithMain(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := ReplaceArg(GetMinimalExpectedArgs(), DefaultMain, "com.foo.Bar") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -217,7 +217,7 @@ func TestApplicationTypeHelidon(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := ReplaceArg(GetMinimalExpectedArgs(), DefaultMain, HelidonMain) - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -248,7 +248,7 @@ func TestApplicationTypeHelidonWithMain(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := ReplaceArg(GetMinimalExpectedArgs(), DefaultMain, "com.foo.Bar") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(e).NotTo(BeNil()) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_coherence_test.go b/pkg/runner/runner_coherence_test.go index 16da291e3..00e2b0545 100644 --- a/pkg/runner/runner_coherence_test.go +++ b/pkg/runner/runner_coherence_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -32,7 +32,7 @@ func TestCoherenceClusterName(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.cluster="), "-Dcoherence.cluster=test-cluster") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -63,7 +63,7 @@ func TestCoherenceCacheConfig(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.cacheconfig="), "-Dcoherence.cacheconfig=test-config.xml") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -94,7 +94,7 @@ func TestCoherenceOperationalConfig(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.k8s.override="), "-Dcoherence.k8s.override=test-override.xml") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -125,7 +125,7 @@ func TestCoherenceStorageEnabledTrue(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.distributed.localstorage="), "-Dcoherence.distributed.localstorage=true") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -156,7 +156,7 @@ func TestCoherenceStorageEnabledFalse(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.distributed.localstorage="), "-Dcoherence.distributed.localstorage=false") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -186,7 +186,7 @@ func TestCoherenceExcludeFromWKATrue(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -217,7 +217,7 @@ func TestCoherenceLogLevel(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.log.level="), "-Dcoherence.log.level=9") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -248,7 +248,7 @@ func TestCoherenceTracingRatio(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-Dcoherence.tracing.ratio=0.012340") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -278,7 +278,7 @@ func TestCoherenceAllowEndangeredEmptyList(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -308,7 +308,7 @@ func TestCoherenceAllowEndangered(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-Dcoherence.k8s.operator.statusha.allowendangered=foo,bar") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -342,7 +342,7 @@ func TestCoherenceExistingWKADeploymentSameNamespace(t *testing.T) { expectedArgs := GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.wka") expectedArgs = append(expectedArgs, "-Dcoherence.wka=data"+coh.WKAServiceNameSuffix+".foo.svc") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -376,7 +376,7 @@ func TestCoherenceExistingWKADeploymentDifferentNamespace(t *testing.T) { expectedArgs := GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.wka") expectedArgs = append(expectedArgs, "-Dcoherence.wka=data"+coh.WKAServiceNameSuffix+".back-end.svc") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -406,7 +406,7 @@ func TestCoherenceEnableIpMonitor(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.ipmonitor.pingtimeout") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -436,7 +436,7 @@ func TestCoherenceDisableIpMonitor(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -466,7 +466,7 @@ func TestCoherenceDefaultIpMonitor(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_initialise_test.go b/pkg/runner/runner_initialise_test.go index bd4f99fc1..0d44baaee 100644 --- a/pkg/runner/runner_initialise_test.go +++ b/pkg/runner/runner_initialise_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -36,7 +36,7 @@ func TestInitialise(t *testing.T) { args, err := createArgs() g.Expect(err).NotTo(HaveOccurred()) - ex, err := ExecuteWithArgs(env, args) + ex, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(ex).NotTo(BeNil()) g.Expect(ex.OsCmd).To(BeNil()) @@ -56,7 +56,7 @@ func TestInitialiseWithCommand(t *testing.T) { args = append(args, "--cmd", "server,--dry-run") - ex, err := ExecuteWithArgs(env, args) + ex, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(ex).NotTo(BeNil()) g.Expect(ex.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_jvm_jibclasspath_test.go b/pkg/runner/runner_jvm_jibclasspath_test.go index db4259bbc..7afe9ad77 100644 --- a/pkg/runner/runner_jvm_jibclasspath_test.go +++ b/pkg/runner/runner_jvm_jibclasspath_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -37,7 +37,7 @@ func TestJibClasspath(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -69,7 +69,7 @@ func TestJibClasspathFile(t *testing.T) { defer os.Remove(f.Name()) expectedArgs := GetMinimalExpectedArgsWithAppClasspathFile() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -101,7 +101,7 @@ func TestJibMainClassFile(t *testing.T) { defer os.Remove(f.Name()) expectedArgs := GetMinimalExpectedArgsWithAppMainClassFile() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -135,7 +135,7 @@ func TestJibClasspathFileAndMainClassFile(t *testing.T) { defer os.Remove(f2.Name()) expectedArgs := GetMinimalExpectedArgsWithAppClasspathFileAndMainClassFile() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_jvm_memory_test.go b/pkg/runner/runner_jvm_memory_test.go index 9e0f1fc60..bee3f8401 100644 --- a/pkg/runner/runner_jvm_memory_test.go +++ b/pkg/runner/runner_jvm_memory_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -37,7 +37,7 @@ func TestJvmHeapSize(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:InitialHeapSize=10g", "-XX:MaxHeapSize=10g") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -69,7 +69,7 @@ func TestJvmInitialHeapSize(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:InitialHeapSize=10g") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -101,7 +101,7 @@ func TestJvmMaxHeapSize(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:MaxHeapSize=10g") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -135,7 +135,7 @@ func TestJvmHeapSizeOverridesInitialAndMaxHeapSize(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:InitialHeapSize=5g", "-XX:MaxHeapSize=5g") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -167,7 +167,7 @@ func TestJvmMaxRam(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:MaxRAM=10g") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -201,7 +201,7 @@ func TestJvmRamPercent(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgs(), "-XX:InitialRAMPercentage=5.500", "-XX:MaxRAMPercentage=5.500", "-XX:MinRAMPercentage=5.500") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -234,7 +234,7 @@ func TestJvmInitialRamPercent(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:InitialRAMPercentage=5.500") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -267,7 +267,7 @@ func TestJvmMaxRamPercent(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:MaxRAMPercentage=5.500") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -300,7 +300,7 @@ func TestJvmMinRamPercent(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:MinRAMPercentage=5.500") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -340,7 +340,7 @@ func TestJvmRamPercentOverridesInitialMaxAndMin(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgs(), "-XX:InitialRAMPercentage=5.500", "-XX:MaxRAMPercentage=5.500", "-XX:MinRAMPercentage=5.500") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -372,7 +372,7 @@ func TestJvmStackSize(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-Xss500k") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -404,7 +404,7 @@ func TestJvmMetaspaceSize(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:MetaspaceSize=5g", "-XX:MaxMetaspaceSize=5g") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -436,7 +436,7 @@ func TestJvmDirectMemorySize(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:MaxDirectMemorySize=5g") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -468,7 +468,7 @@ func TestJvmNativeMemoryTracking(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-XX:NativeMemoryTracking="), "-XX:NativeMemoryTracking=detail") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -502,7 +502,7 @@ func TestJvmOOMHeapDumpOff(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgsWithoutPrefix("-XX:+HeapDumpOnOutOfMemoryError") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -536,7 +536,7 @@ func TestJvmOOMExitOff(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgsWithoutPrefix("-XX:+ExitOnOutOfMemoryError") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_jvm_test.go b/pkg/runner/runner_jvm_test.go index fbdb06499..d4c596c07 100644 --- a/pkg/runner/runner_jvm_test.go +++ b/pkg/runner/runner_jvm_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -35,7 +35,7 @@ func TestJvmArgsEmpty(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -65,7 +65,7 @@ func TestJvmArgs(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-Dfoo=foo-value", "-Dbar=bar-value") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -99,7 +99,7 @@ func TestJvmArgsWithEnvExpansion(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-Dfoo=foo-value", "-Dbar=bar-value") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -129,7 +129,7 @@ func TestJvmUseContainerLimitsFalse(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgsWithoutPrefix("-XX:+UseContainerSupport") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -159,7 +159,7 @@ func TestJvmUseContainerLimitsTrue(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -191,7 +191,7 @@ func TestJvmGarbageCollectorG1(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-XX:+UseG1GC"), "-XX:+UseG1GC") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -223,7 +223,7 @@ func TestJvmGarbageCollectorCMS(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-XX:+UseG1GC"), "-XX:+UseConcMarkSweepGC") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -255,7 +255,7 @@ func TestJvmGarbageCollectorParallel(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-XX:+UseG1GC"), "-XX:+UseParallelGC") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -294,7 +294,7 @@ func TestJvmGarbageCollectorLoggingTrue(t *testing.T) { "-XX:+PrintGCApplicationStoppedTime", "-XX:+PrintGCApplicationConcurrentTime") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -326,7 +326,7 @@ func TestJvmGarbageCollectorArgsEmpty(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -358,7 +358,7 @@ func TestJvmGarbageCollectorArgs(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedArgs(), "-XX:Arg1", "-XX:Arg2") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_persistence_test.go b/pkg/runner/runner_persistence_test.go index 72d667106..66162c4bc 100644 --- a/pkg/runner/runner_persistence_test.go +++ b/pkg/runner/runner_persistence_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -37,7 +37,7 @@ func TestServerWithPersistenceMode(t *testing.T) { expectedArgs := append(GetMinimalExpectedArgsWithoutPrefix("-Dcoherence.distributed.persistence-mode="), "-Dcoherence.distributed.persistence-mode=active") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -57,7 +57,7 @@ func TestServerWithPersistenceDirectory(t *testing.T) { expectedCommand := GetJavaCommand() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -77,7 +77,7 @@ func TestServerWithSnapshotDirectory(t *testing.T) { expectedCommand := GetJavaCommand() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_spring_test.go b/pkg/runner/runner_spring_test.go index 5781f0cbf..2abc30b0f 100644 --- a/pkg/runner/runner_spring_test.go +++ b/pkg/runner/runner_spring_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -36,7 +36,7 @@ func TestSpringBootApplication(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedSpringBootArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -68,7 +68,7 @@ func TestSpringBootFatJarApplication(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedSpringBootFatJarArgs(jar) - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -101,7 +101,7 @@ func TestSpringBootFatJarApplicationWithCustomMain(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := append(GetMinimalExpectedSpringBootFatJarArgs(jar), "-Dloader.main=foo.Bar") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -133,7 +133,7 @@ func TestSpringBootBuildpacks(t *testing.T) { expectedCommand := getBuildpackLauncher() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/pkg/runner/runner_test.go b/pkg/runner/runner_test.go index 43dfe81ca..f528e0c92 100644 --- a/pkg/runner/runner_test.go +++ b/pkg/runner/runner_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -32,7 +32,7 @@ func TestMinimalDeployment(t *testing.T) { expectedCommand := GetJavaCommand() expectedArgs := GetMinimalExpectedArgs() - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) @@ -65,7 +65,7 @@ func TestMinimalServerSkipCoherenceVersionCheck(t *testing.T) { "-Dcoherence.k8s.operator.health.enabled=false", "-Dcoherence.health.http.port=6676") - e, err := ExecuteWithArgs(env, args) + e, err := ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) g.Expect(e).NotTo(BeNil()) g.Expect(e.OsCmd).NotTo(BeNil()) diff --git a/test/e2e/local/status_query_test.go b/test/e2e/local/status_query_test.go index 377e14f14..af43bf7a1 100644 --- a/test/e2e/local/status_query_test.go +++ b/test/e2e/local/status_query_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -26,12 +26,12 @@ func TestStatusForExistingCuster(t *testing.T) { // Should be Ready args := []string{"status", "--operator-url", "http://localhost:8000", "--namespace", ns, "--name", "minimal-cluster", "--timeout", "1m"} - _, err := runner.ExecuteWithArgs(env, args) + _, err := runner.ExecuteWithArgsAndNewViper(env, args) g.Expect(err).NotTo(HaveOccurred()) // Should not be Scaling args = []string{"status", "--operator-url", "http://localhost:8000", "--namespace", ns, "--name", "minimal-cluster", "--condition", string(coh.ConditionTypeScaling), "--timeout", "1m"} - _, err = runner.ExecuteWithArgs(env, args) + _, err = runner.ExecuteWithArgsAndNewViper(env, args) g.Expect(err).To(HaveOccurred()) } @@ -45,6 +45,6 @@ func TestStatusForNonExistentCluster(t *testing.T) { args := []string{"status", "--operator-url", "http://localhost:8000", "--namespace", ns, "--name", "foo", "--timeout", "30s"} // should not be found - _, err := runner.ExecuteWithArgs(env, args) + _, err := runner.ExecuteWithArgsAndNewViper(env, args) g.Expect(err).To(HaveOccurred()) }