forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for the following PR: containernetworking/plugins#832
- Loading branch information
1 parent
2b61865
commit a64c5bf
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package networking | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
|
||
nadtypes "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1" | ||
g "github.com/onsi/ginkgo/v2" | ||
o "github.com/onsi/gomega" | ||
|
||
exutil "github.com/openshift/origin/test/extended/util" | ||
kapiv1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
var _ = g.Describe("[sig-network][Feature:tap]", func() { | ||
oc := exutil.NewCLI("tap") | ||
f := oc.KubeFramework() | ||
|
||
g.It(fmt.Sprintf("should create a pod with a tap interface [apigroup:k8s.cni.cncf.io]"), func() { | ||
ns := f.Namespace.Name | ||
podName := "pod1" | ||
nadName := "nad-tap" | ||
ifName := "tap1" | ||
|
||
g.By("creating a network attachment definition") | ||
err := createNetworkAttachmentDefinition( | ||
oc.AdminConfig(), | ||
ns, | ||
nadName, | ||
fmt.Sprintf(`{"cniVersion":"0.4.0","name":"%s","type": "tap", | ||
"selinuxcontext": "system_u:system_r:container_t:s0", "ipam": {}}`, nadName), | ||
) | ||
o.Expect(err).NotTo(o.HaveOccurred(), "unable to create tap network-attachment-definition") | ||
|
||
g.By("creating pod and checking results") | ||
exutil.CreateExecPodOrFail(f.ClientSet, ns, podName, func(pod *kapiv1.Pod) { | ||
tapAnnotation := fmt.Sprintf("%s/%s@%s", ns, nadName, ifName) | ||
pod.ObjectMeta.Annotations = map[string]string{"k8s.v1.cni.cncf.io/networks": fmt.Sprintf("%s", tapAnnotation)} | ||
}) | ||
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(context.TODO(), podName, metav1.GetOptions{}) | ||
o.Expect(err).ToNot(o.HaveOccurred()) | ||
|
||
networkStatusString, ok := pod.Annotations["k8s.v1.cni.cncf.io/network-status"] | ||
o.Expect(ok).To(o.BeTrue()) | ||
o.Expect(networkStatusString).ToNot(o.BeNil()) | ||
|
||
var networkStatuses []nadtypes.NetworkStatus | ||
o.Expect(json.Unmarshal([]byte(networkStatusString), &networkStatuses)).ToNot(o.HaveOccurred()) | ||
o.Expect(networkStatuses).To(o.HaveLen(2)) | ||
o.Expect(networkStatuses[1].Interface).To(o.Equal(ifName)) | ||
o.Expect(networkStatuses[1].Name).To(o.Equal(fmt.Sprintf("%s/%s", ns, nadName))) | ||
}) | ||
}) |
2 changes: 2 additions & 0 deletions
2
test/extended/util/annotate/generated/zz_generated.annotations.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.