Skip to content

Commit

Permalink
Make windows-specific acceptance_test case
Browse files Browse the repository at this point in the history
- Bump imgutil to feature/23-windows-linux-images branch
- Make separate stacks for linux/windows

Signed-off-by: Micah Young <ymicah@vmware.com>
  • Loading branch information
Micah Young authored and Javier Romero and Andrew Meyer committed May 5, 2020
1 parent 7385b3a commit c6fdc35
Show file tree
Hide file tree
Showing 21 changed files with 292 additions and 91 deletions.
56 changes: 40 additions & 16 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,20 @@ func testAcceptance(
runImageMirror = value
})

when("creating a windows builder", func() {
windowsDaemon := true
it("succeeds", func() {
img := createBuilder(t,
runImageMirror,
configDir,
packCreateBuilderPath,
lifecyclePath,
lifecycleDescriptor,
windowsDaemon)
h.DockerRmi(dockerCli, img)
})
})

when("builder is created", func() {
var (
builderName string
Expand All @@ -566,7 +580,7 @@ func testAcceptance(

key := taskKey("create-builder", runImageMirror, configDir, packCreateBuilderPath, lifecyclePath)
value, err := suiteManager.RunTaskOnceString(key, func() (string, error) {
return createBuilder(t, runImageMirror, configDir, packCreateBuilderPath, lifecyclePath, lifecycleDescriptor), nil
return createBuilder(t, runImageMirror, configDir, packCreateBuilderPath, lifecyclePath, lifecycleDescriptor, false), nil
})
h.AssertNil(t, err)
suiteManager.RegisterCleanUp("clean-"+key, func() error {
Expand Down Expand Up @@ -1645,7 +1659,7 @@ func buildPack(t *testing.T, compileVersion string) string {
return packPath
}

func createBuilder(t *testing.T, runImageMirror, configDir, packPath, lifecyclePath string, lifecycleDescriptor builder.LifecycleDescriptor) string {
func createBuilder(t *testing.T, runImageMirror, configDir, packPath, lifecyclePath string, lifecycleDescriptor builder.LifecycleDescriptor, windowsDaemon bool) string {
t.Log("creating builder image...")

// CREATE TEMP WORKING DIR
Expand All @@ -1672,15 +1686,19 @@ func createBuilder(t *testing.T, runImageMirror, configDir, packPath, lifecycleP
h.AssertNil(t, err)
}

// CREATE PACKAGE
packageImageName := packageBuildpackAsImage(t,
packPath,
filepath.Join(configDir, "package.toml"),
lifecycleDescriptor,
[]string{"simple-layers-buildpack"},
)
var packageImageName string
var packageId string
if !windowsDaemon {
// CREATE PACKAGE
packageImageName = packageBuildpackAsImage(t,
packPath,
filepath.Join(configDir, "package.toml"),
lifecycleDescriptor,
[]string{"simple-layers-buildpack"},
)

packageId := "simple/layers"
packageId = "simple/layers"
}

// ADD lifecycle
var lifecycleURI string
Expand All @@ -1696,10 +1714,10 @@ func createBuilder(t *testing.T, runImageMirror, configDir, packPath, lifecycleP
// RENDER builder.toml
cfgData := fillTemplate(t, filepath.Join(configDir, "builder.toml"), map[string]interface{}{
"package_image_name": packageImageName,
"package_id": packageId,
"run_image_mirror": runImageMirror,
"lifecycle_uri": lifecycleURI,
"lifecycle_version": lifecycleVersion,
"package_id": packageId,
"run_image_mirror": runImageMirror,
"lifecycle_uri": lifecycleURI,
"lifecycle_version": lifecycleVersion,
})

err = ioutil.WriteFile(filepath.Join(tmpDir, "builder.toml"), []byte(cfgData), os.ModePerm)
Expand Down Expand Up @@ -1788,10 +1806,16 @@ func createStack(t *testing.T, dockerCli client.CommonAPIClient, runImageMirror
t.Helper()
t.Log("creating stack images...")

if err := createStackImage(dockerCli, runImage, filepath.Join("testdata", "mock_stack", "run")); err != nil {
daemonInfo, err := dockerCli.Info(context.TODO())
h.AssertNil(t, err)

os := daemonInfo.OSType
stackBaseDir := filepath.Join("testdata", "mock_stack", os)

if err := createStackImage(dockerCli, runImage, filepath.Join(stackBaseDir, "run")); err != nil {
return err
}
if err := createStackImage(dockerCli, buildImage, filepath.Join("testdata", "mock_stack", "build")); err != nil {
if err := createStackImage(dockerCli, buildImage, filepath.Join(stackBaseDir, "build")); err != nil {
return err
}

Expand Down
5 changes: 3 additions & 2 deletions acceptance/testdata/mock_stack/create-stack.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

dir="$(cd $(dirname $0) && pwd)"
os=$(docker info --format '{{json .}}' | jq -r .OSType)

docker build --tag pack-test/build "$dir"/build
docker build --tag pack-test/run "$dir"/run
docker build --tag pack-test/build "$dir"/$os/build
docker build --tag pack-test/run "$dir"/$os/run
14 changes: 14 additions & 0 deletions acceptance/testdata/mock_stack/windows/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/windows/nanoserver:1809

# placeholder values until correct values are deteremined
ENV CNB_USER_ID=0
ENV CNB_GROUP_ID=0

USER ContainerAdministrator

RUN net users /ADD pack /passwordreq:no /expires:never

LABEL io.buildpacks.stack.id=pack.test.stack
LABEL io.buildpacks.stack.mixins="[\"mixinA\", \"build:mixinTwo\", \"netcat\", \"mixin3\"]"

USER pack
14 changes: 14 additions & 0 deletions acceptance/testdata/mock_stack/windows/run/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM mcr.microsoft.com/windows/nanoserver:1809

# placeholder values until correct values are deteremined
ENV CNB_USER_ID=0
ENV CNB_GROUP_ID=0

USER ContainerAdministrator

RUN net users /ADD pack /passwordreq:no /expires:never

LABEL io.buildpacks.stack.id=pack.test.stack
LABEL io.buildpacks.stack.mixins="[\"mixinA\", \"netcat\", \"mixin3\"]"

USER pack
2 changes: 1 addition & 1 deletion acceptance/testdata/pack_fixtures/builder.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
{{- end}}
{{- if .lifecycle_version}}
version = "{{.lifecycle_version}}"
{{- end}}
{{- end}}
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/Microsoft/hcsshim v0.8.7 // indirect
github.com/apex/log v1.1.2
github.com/buildpacks/imgutil v0.0.0-20200313170640-a02052f47d62
github.com/buildpacks/lifecycle v0.7.1
github.com/buildpacks/lifecycle v0.7.2
github.com/containerd/containerd v1.3.3 // indirect
github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41 // indirect
github.com/dgodd/dockerdial v1.0.1
Expand Down Expand Up @@ -48,3 +48,5 @@ require (
)

go 1.13

replace github.com/buildpacks/imgutil => ../imgutil
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/buildpacks/imgutil v0.0.0-20200313170640-a02052f47d62 h1:jo6zuwPgCWD/V5YQEgaRKeW/uxy4fhFO9FsFWmKCtdQ=
github.com/buildpacks/imgutil v0.0.0-20200313170640-a02052f47d62/go.mod h1:TjPmM78urjQIiMal4T7en6iBekAPv6z1yVMZobc4Kd8=
github.com/buildpacks/lifecycle v0.7.1 h1:cfVdxGJJqAoK55kkxTA5HxHPmUNp0NuGgDzRl5f7R/E=
github.com/buildpacks/lifecycle v0.7.1/go.mod h1:k41tT3XOt7ufaMGAvOpEsXyuJpUPoo4F686Z652lU3E=
github.com/buildpacks/lifecycle v0.7.2 h1:FO7i2cokLNc7lcuThq/LYt1jmkB8HBrjpK+2GWWsaLI=
github.com/buildpacks/lifecycle v0.7.2/go.mod h1:k41tT3XOt7ufaMGAvOpEsXyuJpUPoo4F686Z652lU3E=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
Expand Down
2 changes: 1 addition & 1 deletion testhelpers/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"golang.org/x/crypto/bcrypt"
)

var registryContainerName = "registry:2"
var registryContainerName = "micahyoung/registry:2"

type TestRegistryConfig struct {
runRegistryName string
Expand Down
18 changes: 0 additions & 18 deletions vendor/github.com/buildpacks/imgutil/.travis.yml

This file was deleted.

21 changes: 11 additions & 10 deletions vendor/github.com/buildpacks/imgutil/Makefile

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

4 changes: 2 additions & 2 deletions vendor/github.com/buildpacks/imgutil/README.md

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

8 changes: 8 additions & 0 deletions vendor/github.com/buildpacks/imgutil/fakes/image.go

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

6 changes: 3 additions & 3 deletions vendor/github.com/buildpacks/imgutil/go.mod

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

7 changes: 7 additions & 0 deletions vendor/github.com/buildpacks/imgutil/go.sum

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

31 changes: 31 additions & 0 deletions vendor/github.com/buildpacks/imgutil/golangci.yaml

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

2 changes: 2 additions & 0 deletions vendor/github.com/buildpacks/imgutil/image.go

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

Loading

0 comments on commit c6fdc35

Please sign in to comment.