onbuild integration test

This commit is contained in:
Priya Wadhwa 2018-04-04 17:06:09 -07:00
parent 27f964957b
commit 59a5950e9e
No known key found for this signature in database
GPG Key ID: 0D0DAFD8F7AA73AE
5 changed files with 48 additions and 2 deletions

View File

@ -0,0 +1,6 @@
FROM gcr.io/google-appengine/debian9:latest
ENV dir /tmp/dir/
ONBUILD RUN echo "onbuild" > /tmp/onbuild
ONBUILD RUN mkdir $dir
ONBUILD RUN echo "onbuild 2" > ${dir}/onbuild2
ONBUILD WORKDIR /new/workdir

View File

@ -0,0 +1,6 @@
FROM gcr.io/kaniko-test/onbuild-base:latest
COPY context/foo foo
ENV dir /new/workdir/
ONBUILD RUN echo "onbuild" > /tmp/onbuild
ONBUILD RUN echo "onbuild 2" > ${dir}
ONBUILD WORKDIR /new/workdir

View File

@ -0,0 +1,12 @@
[
{
"Image1": "gcr.io/kaniko-test/docker-test-onbuild:latest",
"Image2": "gcr.io/kaniko-test/kaniko-test-onbuild:latest",
"DiffType": "File",
"Diff": {
"Adds": null,
"Dels": null,
"Mods": null
}
}
]

View File

@ -34,6 +34,7 @@ const (
kanikoTestBucket = "kaniko-test-bucket"
buildcontextPath = "/workspace/integration_tests"
dockerfilesPath = "/workspace/integration_tests/dockerfiles"
onbuildBaseImage = testRepo + "onbuild-base:latest"
)
var fileTests = []struct {
@ -102,6 +103,14 @@ var fileTests = []struct {
kanikoContext: buildcontextPath,
repo: "test-add",
},
{
description: "test onbuild",
dockerfilePath: "/workspace/integration_tests/dockerfiles/Dockerfile_test_onbuild",
configPath: "/workspace/integration_tests/dockerfiles/config_test_onbuild.json",
dockerContext: buildcontextPath,
kanikoContext: buildcontextPath,
repo: "test-onbuild",
},
}
var structureTests = []struct {
@ -182,8 +191,19 @@ func main() {
Name: dockerImage,
Args: []string{"build", "-t", executorImage, "-f", "deploy/Dockerfile", "."},
}
// Build and push onbuild base images
buildOnbuildImage := step{
Name: dockerImage,
Args: []string{"build", "-t", onbuildBaseImage, "-f", "/workspace/integration_tests/dockerfiles/Dockerfile_onbuild_base", "."},
}
pushOnbuildBase := step{
Name: dockerImage,
Args: []string{"push", onbuildBaseImage},
}
y := testyaml{
Steps: []step{containerDiffStep, containerDiffPermissions, structureTestsStep, structureTestPermissions, GCSBucketTarBuildContext, uploadTarBuildContext, buildExecutorImage},
Steps: []step{containerDiffStep, containerDiffPermissions, structureTestsStep, structureTestPermissions, GCSBucketTarBuildContext, uploadTarBuildContext, buildExecutorImage,
buildOnbuildImage, pushOnbuildBase},
}
for _, test := range fileTests {
// First, build the image with docker

View File

@ -27,8 +27,10 @@ type OnBuildCommand struct {
cmd *instructions.OnbuildCommand
}
//ExecuteCommand adds the specified expression in Onbuild to the config
func (o *OnBuildCommand) ExecuteCommand(config *manifest.Schema2Config) error {
logrus.Info("cmd: ONBUILD")
logrus.Infof("args: %s", o.cmd.Expression)
resolvedExpression, err := util.ResolveEnvironmentReplacement(o.cmd.Expression, config.Env, false)
if err != nil {
return err
@ -41,7 +43,7 @@ func (o *OnBuildCommand) ExecuteCommand(config *manifest.Schema2Config) error {
return nil
}
// No files have changed, this command only touches metadata.
// FilesToSnapshot returns that no files have changed, this command only touches metadata.
func (o *OnBuildCommand) FilesToSnapshot() []string {
return []string{}
}