@@ -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.
3533func 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