From d0fefc9a3bb629c91676b3d68ac9395a35b578fc Mon Sep 17 00:00:00 2001 From: JordanBrockopp Date: Tue, 4 Oct 2022 13:38:20 -0500 Subject: [PATCH 1/4] test(executor): add kubernetes runtime to CreateBuild test --- executor/linux/build_test.go | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/executor/linux/build_test.go b/executor/linux/build_test.go index c1297a4a..68f95a9f 100644 --- a/executor/linux/build_test.go +++ b/executor/linux/build_test.go @@ -69,6 +69,14 @@ func TestLinux_CreateBuild(t *testing.T) { build: _build, pipeline: "testdata/build/secrets/basic.yml", }, + { + name: "kubernetes-basic secrets pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + build: _build, + pipeline: "testdata/build/secrets/basic.yml", + }, { name: "docker-basic services pipeline", failure: false, @@ -77,6 +85,14 @@ func TestLinux_CreateBuild(t *testing.T) { build: _build, pipeline: "testdata/build/services/basic.yml", }, + { + name: "kubernetes-basic services pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + build: _build, + pipeline: "testdata/build/services/basic.yml", + }, { name: "docker-basic steps pipeline", failure: false, @@ -85,6 +101,14 @@ func TestLinux_CreateBuild(t *testing.T) { build: _build, pipeline: "testdata/build/steps/basic.yml", }, + { + name: "kubernetes-basic steps pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + build: _build, + pipeline: "testdata/build/steps/basic.yml", + }, { name: "docker-basic stages pipeline", failure: false, @@ -93,6 +117,14 @@ func TestLinux_CreateBuild(t *testing.T) { build: _build, pipeline: "testdata/build/stages/basic.yml", }, + { + name: "kubernetes-basic stages pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + build: _build, + pipeline: "testdata/build/stages/basic.yml", + }, { name: "docker-steps pipeline with empty build", failure: true, @@ -101,6 +133,14 @@ func TestLinux_CreateBuild(t *testing.T) { build: new(library.Build), pipeline: "testdata/build/steps/basic.yml", }, + { + name: "kubernetes-steps pipeline with empty build", + failure: true, + logError: false, + runtime: constants.DriverKubernetes, + build: new(library.Build), + pipeline: "testdata/build/steps/basic.yml", + }, } // run test @@ -1457,6 +1497,13 @@ func TestLinux_ExecBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/stages/basic.yml", }, + { + name: "kubernetes-basic stages pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/stages/basic.yml", + }, { name: "docker-stages pipeline with image not found", failure: true, From bd09bd1a97c787191f32aaead8028dd8444a0cda Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Fri, 7 Oct 2022 21:54:55 -0500 Subject: [PATCH 2/4] test: Use kubernetes runtime in executor build tests The kubernetes Mock does not support some of the failure modes simulated by the docker Mock. So, those test cases are commented out with a FIXME. --- executor/linux/build_test.go | 348 +++++++++++++++++++++++++++++++++++ 1 file changed, 348 insertions(+) diff --git a/executor/linux/build_test.go b/executor/linux/build_test.go index 68f95a9f..8b5ca437 100644 --- a/executor/linux/build_test.go +++ b/executor/linux/build_test.go @@ -1092,6 +1092,13 @@ func TestLinux_PlanBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/secrets/basic.yml", }, + { + name: "kubernetes-basic secrets pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/secrets/basic.yml", + }, { name: "docker-basic services pipeline", failure: false, @@ -1099,6 +1106,13 @@ func TestLinux_PlanBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/services/basic.yml", }, + { + name: "kubernetes-basic services pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/services/basic.yml", + }, { name: "docker-basic steps pipeline", failure: false, @@ -1106,6 +1120,13 @@ func TestLinux_PlanBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/steps/basic.yml", }, + { + name: "kubernetes-basic steps pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + }, { name: "docker-basic stages pipeline", failure: false, @@ -1113,6 +1134,13 @@ func TestLinux_PlanBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/stages/basic.yml", }, + { + name: "kubernetes-basic stages pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/stages/basic.yml", + }, } // run test @@ -1242,6 +1270,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/secrets/basic.yml", }, + { + name: "kubernetes-basic secrets pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/secrets/basic.yml", + }, { name: "docker-secrets pipeline with image not found", failure: true, @@ -1249,6 +1284,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/secrets/img_notfound.yml", }, + //{ + // name: "kubernetes-secrets pipeline with image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/secrets/img_notfound.yml", + //}, { name: "docker-secrets pipeline with ignoring image not found", failure: true, @@ -1256,6 +1298,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/secrets/img_ignorenotfound.yml", }, + //{ + // name: "kubernetes-secrets pipeline with ignoring image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/secrets/img_ignorenotfound.yml", + //}, { name: "docker-basic services pipeline", failure: false, @@ -1263,6 +1312,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/services/basic.yml", }, + { + name: "kubernetes-basic services pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/services/basic.yml", + }, { name: "docker-services pipeline with image not found", failure: true, @@ -1270,6 +1326,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/services/img_notfound.yml", }, + //{ + // name: "kubernetes-services pipeline with image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/services/img_notfound.yml", + //}, { name: "docker-services pipeline with ignoring image not found", failure: true, @@ -1277,6 +1340,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/services/img_ignorenotfound.yml", }, + //{ + // name: "kubernetes-services pipeline with ignoring image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/services/img_ignorenotfound.yml", + //}, { name: "docker-basic steps pipeline", failure: false, @@ -1284,6 +1354,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/steps/basic.yml", }, + { + name: "kubernetes-basic steps pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + }, { name: "docker-steps pipeline with image not found", failure: true, @@ -1291,6 +1368,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/steps/img_notfound.yml", }, + //{ + // name: "kubernetes-steps pipeline with image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/steps/img_notfound.yml", + //}, { name: "docker-steps pipeline with ignoring image not found", failure: true, @@ -1298,6 +1382,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/steps/img_ignorenotfound.yml", }, + //{ + // name: "kubernetes-steps pipeline with ignoring image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/steps/img_ignorenotfound.yml", + //}, { name: "docker-basic stages pipeline", failure: false, @@ -1305,6 +1396,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/stages/basic.yml", }, + { + name: "kubernetes-basic stages pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/stages/basic.yml", + }, { name: "docker-stages pipeline with image not found", failure: true, @@ -1312,6 +1410,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/stages/img_notfound.yml", }, + //{ + // name: "kubernetes-stages pipeline with image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/stages/img_notfound.yml", + //}, { name: "docker-stages pipeline with ignoring image not found", failure: true, @@ -1319,6 +1424,13 @@ func TestLinux_AssembleBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/stages/img_ignorenotfound.yml", }, + //{ + // name: "kubernetes-stages pipeline with ignoring image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/stages/img_ignorenotfound.yml", + //}, } // run test @@ -1469,6 +1581,13 @@ func TestLinux_ExecBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/services/basic.yml", }, + { + name: "kubernetes-basic services pipeline", + failure: false, // fixed + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/services/basic.yml", + }, { name: "docker-services pipeline with image not found", failure: true, @@ -1476,6 +1595,13 @@ func TestLinux_ExecBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/services/img_notfound.yml", }, + //{ + // name: "kubernetes-services pipeline with image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/services/img_notfound.yml", + //}, { name: "docker-basic steps pipeline", failure: false, @@ -1483,6 +1609,13 @@ func TestLinux_ExecBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/steps/basic.yml", }, + { + name: "kubernetes-basic steps pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + }, { name: "docker-steps pipeline with image not found", failure: true, @@ -1490,6 +1623,13 @@ func TestLinux_ExecBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/steps/img_notfound.yml", }, + //{ + // name: "kubernetes-steps pipeline with image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/steps/img_notfound.yml", + //}, { name: "docker-basic stages pipeline", failure: false, @@ -1511,6 +1651,13 @@ func TestLinux_ExecBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/stages/img_notfound.yml", }, + //{ + // name: "kubernetes-stages pipeline with image not found", + // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/stages/img_notfound.yml", + //}, } // run test @@ -1748,6 +1895,31 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-basic services pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/services/basic.yml", + messageKey: "service", + streamFunc: func(c *client) message.StreamFunc { + return c.StreamService + }, + planFunc: func(c *client) planFuncType { + return c.PlanService + }, + ctn: &pipeline.Container{ + ID: "service-github-octocat-1-postgres", + Detach: true, + Directory: "/vela/src/github.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "postgres:latest", + Name: "postgres", + Number: 1, + Ports: []string{"5432:5432"}, + Pull: "not_present", + }, + }, { name: "docker-basic services pipeline with StreamService failure", failure: false, @@ -1774,6 +1946,32 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-basic services pipeline with StreamService failure", + failure: false, + logError: true, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/services/basic.yml", + messageKey: "service", + streamFunc: func(c *client) message.StreamFunc { + return c.StreamService + }, + planFunc: func(c *client) planFuncType { + // simulate failure to call PlanService + return planNothing + }, + ctn: &pipeline.Container{ + ID: "service-github-octocat-1-postgres", + Detach: true, + Directory: "/vela/src/github.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "postgres:latest", + Name: "postgres", + Number: 1, + Ports: []string{"5432:5432"}, + Pull: "not_present", + }, + }, { name: "docker-basic steps pipeline", failure: false, @@ -1797,6 +1995,29 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-basic steps pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + messageKey: "step", + streamFunc: func(c *client) message.StreamFunc { + return c.StreamStep + }, + planFunc: func(c *client) planFuncType { + return c.PlanStep + }, + ctn: &pipeline.Container{ + ID: "step-github-octocat-1-test", + Directory: "/vela/src/github.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "alpine:latest", + Name: "test", + Number: 1, + Pull: "not_present", + }, + }, { name: "docker-basic steps pipeline with StreamStep failure", failure: false, @@ -1821,6 +2042,30 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-basic steps pipeline with StreamStep failure", + failure: false, + logError: true, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + messageKey: "step", + streamFunc: func(c *client) message.StreamFunc { + return c.StreamStep + }, + planFunc: func(c *client) planFuncType { + // simulate failure to call PlanStep + return planNothing + }, + ctn: &pipeline.Container{ + ID: "step-github-octocat-1-test", + Directory: "/vela/src/github.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "alpine:latest", + Name: "test", + Number: 1, + Pull: "not_present", + }, + }, { name: "docker-basic stages pipeline", failure: false, @@ -1844,6 +2089,29 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-basic stages pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/stages/basic.yml", + messageKey: "step", + streamFunc: func(c *client) message.StreamFunc { + return c.StreamStep + }, + planFunc: func(c *client) planFuncType { + return c.PlanStep + }, + ctn: &pipeline.Container{ + ID: "step-github-octocat-1-test-test", + Directory: "/vela/src/github.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "alpine:latest", + Name: "test", + Number: 1, + Pull: "not_present", + }, + }, { name: "docker-basic secrets pipeline", failure: false, @@ -1868,6 +2136,30 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-basic secrets pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/secrets/basic.yml", + messageKey: "secret", + streamFunc: func(c *client) message.StreamFunc { + return c.secret.stream + }, + planFunc: func(c *client) planFuncType { + // no plan function equivalent for secret containers + return planNothing + }, + ctn: &pipeline.Container{ + ID: "secret-github-octocat-1-vault", + Directory: "/vela/src/vcs.company.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "target/secret-vault:latest", + Name: "vault", + Number: 1, + Pull: "not_present", + }, + }, { name: "docker-early exit from ExecBuild", failure: false, @@ -2119,6 +2411,13 @@ func TestLinux_DestroyBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/secrets/basic.yml", }, + { + name: "kubernetes-basic secrets pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/secrets/basic.yml", + }, { name: "docker-secrets pipeline with name not found", failure: false, @@ -2126,6 +2425,13 @@ func TestLinux_DestroyBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/secrets/name_notfound.yml", }, + //{ + // name: "kubernetes-secrets pipeline with name not found", + // failure: false, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/secrets/name_notfound.yml", + //}, { name: "docker-basic services pipeline", failure: false, @@ -2133,6 +2439,13 @@ func TestLinux_DestroyBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/services/basic.yml", }, + { + name: "kubernetes-basic services pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/services/basic.yml", + }, { name: "docker-services pipeline with name not found", failure: false, @@ -2140,6 +2453,13 @@ func TestLinux_DestroyBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/services/name_notfound.yml", }, + //{ + // name: "kubernetes-services pipeline with name not found", + // failure: false, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/services/name_notfound.yml", + //}, { name: "docker-basic steps pipeline", failure: false, @@ -2147,6 +2467,13 @@ func TestLinux_DestroyBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/steps/basic.yml", }, + { + name: "kubernetes-basic steps pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + }, { name: "docker-steps pipeline with name not found", failure: false, @@ -2154,6 +2481,13 @@ func TestLinux_DestroyBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/steps/name_notfound.yml", }, + //{ + // name: "kubernetes-steps pipeline with name not found", + // failure: false, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/steps/name_notfound.yml", + //}, { name: "docker-basic stages pipeline", failure: false, @@ -2161,6 +2495,13 @@ func TestLinux_DestroyBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/stages/basic.yml", }, + { + name: "kubernetes-basic stages pipeline", + failure: false, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/stages/basic.yml", + }, { name: "docker-stages pipeline with name not found", failure: false, @@ -2168,6 +2509,13 @@ func TestLinux_DestroyBuild(t *testing.T) { runtime: constants.DriverDocker, pipeline: "testdata/build/stages/name_notfound.yml", }, + //{ + // name: "kubernetes-stages pipeline with name not found", + // failure: false, // FIXME: make Kubernetes mock simulate failure similar to Docker mock + // logError: false, + // runtime: constants.DriverKubernetes, + // pipeline: "testdata/build/stages/name_notfound.yml", + //}, } // run test From 7f2e99fe7d53047c11ea0afc07a88b366653e0a7 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 28 Feb 2023 12:06:00 -0600 Subject: [PATCH 3/4] cleanup commented blocks --- executor/linux/build_test.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/executor/linux/build_test.go b/executor/linux/build_test.go index 8b5ca437..0756f3f3 100644 --- a/executor/linux/build_test.go +++ b/executor/linux/build_test.go @@ -1287,7 +1287,7 @@ func TestLinux_AssembleBuild(t *testing.T) { //{ // name: "kubernetes-secrets pipeline with image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/secrets/img_notfound.yml", //}, @@ -1301,7 +1301,7 @@ func TestLinux_AssembleBuild(t *testing.T) { //{ // name: "kubernetes-secrets pipeline with ignoring image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/secrets/img_ignorenotfound.yml", //}, @@ -1329,7 +1329,7 @@ func TestLinux_AssembleBuild(t *testing.T) { //{ // name: "kubernetes-services pipeline with image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/services/img_notfound.yml", //}, @@ -1343,7 +1343,7 @@ func TestLinux_AssembleBuild(t *testing.T) { //{ // name: "kubernetes-services pipeline with ignoring image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/services/img_ignorenotfound.yml", //}, @@ -1371,7 +1371,7 @@ func TestLinux_AssembleBuild(t *testing.T) { //{ // name: "kubernetes-steps pipeline with image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/steps/img_notfound.yml", //}, @@ -1385,7 +1385,7 @@ func TestLinux_AssembleBuild(t *testing.T) { //{ // name: "kubernetes-steps pipeline with ignoring image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/steps/img_ignorenotfound.yml", //}, @@ -1413,7 +1413,7 @@ func TestLinux_AssembleBuild(t *testing.T) { //{ // name: "kubernetes-stages pipeline with image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/stages/img_notfound.yml", //}, @@ -1427,7 +1427,7 @@ func TestLinux_AssembleBuild(t *testing.T) { //{ // name: "kubernetes-stages pipeline with ignoring image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/stages/img_ignorenotfound.yml", //}, @@ -1598,7 +1598,7 @@ func TestLinux_ExecBuild(t *testing.T) { //{ // name: "kubernetes-services pipeline with image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/services/img_notfound.yml", //}, @@ -1626,7 +1626,7 @@ func TestLinux_ExecBuild(t *testing.T) { //{ // name: "kubernetes-steps pipeline with image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/steps/img_notfound.yml", //}, @@ -1654,7 +1654,7 @@ func TestLinux_ExecBuild(t *testing.T) { //{ // name: "kubernetes-stages pipeline with image not found", // failure: true, // FIXME: make Kubernetes mock simulate failure similar to Docker mock - // logError: false, + // logError: false, // runtime: constants.DriverKubernetes, // pipeline: "testdata/build/stages/img_notfound.yml", //}, From ef698f82e0dbb1231a8b57ab964c743a816635e7 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Tue, 28 Feb 2023 12:32:23 -0600 Subject: [PATCH 4/4] test(executor): add remaining StreamBuild k8s test cases --- executor/linux/build_test.go | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/executor/linux/build_test.go b/executor/linux/build_test.go index 0756f3f3..2bc35cca 100644 --- a/executor/linux/build_test.go +++ b/executor/linux/build_test.go @@ -2184,6 +2184,30 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-early exit from ExecBuild", + failure: false, + earlyExecExit: true, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + messageKey: "step", + streamFunc: func(c *client) message.StreamFunc { + return c.StreamStep + }, + planFunc: func(c *client) planFuncType { + return c.PlanStep + }, + ctn: &pipeline.Container{ + ID: "step-github-octocat-1-test", + Directory: "/vela/src/github.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "alpine:latest", + Name: "test", + Number: 1, + Pull: "not_present", + }, + }, { name: "docker-build complete before ExecBuild called", failure: false, @@ -2208,6 +2232,30 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-build complete before ExecBuild called", + failure: false, + earlyBuildDone: true, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + messageKey: "step", + streamFunc: func(c *client) message.StreamFunc { + return c.StreamStep + }, + planFunc: func(c *client) planFuncType { + return c.PlanStep + }, + ctn: &pipeline.Container{ + ID: "step-github-octocat-1-test", + Directory: "/vela/src/github.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "alpine:latest", + Name: "test", + Number: 1, + Pull: "not_present", + }, + }, { name: "docker-early exit from ExecBuild and build complete signaled", failure: false, @@ -2232,6 +2280,30 @@ func TestLinux_StreamBuild(t *testing.T) { Pull: "not_present", }, }, + { + name: "kubernetes-early exit from ExecBuild and build complete signaled", + failure: false, + earlyExecExit: true, + logError: false, + runtime: constants.DriverKubernetes, + pipeline: "testdata/build/steps/basic.yml", + messageKey: "step", + streamFunc: func(c *client) message.StreamFunc { + return c.StreamStep + }, + planFunc: func(c *client) planFuncType { + return c.PlanStep + }, + ctn: &pipeline.Container{ + ID: "step-github-octocat-1-test", + Directory: "/vela/src/github.com/github/octocat", + Environment: map[string]string{"FOO": "bar"}, + Image: "alpine:latest", + Name: "test", + Number: 1, + Pull: "not_present", + }, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) {