Last active
October 31, 2018 15:32
-
-
Save robertgzr/34b97ba5f5994ea346bdba159151c7f7 to your computer and use it in GitHub Desktop.
delta tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package image | |
import ( | |
"context" | |
"encoding/json" | |
"errors" | |
"fmt" | |
"io/ioutil" | |
"testing" | |
"github.com/docker/docker/api/types" | |
"github.com/docker/docker/api/types/container" | |
"github.com/docker/docker/integration-cli/daemon" | |
"github.com/docker/go-connections/nat" | |
) | |
// TESTDIRS="integration/image" TESTFLAGS="-test.run Delta" make test-integration | |
func TestDelta(t *testing.T) { | |
type testCase struct { | |
desc string | |
src string | |
dest string | |
} | |
for _, c := range []testCase{ | |
{ | |
desc: "busybox images", | |
src: "busybox:1.24", | |
dest: "busybox:1.29", | |
}, | |
} { | |
t.Run(c.desc, func(t *testing.T) { | |
c := c | |
t.Parallel() | |
d := daemon.New(t, "", "balena-engine-daemon", daemon.Config{}) | |
client, err := d.NewClient() | |
if err != nil { | |
t.Fatal(err) | |
} | |
var args = []string{"--insecure-registry=127.0.0.1:5000"} | |
// d.Start(t) | |
d.Start(t, args...) | |
ctx := context.Background() | |
pullResp, err := client.ImagePull(ctx, | |
"registry:2", | |
types.ImagePullOptions{}) | |
if err != nil { | |
t.Fatal(err) | |
} | |
{ | |
out, err := ioutil.ReadAll(pullResp) | |
if err != nil { | |
t.Fatal(err) | |
} | |
t.Logf("got: %s", out) | |
} | |
// run a local registry | |
registryC, err := client.ContainerCreate(ctx, | |
&container.Config{Image: "registry:2"}, | |
&container.HostConfig{ | |
PortBindings: nat.PortMap(map[nat.Port][]nat.PortBinding{ | |
nat.Port("5000/tcp"): []nat.PortBinding{nat.PortBinding{ | |
HostIP: "127.0.0.1", | |
HostPort: "5000", | |
}}, | |
}), | |
}, nil, "") | |
if err != nil { | |
t.Fatal(err) | |
} | |
defer client.ContainerRemove(ctx, registryC.ID, types.ContainerRemoveOptions{Force: true}) | |
if err := client.ContainerStart(ctx, registryC.ID, types.ContainerStartOptions{}); err != nil { | |
t.Fatal(err) | |
} | |
t.Log("Pulling delta base") | |
// pull one version of busybox | |
if _, err := client.ImagePull(ctx, | |
c.src, | |
types.ImagePullOptions{}); err != nil { | |
t.Fatal(err) | |
} | |
t.Log("Pulling delta target") | |
// pull another version of busybox | |
if _, err := client.ImagePull(ctx, | |
c.dest, | |
types.ImagePullOptions{}); err != nil { | |
t.Fatal(err) | |
} | |
t.Log("Creating delta") | |
// create a delta | |
resp, err := client.ImageDelta(ctx, | |
"busybox:1.24", | |
"busybox:1.29") | |
if err != nil { | |
t.Fatal(err) | |
} | |
defer resp.Close() | |
var r map[string]interface{} | |
if err := json.NewDecoder(resp).Decode(&r); err != nil { | |
t.Fatal(err) | |
} | |
t.Logf("response:\n%v", r) | |
// push delta to local registry | |
// pushResp, err := client.ImagePush(ctx, <delta image name with registry uri>, types.ImagePushOptions{}) | |
// if err != nil { | |
// t.Fatal(err) | |
// } | |
d.Stop(t) | |
args = append(args, []string{ | |
fmt.Sprintf("--delta-data-root=%s", d.Root), | |
"--delta-storage-driver=overlay2", | |
}...) | |
var newRootDir = fmt.Sprintf("%s/old-root", d.Folder) | |
d.Root = newRootDir | |
d.Start(t, args...) | |
defer d.Stop(t) | |
infoResp, err := client.Info(ctx) | |
if err != nil { | |
t.Fatal(err) | |
} | |
if infoResp.DockerRootDir != newRootDir { | |
t.Fatal(errors.New("Root dir didn't change")) | |
} | |
}) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Running /go/src/github.com/docker/docker/integration/image | |
INFO: Testing against a local daemon | |
=== RUN TestDelta | |
=== RUN TestDelta/busybox_images | |
=== PAUSE TestDelta/busybox_images | |
=== CONT TestDelta/busybox_images | |
--- FAIL: TestDelta (0.00s) | |
--- FAIL: TestDelta/busybox_images (18.04s) | |
daemon.go:285: [ddabfda1d8f2d] waiting for daemon to start | |
daemon.go:317: [ddabfda1d8f2d] daemon started | |
delta_test.go:60: got: {"status":"Pulling from library/registry","id":"2"} | |
{"status":"Pulling fs layer","progressDetail":{},"id":"d6a5679aa3cf"} | |
{"status":"Pulling fs layer","progressDetail":{},"id":"ad0eac849f8f"} | |
{"status":"Pulling fs layer","progressDetail":{},"id":"2261ba058a15"} | |
{"status":"Pulling fs layer","progressDetail":{},"id":"f296fda86f10"} | |
{"status":"Pulling fs layer","progressDetail":{},"id":"bcd4a541795b"} | |
{"status":"Waiting","progressDetail":{},"id":"f296fda86f10"} | |
{"status":"Waiting","progressDetail":{},"id":"bcd4a541795b"} | |
{"status":"Ready to download","progressDetail":{},"id":"d6a5679aa3cf"} | |
{"status":"Ready to download","progressDetail":{},"id":"ad0eac849f8f"} | |
{"status":"Ready to download","progressDetail":{},"id":"bcd4a541795b"} | |
{"status":"Ready to download","progressDetail":{},"id":"2261ba058a15"} | |
{"status":"Ready to download","progressDetail":{},"id":"f296fda86f10"} | |
{"status":"Extracting","progressDetail":{"current":25139,"total":2387846},"progress":"[\u003e ] 25.14kB/2.388MB","id":"d6a5679aa3cf"} | |
{"status":"Extracting","progressDetail":{"current":76955,"total":2387846},"progress":"[=\u003e ] 76.95kB/2.388MB","id":"d6a5679aa3cf"} | |
{"progressDetail":{"current":109590,"total":10688384},"progress":"[\u003e ] 109.6kB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":523020,"total":2387846},"progress":"[==========\u003e ] 523kB/2.388MB","id":"d6a5679aa3cf"} | |
{"status":"Extracting","progressDetail":{"current":555788,"total":2387846},"progress":"[===========\u003e ] 555.8kB/2.388MB","id":"d6a5679aa3cf"} | |
{"progressDetail":{"current":572172,"total":10688384},"progress":"[==\u003e ] 572.2kB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":965388,"total":2387846},"progress":"[====================\u003e ] 965.4kB/2.388MB","id":"d6a5679aa3cf"} | |
{"progressDetail":{"current":1043212,"total":10688384},"progress":"[====\u003e ] 1.043MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":1964812,"total":2387846},"progress":"[=========================================\u003e ] 1.965MB/2.388MB","id":"d6a5679aa3cf"} | |
{"progressDetail":{"current":2177804,"total":10688384},"progress":"[==========\u003e ] 2.178MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":2259724,"total":2387846},"progress":"[===============================================\u003e ] 2.26MB/2.388MB","id":"d6a5679aa3cf"} | |
{"progressDetail":{"current":2288396,"total":10688384},"progress":"[==========\u003e ] 2.288MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":2325260,"total":2387846},"progress":"[================================================\u003e ] 2.325MB/2.388MB","id":"d6a5679aa3cf"} | |
{"status":"Extracting","progressDetail":{"current":2358028,"total":2387846},"progress":"[=================================================\u003e ] 2.358MB/2.388MB","id":"d6a5679aa3cf"} | |
{"status":"Extracting","progressDetail":{"current":2387846,"total":2387846},"progress":"[==================================================\u003e] 2.388MB/2.388MB","id":"d6a5679aa3cf"} | |
{"status":"Extracting","progressDetail":{"current":2387846,"total":2387846},"progress":"[==================================================\u003e] 2.388MB/2.388MB","id":"d6a5679aa3cf"} | |
{"status":"Pull complete","progressDetail":{},"id":"d6a5679aa3cf"} | |
{"progressDetail":{"current":2396557,"total":10688384},"progress":"[===========\u003e ] 2.397MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":21032,"total":2034577},"progress":"[\u003e ] 21.03kB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":63228,"total":2034577},"progress":"[=\u003e ] 63.23kB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":2506024,"total":10688384},"progress":"[===========\u003e ] 2.506MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":134030,"total":2034577},"progress":"[===\u003e ] 134kB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":155175,"total":2034577},"progress":"[===\u003e ] 155.2kB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":179485,"total":2034577},"progress":"[====\u003e ] 179.5kB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":2615951,"total":10688384},"progress":"[============\u003e ] 2.616MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":322313,"total":2034577},"progress":"[=======\u003e ] 322.3kB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":2726543,"total":10688384},"progress":"[============\u003e ] 2.727MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":355081,"total":2034577},"progress":"[========\u003e ] 355.1kB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":3074703,"total":10688384},"progress":"[==============\u003e ] 3.075MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":883465,"total":2034577},"progress":"[=====================\u003e ] 883.5kB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":3648143,"total":10688384},"progress":"[=================\u003e ] 3.648MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":1293065,"total":2034577},"progress":"[===============================\u003e ] 1.293MB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":1555209,"total":2034577},"progress":"[======================================\u003e ] 1.555MB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":3992207,"total":10688384},"progress":"[==================\u003e ] 3.992MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":1620745,"total":2034577},"progress":"[=======================================\u003e ] 1.621MB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":1686281,"total":2034577},"progress":"[=========================================\u003e ] 1.686MB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":4106895,"total":10688384},"progress":"[===================\u003e ] 4.107MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":1719049,"total":2034577},"progress":"[==========================================\u003e ] 1.719MB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":1751817,"total":2034577},"progress":"[===========================================\u003e ] 1.752MB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":1784585,"total":2034577},"progress":"[===========================================\u003e ] 1.785MB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":1817353,"total":2034577},"progress":"[============================================\u003e ] 1.817MB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":4221583,"total":10688384},"progress":"[===================\u003e ] 4.222MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":1850121,"total":2034577},"progress":"[=============================================\u003e ] 1.85MB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":1882889,"total":2034577},"progress":"[==============================================\u003e ] 1.883MB/2.035MB","id":"ad0eac849f8f"} | |
{"progressDetail":{"current":4336271,"total":10688384},"progress":"[====================\u003e ] 4.336MB/10.69MB","id":"Total"} | |
{"status":"Extracting","progressDetail":{"current":1981193,"total":2034577},"progress":"[================================================\u003e ] 1.981MB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":2034577,"total":2034577},"progress":"[==================================================\u003e] 2.035MB/2.035MB","id":"ad0eac849f8f"} | |
{"status":"Extracting","progressDetail":{"current":2034577,"total":2034577},"progress":"[==================================================\u003e] 2.035MB/2.035MB","id":"ad0eac849f8f"} | |
{"errorDetail":{"message":"failed to register layer: Error processing tar file(exit status 1): link /usr/share/terminfo/L/LFT-PC850 /usr/share/terminfo/l/lft-pc850: no such file or directory"},"error":"failed to register layer: Error processing tar file(exit status 1): link /usr/share/terminfo/L/LFT-PC850 /usr/share/terminfo/l/lft-pc850: no such file or directory"} | |
delta_test.go:74: Error: No such image: registry:2 | |
FAIL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment