mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-01-18 05:18:24 +02:00
feat (kuberenetesDeploy) allow adding a timeout to the helm test commands (#4310)
* adding a timeout for helm test * extending test cases * Upadate the helmTestWaitSeconds parameter * Add timeout parameter for helm test command * Update tests --------- Co-authored-by: Vyacheslav Starostin <vyacheslav.starostin@sap.com>
This commit is contained in:
parent
54d543a2c3
commit
17c9f5ca65
@ -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,
|
||||
|
@ -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{},
|
||||
|
@ -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")
|
||||
})
|
||||
|
@ -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`)
|
||||
|
Loading…
x
Reference in New Issue
Block a user