mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
Improve checks for test/e2e/network and test/e2e/network/netpol (#106655)
This commit is contained in:
parent
1d44a54505
commit
93d858c46e
@ -64,7 +64,9 @@ var _ = common.SIGDescribe("[Feature:IPv6DualStack]", func() {
|
|||||||
|
|
||||||
framework.ExpectEqual(len(internalIPs), 2)
|
framework.ExpectEqual(len(internalIPs), 2)
|
||||||
// assert 2 ips belong to different families
|
// assert 2 ips belong to different families
|
||||||
framework.ExpectEqual(netutils.IsIPv4String(internalIPs[0]) != netutils.IsIPv4String(internalIPs[1]), true)
|
if netutils.IsIPv4String(internalIPs[0]) == netutils.IsIPv4String(internalIPs[1]) {
|
||||||
|
framework.Failf("both internalIPs %s and %s belong to the same families", internalIPs[0], internalIPs[1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -97,7 +99,9 @@ var _ = common.SIGDescribe("[Feature:IPv6DualStack]", func() {
|
|||||||
// validate first ip in PodIPs is same as PodIP
|
// validate first ip in PodIPs is same as PodIP
|
||||||
framework.ExpectEqual(p.Status.PodIP, p.Status.PodIPs[0].IP)
|
framework.ExpectEqual(p.Status.PodIP, p.Status.PodIPs[0].IP)
|
||||||
// assert 2 pod ips belong to different families
|
// assert 2 pod ips belong to different families
|
||||||
framework.ExpectEqual(netutils.IsIPv4String(p.Status.PodIPs[0].IP) != netutils.IsIPv4String(p.Status.PodIPs[1].IP), true)
|
if netutils.IsIPv4String(p.Status.PodIPs[0].IP) == netutils.IsIPv4String(p.Status.PodIPs[1].IP) {
|
||||||
|
framework.Failf("both internalIPs %s and %s belong to the same families", p.Status.PodIPs[0].IP, p.Status.PodIPs[1].IP)
|
||||||
|
}
|
||||||
|
|
||||||
ginkgo.By("deleting the pod")
|
ginkgo.By("deleting the pod")
|
||||||
err := podClient.Delete(context.TODO(), pod.Name, *metav1.NewDeleteOptions(30))
|
err := podClient.Delete(context.TODO(), pod.Name, *metav1.NewDeleteOptions(30))
|
||||||
|
@ -380,7 +380,9 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected discovery API group/version, got %#v", discoveryGroups.Groups))
|
if !found {
|
||||||
|
framework.Failf("expected discovery API group/version, got %#v", discoveryGroups.Groups)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("getting /apis/discovery.k8s.io")
|
ginkgo.By("getting /apis/discovery.k8s.io")
|
||||||
@ -395,7 +397,9 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected discovery API version, got %#v", group.Versions))
|
if !found {
|
||||||
|
framework.Failf("expected discovery API version, got %#v", group.Versions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("getting /apis/discovery.k8s.io" + epsVersion)
|
ginkgo.By("getting /apis/discovery.k8s.io" + epsVersion)
|
||||||
@ -409,7 +413,9 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
|
|||||||
foundEPS = true
|
foundEPS = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(foundEPS, true, fmt.Sprintf("expected endpointslices, got %#v", resources.APIResources))
|
if !foundEPS {
|
||||||
|
framework.Failf("expected endpointslices, got %#v", resources.APIResources)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EndpointSlice resource create/read/update/watch verbs
|
// EndpointSlice resource create/read/update/watch verbs
|
||||||
@ -471,10 +477,14 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
|
|||||||
for sawAnnotations := false; !sawAnnotations; {
|
for sawAnnotations := false; !sawAnnotations; {
|
||||||
select {
|
select {
|
||||||
case evt, ok := <-epsWatch.ResultChan():
|
case evt, ok := <-epsWatch.ResultChan():
|
||||||
framework.ExpectEqual(ok, true, "watch channel should not close")
|
if !ok {
|
||||||
|
framework.Fail("watch channel should not close")
|
||||||
|
}
|
||||||
framework.ExpectEqual(evt.Type, watch.Modified)
|
framework.ExpectEqual(evt.Type, watch.Modified)
|
||||||
watchedEPS, isEPS := evt.Object.(*discoveryv1.EndpointSlice)
|
watchedEPS, isEPS := evt.Object.(*discoveryv1.EndpointSlice)
|
||||||
framework.ExpectEqual(isEPS, true, fmt.Sprintf("expected EndpointSlice, got %T", evt.Object))
|
if !isEPS {
|
||||||
|
framework.Failf("expected EndpointSlice, got %T", evt.Object)
|
||||||
|
}
|
||||||
if watchedEPS.Annotations["patched"] == "true" {
|
if watchedEPS.Annotations["patched"] == "true" {
|
||||||
framework.Logf("saw patched and updated annotations")
|
framework.Logf("saw patched and updated annotations")
|
||||||
sawAnnotations = true
|
sawAnnotations = true
|
||||||
@ -492,7 +502,9 @@ var _ = common.SIGDescribe("EndpointSlice", func() {
|
|||||||
err = epsClient.Delete(context.TODO(), createdEPS.Name, metav1.DeleteOptions{})
|
err = epsClient.Delete(context.TODO(), createdEPS.Name, metav1.DeleteOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
_, err = epsClient.Get(context.TODO(), createdEPS.Name, metav1.GetOptions{})
|
_, err = epsClient.Get(context.TODO(), createdEPS.Name, metav1.GetOptions{})
|
||||||
framework.ExpectEqual(apierrors.IsNotFound(err), true, fmt.Sprintf("expected 404, got %v", err))
|
if !apierrors.IsNotFound(err) {
|
||||||
|
framework.Failf("expected 404, got %v", err)
|
||||||
|
}
|
||||||
epsList, err = epsClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
epsList, err = epsClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
framework.ExpectEqual(len(epsList.Items), 2, "filtered list should have 2 items")
|
framework.ExpectEqual(len(epsList.Items), 2, "filtered list should have 2 items")
|
||||||
|
@ -668,7 +668,9 @@ var _ = common.SIGDescribe("Ingress API", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected networking API group/version, got %#v", discoveryGroups.Groups))
|
if !found {
|
||||||
|
framework.Failf("expected networking API group/version, got %#v", discoveryGroups.Groups)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("getting /apis/networking.k8s.io")
|
ginkgo.By("getting /apis/networking.k8s.io")
|
||||||
@ -683,7 +685,9 @@ var _ = common.SIGDescribe("Ingress API", func() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected networking API version, got %#v", group.Versions))
|
if !found {
|
||||||
|
framework.Failf("expected networking API version, got %#v", group.Versions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("getting /apis/networking.k8s.io" + ingVersion)
|
ginkgo.By("getting /apis/networking.k8s.io" + ingVersion)
|
||||||
@ -697,7 +701,9 @@ var _ = common.SIGDescribe("Ingress API", func() {
|
|||||||
foundIngress = true
|
foundIngress = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(foundIngress, true, fmt.Sprintf("expected ingresses, got %#v", resources.APIResources))
|
if !foundIngress {
|
||||||
|
framework.Failf("expected ingresses, got %#v", resources.APIResources)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ingress resource create/read/update/watch verbs
|
// Ingress resource create/read/update/watch verbs
|
||||||
@ -759,10 +765,14 @@ var _ = common.SIGDescribe("Ingress API", func() {
|
|||||||
for sawAnnotations := false; !sawAnnotations; {
|
for sawAnnotations := false; !sawAnnotations; {
|
||||||
select {
|
select {
|
||||||
case evt, ok := <-ingWatch.ResultChan():
|
case evt, ok := <-ingWatch.ResultChan():
|
||||||
framework.ExpectEqual(ok, true, "watch channel should not close")
|
if !ok {
|
||||||
|
framework.Fail("watch channel should not close")
|
||||||
|
}
|
||||||
framework.ExpectEqual(evt.Type, watch.Modified)
|
framework.ExpectEqual(evt.Type, watch.Modified)
|
||||||
watchedIngress, isIngress := evt.Object.(*networkingv1.Ingress)
|
watchedIngress, isIngress := evt.Object.(*networkingv1.Ingress)
|
||||||
framework.ExpectEqual(isIngress, true, fmt.Sprintf("expected Ingress, got %T", evt.Object))
|
if !isIngress {
|
||||||
|
framework.Failf("expected Ingress, got %T", evt.Object)
|
||||||
|
}
|
||||||
if watchedIngress.Annotations["patched"] == "true" {
|
if watchedIngress.Annotations["patched"] == "true" {
|
||||||
framework.Logf("saw patched and updated annotations")
|
framework.Logf("saw patched and updated annotations")
|
||||||
sawAnnotations = true
|
sawAnnotations = true
|
||||||
@ -818,7 +828,9 @@ var _ = common.SIGDescribe("Ingress API", func() {
|
|||||||
|
|
||||||
expectFinalizer := func(ing *networkingv1.Ingress, msg string) {
|
expectFinalizer := func(ing *networkingv1.Ingress, msg string) {
|
||||||
framework.ExpectNotEqual(ing.DeletionTimestamp, nil, fmt.Sprintf("expected deletionTimestamp, got nil on step: %q, ingress: %+v", msg, ing))
|
framework.ExpectNotEqual(ing.DeletionTimestamp, nil, fmt.Sprintf("expected deletionTimestamp, got nil on step: %q, ingress: %+v", msg, ing))
|
||||||
framework.ExpectEqual(len(ing.Finalizers) > 0, true, fmt.Sprintf("expected finalizers on ingress, got none on step: %q, ingress: %+v", msg, ing))
|
if len(ing.Finalizers) == 0 {
|
||||||
|
framework.Failf("expected finalizers on ingress, got none on step: %q, ingress: %+v", msg, ing)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ingClient.Delete(context.TODO(), createdIngress.Name, metav1.DeleteOptions{})
|
err = ingClient.Delete(context.TODO(), createdIngress.Name, metav1.DeleteOptions{})
|
||||||
@ -828,12 +840,16 @@ var _ = common.SIGDescribe("Ingress API", func() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
expectFinalizer(ing, "deleting createdIngress")
|
expectFinalizer(ing, "deleting createdIngress")
|
||||||
} else {
|
} else {
|
||||||
framework.ExpectEqual(apierrors.IsNotFound(err), true, fmt.Sprintf("expected 404, got %v", err))
|
if !apierrors.IsNotFound(err) {
|
||||||
|
framework.Failf("expected 404, got %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ings, err = ingClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
ings, err = ingClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
// Should have <= 3 items since some ingresses might not have been deleted yet due to finalizers
|
// Should have <= 3 items since some ingresses might not have been deleted yet due to finalizers
|
||||||
framework.ExpectEqual(len(ings.Items) <= 3, true, "filtered list should have <= 3 items")
|
if len(ings.Items) > 3 {
|
||||||
|
framework.Fail("filtered list should have <= 3 items")
|
||||||
|
}
|
||||||
// Validate finalizer on the deleted ingress
|
// Validate finalizer on the deleted ingress
|
||||||
for _, ing := range ings.Items {
|
for _, ing := range ings.Items {
|
||||||
if ing.Namespace == createdIngress.Namespace && ing.Name == createdIngress.Name {
|
if ing.Namespace == createdIngress.Namespace && ing.Name == createdIngress.Name {
|
||||||
@ -847,7 +863,9 @@ var _ = common.SIGDescribe("Ingress API", func() {
|
|||||||
ings, err = ingClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
ings, err = ingClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
// Should have <= 3 items since some ingresses might not have been deleted yet due to finalizers
|
// Should have <= 3 items since some ingresses might not have been deleted yet due to finalizers
|
||||||
framework.ExpectEqual(len(ings.Items) <= 3, true, "filtered list should have <= 3 items")
|
if len(ings.Items) > 3 {
|
||||||
|
framework.Fail("filtered list should have <= 3 items")
|
||||||
|
}
|
||||||
// Validate finalizers
|
// Validate finalizers
|
||||||
for _, ing := range ings.Items {
|
for _, ing := range ings.Items {
|
||||||
expectFinalizer(&ing, "deleting ingress collection")
|
expectFinalizer(&ing, "deleting ingress collection")
|
||||||
|
@ -18,7 +18,6 @@ package network
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -217,7 +216,9 @@ var _ = common.SIGDescribe("IngressClass API", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected networking API group/version, got %#v", discoveryGroups.Groups))
|
if !found {
|
||||||
|
framework.Failf("expected networking API group/version, got %#v", discoveryGroups.Groups)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ginkgo.By("getting /apis/networking.k8s.io")
|
ginkgo.By("getting /apis/networking.k8s.io")
|
||||||
{
|
{
|
||||||
@ -231,7 +232,9 @@ var _ = common.SIGDescribe("IngressClass API", func() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected networking API version, got %#v", group.Versions))
|
if !found {
|
||||||
|
framework.Failf("expected networking API version, got %#v", group.Versions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("getting /apis/networking.k8s.io" + icVersion)
|
ginkgo.By("getting /apis/networking.k8s.io" + icVersion)
|
||||||
@ -245,7 +248,9 @@ var _ = common.SIGDescribe("IngressClass API", func() {
|
|||||||
foundIC = true
|
foundIC = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(foundIC, true, fmt.Sprintf("expected ingressclasses, got %#v", resources.APIResources))
|
if !foundIC {
|
||||||
|
framework.Failf("expected ingressclasses, got %#v", resources.APIResources)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IngressClass resource create/read/update/watch verbs
|
// IngressClass resource create/read/update/watch verbs
|
||||||
@ -289,10 +294,14 @@ var _ = common.SIGDescribe("IngressClass API", func() {
|
|||||||
for sawAnnotations := false; !sawAnnotations; {
|
for sawAnnotations := false; !sawAnnotations; {
|
||||||
select {
|
select {
|
||||||
case evt, ok := <-icWatch.ResultChan():
|
case evt, ok := <-icWatch.ResultChan():
|
||||||
framework.ExpectEqual(ok, true, "watch channel should not close")
|
if !ok {
|
||||||
|
framework.Fail("watch channel should not close")
|
||||||
|
}
|
||||||
framework.ExpectEqual(evt.Type, watch.Modified)
|
framework.ExpectEqual(evt.Type, watch.Modified)
|
||||||
watchedIngress, isIngress := evt.Object.(*networkingv1.IngressClass)
|
watchedIngress, isIngress := evt.Object.(*networkingv1.IngressClass)
|
||||||
framework.ExpectEqual(isIngress, true, fmt.Sprintf("expected Ingress, got %T", evt.Object))
|
if !isIngress {
|
||||||
|
framework.Failf("expected Ingress, got %T", evt.Object)
|
||||||
|
}
|
||||||
if watchedIngress.Annotations["patched"] == "true" {
|
if watchedIngress.Annotations["patched"] == "true" {
|
||||||
framework.Logf("saw patched and updated annotations")
|
framework.Logf("saw patched and updated annotations")
|
||||||
sawAnnotations = true
|
sawAnnotations = true
|
||||||
@ -310,7 +319,9 @@ var _ = common.SIGDescribe("IngressClass API", func() {
|
|||||||
err = icClient.Delete(context.TODO(), ingressClass1.Name, metav1.DeleteOptions{})
|
err = icClient.Delete(context.TODO(), ingressClass1.Name, metav1.DeleteOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
_, err = icClient.Get(context.TODO(), ingressClass1.Name, metav1.GetOptions{})
|
_, err = icClient.Get(context.TODO(), ingressClass1.Name, metav1.GetOptions{})
|
||||||
framework.ExpectEqual(apierrors.IsNotFound(err), true, fmt.Sprintf("expected 404, got %#v", err))
|
if !apierrors.IsNotFound(err) {
|
||||||
|
framework.Failf("expected 404, got %#v", err)
|
||||||
|
}
|
||||||
ics, err = icClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "ingressclass=" + f.UniqueName})
|
ics, err = icClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "ingressclass=" + f.UniqueName})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
framework.ExpectEqual(len(ics.Items), 2, "filtered list should have 2 items")
|
framework.ExpectEqual(len(ics.Items), 2, "filtered list should have 2 items")
|
||||||
|
@ -608,7 +608,9 @@ var _ = common.SIGDescribe("LoadBalancers", func() {
|
|||||||
lbIngress := &svc.Status.LoadBalancer.Ingress[0]
|
lbIngress := &svc.Status.LoadBalancer.Ingress[0]
|
||||||
svcPort := int(svc.Spec.Ports[0].Port)
|
svcPort := int(svc.Spec.Ports[0].Port)
|
||||||
// should have an internal IP.
|
// should have an internal IP.
|
||||||
framework.ExpectEqual(isInternalEndpoint(lbIngress), true)
|
if !isInternalEndpoint(lbIngress) {
|
||||||
|
framework.Failf("lbIngress %v doesn't have an internal IP", lbIngress)
|
||||||
|
}
|
||||||
|
|
||||||
// ILBs are not accessible from the test orchestrator, so it's necessary to use
|
// ILBs are not accessible from the test orchestrator, so it's necessary to use
|
||||||
// a pod to test the service.
|
// a pod to test the service.
|
||||||
|
@ -2246,7 +2246,9 @@ var _ = common.SIGDescribe("NetworkPolicy API", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected networking API group/version, got %#v", discoveryGroups.Groups))
|
if !found {
|
||||||
|
framework.Failf("expected networking API group/version, got %#v", discoveryGroups.Groups)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ginkgo.By("getting /apis/networking.k8s.io")
|
ginkgo.By("getting /apis/networking.k8s.io")
|
||||||
{
|
{
|
||||||
@ -2260,7 +2262,9 @@ var _ = common.SIGDescribe("NetworkPolicy API", func() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected networking API version, got %#v", group.Versions))
|
if !found {
|
||||||
|
framework.Failf("expected networking API version, got %#v", group.Versions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ginkgo.By("getting /apis/networking.k8s.io" + npVersion)
|
ginkgo.By("getting /apis/networking.k8s.io" + npVersion)
|
||||||
{
|
{
|
||||||
@ -2273,7 +2277,9 @@ var _ = common.SIGDescribe("NetworkPolicy API", func() {
|
|||||||
foundNetPol = true
|
foundNetPol = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(foundNetPol, true, fmt.Sprintf("expected networkpolicies, got %#v", resources.APIResources))
|
if !foundNetPol {
|
||||||
|
framework.Failf("expected networkpolicies, got %#v", resources.APIResources)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// NetPol resource create/read/update/watch verbs
|
// NetPol resource create/read/update/watch verbs
|
||||||
ginkgo.By("creating")
|
ginkgo.By("creating")
|
||||||
@ -2326,10 +2332,14 @@ var _ = common.SIGDescribe("NetworkPolicy API", func() {
|
|||||||
for sawAnnotations := false; !sawAnnotations; {
|
for sawAnnotations := false; !sawAnnotations; {
|
||||||
select {
|
select {
|
||||||
case evt, ok := <-npWatch.ResultChan():
|
case evt, ok := <-npWatch.ResultChan():
|
||||||
framework.ExpectEqual(ok, true, "watch channel should not close")
|
if !ok {
|
||||||
|
framework.Fail("watch channel should not close")
|
||||||
|
}
|
||||||
framework.ExpectEqual(evt.Type, watch.Modified)
|
framework.ExpectEqual(evt.Type, watch.Modified)
|
||||||
watchedNetPol, isNetPol := evt.Object.(*networkingv1.NetworkPolicy)
|
watchedNetPol, isNetPol := evt.Object.(*networkingv1.NetworkPolicy)
|
||||||
framework.ExpectEqual(isNetPol, true, fmt.Sprintf("expected NetworkPolicy, got %T", evt.Object))
|
if !isNetPol {
|
||||||
|
framework.Failf("expected NetworkPolicy, got %T", evt.Object)
|
||||||
|
}
|
||||||
if watchedNetPol.Annotations["patched"] == "true" && watchedNetPol.Annotations["updated"] == "true" {
|
if watchedNetPol.Annotations["patched"] == "true" && watchedNetPol.Annotations["updated"] == "true" {
|
||||||
framework.Logf("saw patched and updated annotations")
|
framework.Logf("saw patched and updated annotations")
|
||||||
sawAnnotations = true
|
sawAnnotations = true
|
||||||
@ -2346,7 +2356,9 @@ var _ = common.SIGDescribe("NetworkPolicy API", func() {
|
|||||||
err = npClient.Delete(context.TODO(), createdNetPol.Name, metav1.DeleteOptions{})
|
err = npClient.Delete(context.TODO(), createdNetPol.Name, metav1.DeleteOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
_, err = npClient.Get(context.TODO(), createdNetPol.Name, metav1.GetOptions{})
|
_, err = npClient.Get(context.TODO(), createdNetPol.Name, metav1.GetOptions{})
|
||||||
framework.ExpectEqual(apierrors.IsNotFound(err), true, fmt.Sprintf("expected 404, got %#v", err))
|
if !apierrors.IsNotFound(err) {
|
||||||
|
framework.Failf("expected 404, got %#v", err)
|
||||||
|
}
|
||||||
nps, err = npClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
nps, err = npClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
framework.ExpectEqual(len(nps.Items), 2, "filtered list should have 2 items")
|
framework.ExpectEqual(len(nps.Items), 2, "filtered list should have 2 items")
|
||||||
|
@ -18,7 +18,6 @@ package netpol
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
@ -85,7 +84,9 @@ var _ = common.SIGDescribe("Netpol API", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected networking API group/version, got %#v", discoveryGroups.Groups))
|
if !found {
|
||||||
|
framework.Failf("expected networking API group/version, got %#v", discoveryGroups.Groups)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ginkgo.By("getting /apis/networking.k8s.io")
|
ginkgo.By("getting /apis/networking.k8s.io")
|
||||||
{
|
{
|
||||||
@ -99,7 +100,9 @@ var _ = common.SIGDescribe("Netpol API", func() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(found, true, fmt.Sprintf("expected networking API version, got %#v", group.Versions))
|
if !found {
|
||||||
|
framework.Failf("expected networking API version, got %#v", group.Versions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ginkgo.By("getting /apis/networking.k8s.io" + npVersion)
|
ginkgo.By("getting /apis/networking.k8s.io" + npVersion)
|
||||||
{
|
{
|
||||||
@ -112,7 +115,9 @@ var _ = common.SIGDescribe("Netpol API", func() {
|
|||||||
foundNetPol = true
|
foundNetPol = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(foundNetPol, true, fmt.Sprintf("expected networkpolicies, got %#v", resources.APIResources))
|
if !foundNetPol {
|
||||||
|
framework.Failf("expected networkpolicies, got %#v", resources.APIResources)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// NetPol resource create/read/update/watch verbs
|
// NetPol resource create/read/update/watch verbs
|
||||||
ginkgo.By("creating")
|
ginkgo.By("creating")
|
||||||
@ -165,10 +170,14 @@ var _ = common.SIGDescribe("Netpol API", func() {
|
|||||||
for sawAnnotations := false; !sawAnnotations; {
|
for sawAnnotations := false; !sawAnnotations; {
|
||||||
select {
|
select {
|
||||||
case evt, ok := <-npWatch.ResultChan():
|
case evt, ok := <-npWatch.ResultChan():
|
||||||
framework.ExpectEqual(ok, true, "watch channel should not close")
|
if !ok {
|
||||||
|
framework.Fail("watch channel should not close")
|
||||||
|
}
|
||||||
framework.ExpectEqual(evt.Type, watch.Modified)
|
framework.ExpectEqual(evt.Type, watch.Modified)
|
||||||
watchedNetPol, isNetPol := evt.Object.(*networkingv1.NetworkPolicy)
|
watchedNetPol, isNetPol := evt.Object.(*networkingv1.NetworkPolicy)
|
||||||
framework.ExpectEqual(isNetPol, true, fmt.Sprintf("expected NetworkPolicy, got %T", evt.Object))
|
if !isNetPol {
|
||||||
|
framework.Failf("expected NetworkPolicy, got %T", evt.Object)
|
||||||
|
}
|
||||||
if watchedNetPol.Annotations["patched"] == "true" && watchedNetPol.Annotations["updated"] == "true" {
|
if watchedNetPol.Annotations["patched"] == "true" && watchedNetPol.Annotations["updated"] == "true" {
|
||||||
framework.Logf("saw patched and updated annotations")
|
framework.Logf("saw patched and updated annotations")
|
||||||
sawAnnotations = true
|
sawAnnotations = true
|
||||||
@ -185,7 +194,9 @@ var _ = common.SIGDescribe("Netpol API", func() {
|
|||||||
err = npClient.Delete(context.TODO(), createdNetPol.Name, metav1.DeleteOptions{})
|
err = npClient.Delete(context.TODO(), createdNetPol.Name, metav1.DeleteOptions{})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
_, err = npClient.Get(context.TODO(), createdNetPol.Name, metav1.GetOptions{})
|
_, err = npClient.Get(context.TODO(), createdNetPol.Name, metav1.GetOptions{})
|
||||||
framework.ExpectEqual(apierrors.IsNotFound(err), true, fmt.Sprintf("expected 404, got %#v", err))
|
if !apierrors.IsNotFound(err) {
|
||||||
|
framework.Failf("expected 404, got %#v", err)
|
||||||
|
}
|
||||||
nps, err = npClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
nps, err = npClient.List(context.TODO(), metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
framework.ExpectEqual(len(nps.Items), 2, "filtered list should have 2 items")
|
framework.ExpectEqual(len(nps.Items), 2, "filtered list should have 2 items")
|
||||||
|
@ -2321,7 +2321,9 @@ var _ = common.SIGDescribe("Services", func() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
framework.ExpectEqual(foundSvc, true, "could not find service 'kubernetes' in service list in all namespaces")
|
if !foundSvc {
|
||||||
|
framework.Fail("could not find service 'kubernetes' in service list in all namespaces")
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2395,7 +2397,9 @@ var _ = common.SIGDescribe("Services", func() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
framework.ExpectEqual(eventFound, true, "unable to find Endpoint Service in list of Endpoints")
|
if !eventFound {
|
||||||
|
framework.Fail("unable to find Endpoint Service in list of Endpoints")
|
||||||
|
}
|
||||||
|
|
||||||
ginkgo.By("updating the Endpoint")
|
ginkgo.By("updating the Endpoint")
|
||||||
foundEndpoint.ObjectMeta.Labels["test-service"] = "updated"
|
foundEndpoint.ObjectMeta.Labels["test-service"] = "updated"
|
||||||
|
Loading…
Reference in New Issue
Block a user