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

Fix Deployment acceptance tests #248

Merged
merged 1 commit into from
Dec 8, 2018

Conversation

pdecat
Copy link
Contributor

@pdecat pdecat commented Dec 7, 2018

This PR fixes some failing deployment acceptance tests (tested on GKE 1.11.4-gke.8):

 make testacc TEST=./kubernetes TESTARGS='-run=TestAccKubernetesDeployment_.* -count=1'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./kubernetes -v -run=TestAccKubernetesDeployment_.* -count=1 -timeout 120m
=== RUN   TestAccKubernetesDeployment_basic
--- PASS: TestAccKubernetesDeployment_basic (80.29s)
=== RUN   TestAccKubernetesDeployment_initContainer
--- PASS: TestAccKubernetesDeployment_initContainer (129.77s)
=== RUN   TestAccKubernetesDeployment_importBasic
--- PASS: TestAccKubernetesDeployment_importBasic (129.93s)
=== RUN   TestAccKubernetesDeployment_generatedName
--- PASS: TestAccKubernetesDeployment_generatedName (1.69s)
=== RUN   TestAccKubernetesDeployment_importGeneratedName
--- PASS: TestAccKubernetesDeployment_importGeneratedName (18.11s)
=== RUN   TestAccKubernetesDeployment_with_security_context
--- FAIL: TestAccKubernetesDeployment_with_security_context (600.93s)
        testing.go:518: Step 0 error: Error applying: 1 error(s) occurred:

                * kubernetes_deployment.test: 1 error(s) occurred:

                * kubernetes_deployment.test: Waiting for rollout to finish: 0 of 1 updated replicas are available...
=== RUN   TestAccKubernetesDeployment_with_container_liveness_probe_using_exec
--- PASS: TestAccKubernetesDeployment_with_container_liveness_probe_using_exec (3.57s)
=== RUN   TestAccKubernetesDeployment_with_container_liveness_probe_using_http_get
--- PASS: TestAccKubernetesDeployment_with_container_liveness_probe_using_http_get (3.54s)
=== RUN   TestAccKubernetesDeployment_with_container_liveness_probe_using_tcp
--- PASS: TestAccKubernetesDeployment_with_container_liveness_probe_using_tcp (3.54s)
=== RUN   TestAccKubernetesDeployment_with_container_lifecycle
--- FAIL: TestAccKubernetesDeployment_with_container_lifecycle (600.94s)
        testing.go:518: Step 0 error: Error applying: 1 error(s) occurred:

                * kubernetes_deployment.test: 1 error(s) occurred:

                * kubernetes_deployment.test: Waiting for rollout to finish: 0 of 1 updated replicas are available...
=== RUN   TestAccKubernetesDeployment_with_container_security_context
--- FAIL: TestAccKubernetesDeployment_with_container_security_context (600.97s)
        testing.go:518: Step 0 error: Error applying: 1 error(s) occurred:

                * kubernetes_deployment.test: 1 error(s) occurred:

                * kubernetes_deployment.test: Waiting for rollout to finish: 0 of 1 updated replicas are available...
=== RUN   TestAccKubernetesDeployment_with_volume_mount
--- PASS: TestAccKubernetesDeployment_with_volume_mount (4.70s)
=== RUN   TestAccKubernetesDeployment_with_resource_requirements
--- PASS: TestAccKubernetesDeployment_with_resource_requirements (3.51s)
=== RUN   TestAccKubernetesDeployment_with_empty_dir_volume
--- PASS: TestAccKubernetesDeployment_with_empty_dir_volume (3.51s)
FAIL
FAIL    github.com/terraform-providers/terraform-provider-kubernetes/kubernetes 2185.048s
make: *** [GNUmakefile:17: testacc] Error 1

The TestAccKubernetesDeployment_with_security_context and TestAccKubernetesDeployment_with_container_security_context test are timing out with containers in CrashLoopBackOff with the following container logs:

2018/12/07 19:00:24 [warn] 1#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
2018/12/07 19:00:24 [emerg] 1#0: mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)
nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)

Using nginx images when security contexts define containers to run as non root user is known to cause issues:

Work-around: use some other image such as redis.

The TestAccKubernetesDeployment_with_container_lifecycle test is timing out with containers in CrashLoopBackOff because the gcr.io/google_containers/liveness image used in that test only contains the /server executable, but no shell, ls or date executables:

# kubectl --context=gke_cloudpublic-sandbox_us-east1_pdecat-terraform-kubernetes-testacc get pod tf-acc-test-nza00o9x1u-dcffd6bf6-jwmx8
NAME                                     READY   STATUS                                                   RESTARTS   AGE
tf-acc-test-nza00o9x1u-dcffd6bf6-jwmx8   0/1     PostStartHookError: command 'ls -al' exited with 126:    5          2m
# kubectl get event |grep "ls -al"
1m          1m           3       tf-acc-test-nza00o9x1u-dcffd6bf6-jwmx8.156e1e06346f7435          Pod          spec.containers{containername}   Warning   FailedPostStartHook      kubelet, gke-pdecat-terraform-kub-default-pool-318bb3a5-ns08   Exec lifecycle hook ([ls -al]) for Container "containername" in Pod "tf-acc-test-nza00o9x1u-dcffd6bf6-jwmx8_default(e5857cae-fa47-11e8-8ad1-42010a8e0070)" failed - error: command 'ls -al' exited with 126: , message: "rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused \"exec: \\\"ls\\\": executable file not found in $PATH\"\n\r\n"

Work-around: use gcr.io/google_containers/busybox image.

@ghost ghost added the size/XS label Dec 7, 2018
@pdecat
Copy link
Contributor Author

pdecat commented Dec 7, 2018

Acceptance tests results with these changes:

# make testacc TEST=./kubernetes TESTARGS='-run=TestAccKubernetesDeployment_.* -count=1'                                                                                               
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./kubernetes -v -run=TestAccKubernetesDeployment_.* -count=1 -timeout 120m
=== RUN   TestAccKubernetesDeployment_basic
--- PASS: TestAccKubernetesDeployment_basic (69.35s)
=== RUN   TestAccKubernetesDeployment_initContainer
--- PASS: TestAccKubernetesDeployment_initContainer (1.89s)
=== RUN   TestAccKubernetesDeployment_importBasic
--- PASS: TestAccKubernetesDeployment_importBasic (129.24s)
=== RUN   TestAccKubernetesDeployment_generatedName
--- PASS: TestAccKubernetesDeployment_generatedName (17.49s)
=== RUN   TestAccKubernetesDeployment_importGeneratedName
--- PASS: TestAccKubernetesDeployment_importGeneratedName (58.27s)
=== RUN   TestAccKubernetesDeployment_with_security_context
--- PASS: TestAccKubernetesDeployment_with_security_context (1.42s)
=== RUN   TestAccKubernetesDeployment_with_container_liveness_probe_using_exec
--- PASS: TestAccKubernetesDeployment_with_container_liveness_probe_using_exec (17.54s)
=== RUN   TestAccKubernetesDeployment_with_container_liveness_probe_using_http_get
--- PASS: TestAccKubernetesDeployment_with_container_liveness_probe_using_http_get (17.48s)
=== RUN   TestAccKubernetesDeployment_with_container_liveness_probe_using_tcp
--- PASS: TestAccKubernetesDeployment_with_container_liveness_probe_using_tcp (9.46s)
=== RUN   TestAccKubernetesDeployment_with_container_lifecycle
--- PASS: TestAccKubernetesDeployment_with_container_lifecycle (9.49s)
=== RUN   TestAccKubernetesDeployment_with_container_security_context
--- PASS: TestAccKubernetesDeployment_with_container_security_context (9.35s)
=== RUN   TestAccKubernetesDeployment_with_volume_mount
--- PASS: TestAccKubernetesDeployment_with_volume_mount (10.31s)
=== RUN   TestAccKubernetesDeployment_with_resource_requirements
--- PASS: TestAccKubernetesDeployment_with_resource_requirements (9.46s)
=== RUN   TestAccKubernetesDeployment_with_empty_dir_volume
--- PASS: TestAccKubernetesDeployment_with_empty_dir_volume (9.39s)
PASS
ok      github.com/terraform-providers/terraform-provider-kubernetes/kubernetes 370.187s

@pdecat
Copy link
Contributor Author

pdecat commented Dec 7, 2018

I had to fix these before addressing #247 (shaving yaks here 😄 )

Copy link
Member

@alexsomesan alexsomesan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing these.
Running the internal CI for this PR. If all works well, we're good to go.

Copy link
Member

@alexsomesan alexsomesan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is all green.
LGTM

@alexsomesan alexsomesan merged commit f4d689f into hashicorp:master Dec 8, 2018
@pdecat pdecat deleted the fix-deployment-testacc branch December 9, 2018 11:12
@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants