Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat (kuberenetesDeploy) allow adding a timeout to the helm test commands #4310

Merged
merged 8 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/integrationArtifactTransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func runIntegrationArtifactTransport(config *integrationArtifactTransportOptions
return CreateIntegrationArtifactTransportRequest(config, apimData)
}

//CreateIntegrationArtifactTransportRequest - Create a transport request for Integration Package
// CreateIntegrationArtifactTransportRequest - Create a transport request for Integration Package
func CreateIntegrationArtifactTransportRequest(config *integrationArtifactTransportOptions, apistruct apim.Bundle) error {
httpMethod := http.MethodPost
httpClient := apistruct.Client
Expand Down Expand Up @@ -90,7 +90,7 @@ func CreateIntegrationArtifactTransportRequest(config *integrationArtifactTransp
return errors.Errorf("integration flow deployment failed, response Status code: %v", createTransportRequestResp.StatusCode)
}

//pollTransportStatus - Poll the integration package transport processing, return status or error details
// pollTransportStatus - Poll the integration package transport processing, return status or error details
func pollTransportStatus(processId string, remainingRetries int, config *integrationArtifactTransportOptions, httpClient piperhttp.Sender, apiHost string) error {

if remainingRetries <= 0 {
Expand Down Expand Up @@ -126,7 +126,7 @@ func pollTransportStatus(processId string, remainingRetries int, config *integra
return nil
}

//GetJSONPayload -return http payload as byte array
// GetJSONPayload -return http payload as byte array
func GetCPITransportReqPayload(config *integrationArtifactTransportOptions) (*bytes.Buffer, error) {
jsonObj := gabs.New()
jsonObj.Set(rand.Intn(5000), "id")
Expand All @@ -153,7 +153,7 @@ func GetCPITransportReqPayload(config *integrationArtifactTransportOptions) (*by
return bytes.NewBuffer(jsonBody), nil
}

//getIntegrationTransportProcessingStatus - Get integration package transport request processing Status
// getIntegrationTransportProcessingStatus - Get integration package transport request processing Status
func getIntegrationTransportProcessingStatus(config *integrationArtifactTransportOptions, httpClient piperhttp.Sender, apiHost string, processId string) (string, error) {
httpMethod := "GET"
header := make(http.Header)
Expand Down Expand Up @@ -192,7 +192,7 @@ func getIntegrationTransportProcessingStatus(config *integrationArtifactTranspor
return "", errors.Errorf("failed to get transport request processing status, response Status code: %v", transportProcStatusResp.StatusCode)
}

//getTransportError - Get integration package transport failures error details
// getTransportError - Get integration package transport failures error details
func getIntegrationTransportError(config *integrationArtifactTransportOptions, httpClient piperhttp.Sender, apiHost string, processId string) (string, error) {
httpMethod := "GET"
header := make(http.Header)
Expand Down
8 changes: 8 additions & 0 deletions cmd/kubernetesDeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ func runHelmDeploy(config kubernetesDeployOptions, utils kubernetes.DeployUtils,
"--namespace", config.Namespace,
}

if config.HelmTestWaitSeconds > 0 {
testParams = append(
testParams,
"--timeout",
strconv.Itoa(config.HelmTestWaitSeconds),
vstarostin marked this conversation as resolved.
Show resolved Hide resolved
)
}

if config.ShowTestLogs {
testParams = append(
testParams,
Expand Down
11 changes: 11 additions & 0 deletions cmd/kubernetesDeploy_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions cmd/kubernetesDeploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ func TestRunKubernetesDeploy(t *testing.T) {
DockerConfigJSON: ".pipeline/docker/config.json",
RunHelmTests: true,
ShowTestLogs: true,
HelmTestWaitSeconds: 300,
}

dockerConfigJSON := `{"kind": "Secret","data":{".dockerconfigjson": "ThisIsOurBase64EncodedSecret=="}}`
Expand Down Expand Up @@ -538,6 +539,8 @@ func TestRunKubernetesDeploy(t *testing.T) {
"deploymentName",
"--namespace",
"deploymentNamespace",
"--timeout",
"300",
"--logs",
}, mockUtils.Calls[2].Params, "Wrong test parameters")
})
Expand Down
8 changes: 8 additions & 0 deletions resources/metadata/kubernetesDeploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ spec:
- STAGES
- STEPS
default: 300
- name: helmTestWaitSeconds
type: int
description: Time to wait for any individual Kubernetes operation (like Jobs for hooks) . this param gets translated to `--timeout param` for helm cli during helm test.
Default value is 5m0s (5 min and 0 seconds) if not set via parameter. See https://helm.sh/docs/helm/helm_test/#options for further details
vstarostin marked this conversation as resolved.
Show resolved Hide resolved
scope:
- PARAMETERS
- STAGES
- STEPS
- name: helmValues
type: "[]string"
description: List of helm values as YAML file reference or URL (as per helm parameter description for `-f` / `--values`)
Expand Down