diff --git a/executor/linux/build_test.go b/executor/linux/build_test.go index c1297a4a..2bc35cca 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 @@ -1052,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, @@ -1059,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, @@ -1066,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, @@ -1073,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 @@ -1202,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, @@ -1209,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, @@ -1216,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, @@ -1223,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, @@ -1230,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, @@ -1237,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, @@ -1244,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, @@ -1251,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, @@ -1258,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, @@ -1265,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, @@ -1272,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, @@ -1279,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 @@ -1429,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, @@ -1436,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, @@ -1443,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, @@ -1450,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, @@ -1457,6 +1637,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, @@ -1464,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 @@ -1701,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, @@ -1727,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, @@ -1750,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, @@ -1774,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, @@ -1797,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, @@ -1821,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, @@ -1845,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, @@ -1869,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, @@ -1893,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) { @@ -2072,6 +2483,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, @@ -2079,6 +2497,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, @@ -2086,6 +2511,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, @@ -2093,6 +2525,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, @@ -2100,6 +2539,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, @@ -2107,6 +2553,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, @@ -2114,6 +2567,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, @@ -2121,6 +2581,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