diff --git a/cmd/kubernetesDeploy.go b/cmd/kubernetesDeploy.go index 2544834d78..c1659117a5 100644 --- a/cmd/kubernetesDeploy.go +++ b/cmd/kubernetesDeploy.go @@ -226,6 +226,14 @@ func runHelmDeploy(config kubernetesDeployOptions, utils kubernetes.DeployUtils, "--namespace", config.Namespace, } + if config.DeployTool == "helm" { + testParams = append(testParams, "--timeout", strconv.Itoa(config.HelmTestWaitSeconds)) + } + + if config.DeployTool == "helm3" { + testParams = append(testParams, "--timeout", fmt.Sprintf("%vs", config.HelmTestWaitSeconds)) + } + if config.ShowTestLogs { testParams = append( testParams, diff --git a/cmd/kubernetesDeploy_generated.go b/cmd/kubernetesDeploy_generated.go index cf4165cccc..0a3a27acc2 100644 --- a/cmd/kubernetesDeploy_generated.go +++ b/cmd/kubernetesDeploy_generated.go @@ -31,6 +31,7 @@ type kubernetesDeployOptions struct { DeployTool string `json:"deployTool,omitempty" validate:"possible-values=kubectl helm helm3"` ForceUpdates bool `json:"forceUpdates,omitempty"` HelmDeployWaitSeconds int `json:"helmDeployWaitSeconds,omitempty"` + HelmTestWaitSeconds int `json:"helmTestWaitSeconds,omitempty"` HelmValues []string `json:"helmValues,omitempty"` ValuesMapping map[string]interface{} `json:"valuesMapping,omitempty"` GithubToken string `json:"githubToken,omitempty"` @@ -185,6 +186,7 @@ func addKubernetesDeployFlags(cmd *cobra.Command, stepConfig *kubernetesDeployOp cmd.Flags().StringVar(&stepConfig.DeployTool, "deployTool", `kubectl`, "Defines the tool which should be used for deployment.") cmd.Flags().BoolVar(&stepConfig.ForceUpdates, "forceUpdates", true, "Adds `--force` flag to a helm resource update command or to a kubectl replace command") cmd.Flags().IntVar(&stepConfig.HelmDeployWaitSeconds, "helmDeployWaitSeconds", 300, "Number of seconds before helm deploy returns.") + cmd.Flags().IntVar(&stepConfig.HelmTestWaitSeconds, "helmTestWaitSeconds", 300, "Number of seconds to wait for any individual Kubernetes operation (like Jobs for hooks). See https://helm.sh/docs/helm/helm_test/#options for further details") cmd.Flags().StringSliceVar(&stepConfig.HelmValues, "helmValues", []string{}, "List of helm values as YAML file reference or URL (as per helm parameter description for `-f` / `--values`)") cmd.Flags().StringVar(&stepConfig.GithubToken, "githubToken", os.Getenv("PIPER_githubToken"), "GitHub personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line") @@ -416,6 +418,15 @@ func kubernetesDeployMetadata() config.StepData { Aliases: []config.Alias{}, Default: 300, }, + { + Name: "helmTestWaitSeconds", + ResourceRef: []config.ResourceReference{}, + Scope: []string{"PARAMETERS", "STAGES", "STEPS"}, + Type: "int", + Mandatory: false, + Aliases: []config.Alias{}, + Default: 300, + }, { Name: "helmValues", ResourceRef: []config.ResourceReference{}, diff --git a/cmd/kubernetesDeploy_test.go b/cmd/kubernetesDeploy_test.go index 0fd3f2f12f..f8796192ed 100644 --- a/cmd/kubernetesDeploy_test.go +++ b/cmd/kubernetesDeploy_test.go @@ -402,6 +402,7 @@ func TestRunKubernetesDeploy(t *testing.T) { Namespace: "deploymentNamespace", DockerConfigJSON: ".pipeline/docker/config.json", RunHelmTests: true, + HelmTestWaitSeconds: 400, } dockerConfigJSON := `{"kind": "Secret","data":{".dockerconfigjson": "ThisIsOurBase64EncodedSecret=="}}` @@ -459,6 +460,8 @@ func TestRunKubernetesDeploy(t *testing.T) { "deploymentName", "--namespace", "deploymentNamespace", + "--timeout", + "400s", }, mockUtils.Calls[2].Params, "Wrong test parameters") }) @@ -481,6 +484,7 @@ func TestRunKubernetesDeploy(t *testing.T) { DockerConfigJSON: ".pipeline/docker/config.json", RunHelmTests: true, ShowTestLogs: true, + HelmTestWaitSeconds: 400, } dockerConfigJSON := `{"kind": "Secret","data":{".dockerconfigjson": "ThisIsOurBase64EncodedSecret=="}}` @@ -538,6 +542,8 @@ func TestRunKubernetesDeploy(t *testing.T) { "deploymentName", "--namespace", "deploymentNamespace", + "--timeout", + "400s", "--logs", }, mockUtils.Calls[2].Params, "Wrong test parameters") }) diff --git a/resources/metadata/kubernetesDeploy.yaml b/resources/metadata/kubernetesDeploy.yaml index 8bc1ea5336..ab0024cf21 100644 --- a/resources/metadata/kubernetesDeploy.yaml +++ b/resources/metadata/kubernetesDeploy.yaml @@ -279,6 +279,14 @@ spec: - STAGES - STEPS default: 300 + - name: helmTestWaitSeconds + type: int + description: Number of seconds to wait for any individual Kubernetes operation (like Jobs for hooks). See https://helm.sh/docs/helm/helm_test/#options for further details + scope: + - PARAMETERS + - STAGES + - STEPS + default: 300 - name: helmValues type: "[]string" description: List of helm values as YAML file reference or URL (as per helm parameter description for `-f` / `--values`)