Skip to content

Commit b943664

Browse files
authored
Merge pull request containerd#3435 from apostasie/bug-3425-missing-layer
Ensure all layers are here when tagging, committing, saving, or converting
2 parents 83bb11b + 764a2aa commit b943664

File tree

13 files changed

+630
-150
lines changed

13 files changed

+630
-150
lines changed

cmd/nerdctl/container/container_commit_linux_test.go

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import (
2020
"strings"
2121
"testing"
2222

23-
"gotest.tools/v3/icmd"
24-
2523
"github.com/containerd/nerdctl/v2/pkg/testutil"
2624
)
2725

@@ -35,12 +33,11 @@ It will regularly succeed or fail, making random PR fail the Kube check.
3533
func TestKubeCommitPush(t *testing.T) {
3634
t.Parallel()
3735

38-
t.Skip("Test that confirm that #827 is still broken is too flaky")
39-
4036
base := testutil.NewBaseForKubernetes(t)
4137
tID := testutil.Identifier(t)
4238

4339
var containerID string
40+
// var registryIP string
4441

4542
setup := func() {
4643
testutil.KubectlHelper(base, "run", "--image", testutil.CommonImage, tID, "--", "sleep", "Inf").
@@ -55,26 +52,45 @@ func TestKubeCommitPush(t *testing.T) {
5552
cmd := testutil.KubectlHelper(base, "get", "pods", tID, "-o", "jsonpath={ .status.containerStatuses[0].containerID }")
5653
cmd.Run()
5754
containerID = strings.TrimPrefix(cmd.Out(), "containerd://")
55+
56+
// This below is missing configuration to allow for plain http communication
57+
// This is left here for future work to successfully start a registry usable in the cluster
58+
/*
59+
// Start a registry
60+
testutil.KubectlHelper(base, "run", "--port", "5000", "--image", testutil.RegistryImageStable, "testregistry").
61+
AssertOK()
62+
63+
testutil.KubectlHelper(base, "wait", "pod", "testregistry", "--for=condition=ready", "--timeout=1m").
64+
AssertOK()
65+
66+
cmd = testutil.KubectlHelper(base, "get", "pods", tID, "-o", "jsonpath={ .status.hostIPs[0].ip }")
67+
cmd.Run()
68+
registryIP = cmd.Out()
69+
70+
cmd = testutil.KubectlHelper(base, "apply", "-f", "-", fmt.Sprintf(`apiVersion: v1
71+
kind: ConfigMap
72+
metadata:
73+
name: local-registry
74+
namespace: nerdctl-test
75+
data:
76+
localRegistryHosting.v1: |
77+
host: "%s:5000"
78+
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
79+
`, registryIP))
80+
*/
81+
5882
}
5983

6084
tearDown := func() {
61-
testutil.KubectlHelper(base, "delete", "pod", "-f", tID).Run()
85+
testutil.KubectlHelper(base, "delete", "pod", "--all").Run()
6286
}
6387

6488
tearDown()
6589
t.Cleanup(tearDown)
6690
setup()
6791

6892
t.Run("test commit / push on Kube (https://github.com/containerd/nerdctl/issues/827)", func(t *testing.T) {
69-
t.Log("This test is meant to verify that we can commit / push an image from a pod." +
70-
"Currently, this is broken, hence the test assumes it will fail. Once the problem is fixed, we should just" +
71-
"change the expectation to 'success'.")
72-
73-
base.Cmd("commit", containerID, "registry.example.com/my-app:v1").AssertOK()
74-
// See note above.
75-
base.Cmd("push", "registry.example.com/my-app:v1").Assert(icmd.Expected{
76-
ExitCode: 1,
77-
Err: "failed to create a tmp single-platform image",
78-
})
93+
base.Cmd("commit", containerID, "testcommitsave").AssertOK()
94+
base.Cmd("save", "testcommitsave").AssertOK()
7995
})
8096
}

0 commit comments

Comments
 (0)