Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
Signed-off-by: terasihma <[email protected]>
  • Loading branch information
terassyi committed Dec 18, 2023
1 parent a59eabb commit d83be2a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
18 changes: 18 additions & 0 deletions v2/e2e/coil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ var _ = Describe("Coil", func() {
Expect(resp).To(HaveLen(1 << 20))
}

By("creating a dummy pod don't use egress")
// dummy_pod must be created after creating a net-client pod
kubectlSafe(nil, "apply", "-f", "manifests/dummy_pod.yaml")

By("updating Egress in the internet namespace")
kubectlSafe(nil, "apply", "-f", "manifests/egress-updated.yaml")

Expand Down Expand Up @@ -446,6 +450,20 @@ var _ = Describe("Coil", func() {
return nil
}).Should(Succeed())

By("confirming that the fou device must be one in dummy_pod")
out, err := kubectl(nil, "exec", "dummy", "--", "ip", "-j", "link", "show")
Expect(err).NotTo(HaveOccurred())
var dummyPodLinks []link
err = json.Unmarshal(out, &dummyPodLinks)
Expect(err).NotTo(HaveOccurred())
fouCount := 0
for _, l := range dummyPodLinks {
if strings.HasPrefix(l.Ifname, "fou") && l.Ifname != "fou-dummy" {
fouCount += 1
}
}
Expect(fouCount).To(Equal(1))

By("sending and receiving HTTP request from nat-client")
data = make([]byte, 1<<20) // 1 MiB
resp = kubectlSafe(data, "exec", "-i", "nat-client", "--", "curl", "-sf", "-T", "-", fakeURL)
Expand Down
18 changes: 18 additions & 0 deletions v2/e2e/manifests/dummy_pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Pod
metadata:
name: dummy
namespace: default
annotations:
egress.coil.cybozu.com/internet: egress-sport-auto
spec:
tolerations:
- key: test
operator: Exists
nodeSelector:
test: coil
kubernetes.io/hostname: coil-worker
containers:
- name: ubuntu
image: quay.io/cybozu/ubuntu-debug:22.04
command: ["pause"]
1 change: 1 addition & 0 deletions v2/e2e/manifests/nat-client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
operator: Exists
nodeSelector:
test: coil
kubernetes.io/hostname: coil-worker
containers:
- name: ubuntu
image: quay.io/cybozu/ubuntu-debug:22.04
Expand Down
5 changes: 4 additions & 1 deletion v2/pkg/nodenet/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ func TestPodNetwork(t *testing.T) {
t.Error("config for pod3 not found")
}

// confirm to select the expected pod
// This test is for https://github.com/cybozu-go/coil/pull/265.
// Confirm to select the expected pod.
// In this test, the address in podConf is equal to the address in the hook function.
// The hook function is executed inside the pod's network namespace.
type addrInfo struct {
Family string `json:"family"`
Local string `json:"local"`
Expand Down

0 comments on commit d83be2a

Please sign in to comment.