Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #719 from eunomie/relocation-push
Browse files Browse the repository at this point in the history
Push local docker images and use relocation map
  • Loading branch information
rumpl committed Nov 8, 2019
2 parents bff05c3 + 0f5dd8a commit 44932b6
Show file tree
Hide file tree
Showing 209 changed files with 4,632 additions and 17,805 deletions.
48 changes: 13 additions & 35 deletions Gopkg.lock

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

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ required = ["github.com/wadey/gocovmerge"]

[[override]]
name = "github.com/docker/cnab-to-oci"
version = "v0.1.0-beta2"
version = "v0.3.0-beta1"

[[override]]
name = "github.com/containerd/containerd"
branch = "master"
version = "v1.3.0"

[[override]]
name = "github.com/docker/cli"
revision = "d83cd90464377d4164c8f70248d064b979e5ca98"

[[override]]
name = "github.com/deislabs/cnab-go"
version = "v0.3.2-beta1"
version = "v0.7.1-beta1"

[[constraint]]
name = "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -82,7 +82,7 @@ required = ["github.com/wadey/gocovmerge"]

[[override]]
name = "github.com/docker/distribution"
revision = "0d3efadf0154c2b8a4e7b6621fff9809655cc580"
revision = "0d3efadf0154c2b8a4e7b6621fff9809655cc580" # version needed by containerd v1.3.0

[[override]]
name = "github.com/docker/swarmkit"
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ coverage-test-e2e: coverage-bin
@echo "Running e2e tests (coverage)..."
@$(call mkdir,_build/cov)
@$(call mkdir,$(TEST_RESULTS_DIR))
DOCKERAPP_BINARY=../e2e/coverage-bin $(call GO_TESTSUM,e2e-coverage.xml) -v ./e2e
DOCKERAPP_BINARY=../e2e/coverage-bin $(call GO_TESTSUM,e2e-coverage.xml) -v ./e2e $(INCLUDE_E2E)

coverage: coverage-test-unit coverage-test-e2e ## run tests with coverage
@echo "Fixing coverage files..."
find _build/cov/ -type f -name "*.out" -print0 | xargs -0 sed -i '/^coverage/d'
grep coverage _build/cov/*.out || true
go install ./vendor/github.com/wadey/gocovmerge/
gocovmerge _build/cov/*.out > _build/cov/all.out
go tool cover -func _build/cov/all.out
Expand Down Expand Up @@ -131,7 +134,7 @@ schemas: specification/bindata.go ## generate specification/bindata.go from json
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

.PHONY: cross e2e-cross test check lint test-unit test-e2e coverage coverage-bin coverage-test-unit coverage-test-e2e clean vendor schemas help
.PHONY: cross e2e-cross test check lint test-unit test-e2e coverage coverage-bin coverage-test-unit coverage-test-e2e clean vendor schemas help fix-coverage
.DEFAULT: all


Expand Down
15 changes: 7 additions & 8 deletions e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"strings"
"testing"

"github.com/docker/app/internal/relocated"

"gotest.tools/fs"

"github.com/docker/app/internal/store"
Expand All @@ -30,11 +32,8 @@ func TestBuild(t *testing.T) {

cfg := getDockerConfigDir(t, cmd)

f := path.Join(cfg, "app", "bundles", "docker.io", "library", "single", "_tags", "1.0.0", "bundle.json")
data, err := ioutil.ReadFile(f)
assert.NilError(t, err)
var bndl bundle.Bundle
err = json.Unmarshal(data, &bndl)
f := path.Join(cfg, "app", "bundles", "docker.io", "library", "single", "_tags", "1.0.0", relocated.BundleFilename)
bndl, err := relocated.BundleFromFile(f)
assert.NilError(t, err)

built := []string{bndl.InvocationImages[0].Digest, bndl.Images["web"].Digest, bndl.Images["worker"].Digest}
Expand All @@ -53,7 +52,7 @@ func TestBuild(t *testing.T) {
bytes, err := ioutil.ReadFile(iidfile)
assert.NilError(t, err)
iid := string(bytes)
actualID, err := store.FromBundle(&bndl)
actualID, err := store.FromBundle(bndl)
assert.NilError(t, err)
assert.Equal(t, iid, fmt.Sprintf("sha256:%s", actualID.String()))
})
Expand Down Expand Up @@ -96,7 +95,7 @@ func TestBuildWithoutTag(t *testing.T) {
assert.Equal(t, len(infos), 1)
id := infos[0].Name()

f = path.Join(cfg, "app", "bundles", "_ids", id, "bundle.json")
f = path.Join(cfg, "app", "bundles", "_ids", id, relocated.BundleFilename)
data, err := ioutil.ReadFile(f)
assert.NilError(t, err)
var bndl bundle.Bundle
Expand Down Expand Up @@ -127,7 +126,7 @@ func TestBuildWithArgs(t *testing.T) {
assert.Equal(t, len(infos), 1)
id := infos[0].Name()

f = path.Join(cfg, "app", "bundles", "_ids", id, "bundle.json")
f = path.Join(cfg, "app", "bundles", "_ids", id, relocated.BundleFilename)
data, err := ioutil.ReadFile(f)
assert.NilError(t, err)
var bndl bundle.Bundle
Expand Down
11 changes: 5 additions & 6 deletions e2e/cnab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"path"
"testing"

"github.com/docker/app/internal/relocated"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
"gotest.tools/icmd"
Expand Down Expand Up @@ -50,7 +51,7 @@ func TestCallCustomStatusAction(t *testing.T) {
icmd.RunCmd(cmd).Assert(t, icmd.Success)

// docker app install
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", path.Join(testDir, "bundle.json"), "--name", testCase.name)
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", path.Join(testDir, relocated.BundleFilename), "--name", testCase.name)
icmd.RunCmd(cmd).Assert(t, icmd.Success)

// docker app uninstall
Expand Down Expand Up @@ -78,15 +79,13 @@ func TestCnabParameters(t *testing.T) {
}()

// docker app install
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", path.Join(testDir, "bundle.json"), "--name", "cnab-parameters",
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", path.Join(testDir, relocated.BundleFilename), "--name", "cnab-parameters",
"--set", "boolParam=true",
"--set", "stringParam=value",
"--set", "intParam=42",
"--set", "floatParam=3.14")
"--set", "intParam=42")
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
expectedOutput := `boolParam=true
stringParam=value
intParam=42
floatParam=3.14`
intParam=42`
assert.Assert(t, is.Contains(result.Combined(), expectedOutput))
}
7 changes: 4 additions & 3 deletions e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/deislabs/cnab-go/credentials"
"github.com/docker/app/internal"
"github.com/docker/app/internal/relocated"
"github.com/docker/app/internal/yaml"
"gotest.tools/assert"
is "gotest.tools/assert/cmp"
Expand Down Expand Up @@ -205,7 +206,7 @@ func TestRunOnlyOne(t *testing.T) {
Err: `"docker app run" requires exactly 1 argument.`,
})

cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", "bundle.json", "myapp")
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", relocated.BundleFilename, "myapp")
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
ExitCode: 1,
Err: `"docker app run" cannot run a bundle and an App image`,
Expand Down Expand Up @@ -348,14 +349,14 @@ func TestCredentials(t *testing.T) {
assert.NilError(t, err)
bundleJSON := golden.Get(t, "credential-install-bundle.json")
tmpDir := fs.NewDir(t, t.Name(),
fs.WithFile("bundle.json", "", fs.WithBytes(bundleJSON)),
fs.WithFile(relocated.BundleFilename, "", fs.WithBytes(bundleJSON)),
fs.WithDir("local",
fs.WithFile("test-creds.yaml", "", fs.WithBytes(buf)),
),
)
defer tmpDir.Remove()

bundle := tmpDir.Join("bundle.json")
bundle := tmpDir.Join(relocated.BundleFilename)

t.Run("missing", func(t *testing.T) {
cmd.Command = dockerCli.Command(
Expand Down
2 changes: 1 addition & 1 deletion e2e/coverage-bin
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $BUILD_DIR/docker-app.cov \
-test.coverprofile=$BUILD_DIR/cov/$(uuidgen).out \
"$@" \
| grep -vE '^PASS$' \
| grep -vE '^coverage: [0-9]+\.[0-9]+% of statements in .+$' \
| grep -vE '^coverage:.*$' \
| grep -v '^=== RUN TestRunMain$'

exit ${PIPESTATUS[0]}
13 changes: 13 additions & 0 deletions e2e/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ func readFile(t *testing.T, path string) string {
return strings.Replace(string(content), "\r", "", -1)
}

type dindSwarmAndRegistryInfo struct {
swarmAddress string
registryAddress string
configuredCmd icmd.Cmd
stopRegistry func()
registryLogs func() string
}

func runWithDindSwarmAndRegistry(t *testing.T, todo func(dindSwarmAndRegistryInfo)) {
cmd, cleanup := dockerCli.createTestCmd()
defer cleanup()
Expand Down Expand Up @@ -83,6 +91,11 @@ func runWithDindSwarmAndRegistry(t *testing.T, todo func(dindSwarmAndRegistryInf
todo(info)
}

func build(t *testing.T, cmd icmd.Cmd, dockerCli dockerCliCommand, ref, path string) {
cmd.Command = dockerCli.Command("app", "build", "-t", ref, path)
icmd.RunCmd(cmd).Assert(t, icmd.Success)
}

// Container represents a docker container
type Container struct {
image string
Expand Down
Loading

0 comments on commit 44932b6

Please sign in to comment.