mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
e2e_network:stop using deprecated framework.ExpectError
This commit is contained in:
parent
d4050a80c7
commit
95118ec30c
@ -29,6 +29,7 @@ import (
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
@ -233,14 +234,14 @@ var _ = common.SIGDescribe("Netpol API", func() {
|
||||
SetSpecPodSelectorMatchLabels(map[string]string{"pod-name": "test-pod"}),
|
||||
SetSpecEgressRules(egressRule))
|
||||
_, err := npClient.Create(ctx, npTemplate, metav1.CreateOptions{})
|
||||
framework.ExpectError(err, "request template:%v", npTemplate)
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "request template:%v", npTemplate)
|
||||
|
||||
ginkgo.By("EndPort field cannot be defined if the Port field is defined as a named (string) port.")
|
||||
egressRule = networkingv1.NetworkPolicyEgressRule{}
|
||||
egressRule.Ports = append(egressRule.Ports, networkingv1.NetworkPolicyPort{Port: &intstr.IntOrString{Type: intstr.String, StrVal: "serve-80"}, EndPort: &endport})
|
||||
npTemplate.Spec.Egress = []networkingv1.NetworkPolicyEgressRule{egressRule}
|
||||
_, err = npClient.Create(ctx, npTemplate, metav1.CreateOptions{})
|
||||
framework.ExpectError(err, "request template:%v", npTemplate)
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "request template:%v", npTemplate)
|
||||
|
||||
ginkgo.By("EndPort field must be equal or greater than port.")
|
||||
ginkgo.By("When EndPort field is smaller than port, it will failed")
|
||||
@ -248,7 +249,7 @@ var _ = common.SIGDescribe("Netpol API", func() {
|
||||
egressRule.Ports = append(egressRule.Ports, networkingv1.NetworkPolicyPort{Port: &intstr.IntOrString{Type: intstr.Int, IntVal: 30000}, EndPort: &endport})
|
||||
npTemplate.Spec.Egress = []networkingv1.NetworkPolicyEgressRule{egressRule}
|
||||
_, err = npClient.Create(ctx, npTemplate, metav1.CreateOptions{})
|
||||
framework.ExpectError(err, "request template:%v", npTemplate)
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "request template:%v", npTemplate)
|
||||
|
||||
ginkgo.By("EndPort field is equal with port.")
|
||||
egressRule.Ports[0].Port = &intstr.IntOrString{Type: intstr.Int, IntVal: 20000}
|
||||
|
@ -2139,15 +2139,15 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
for i := 0; i < 5; i++ {
|
||||
cmd = fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, clusterIPAddress)
|
||||
_, err := e2eoutput.RunHostCmd(pausePod1.Namespace, pausePod1.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to cluster IP")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to cluster IP")
|
||||
|
||||
cmd = fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, nodePortAddress0)
|
||||
_, err = e2eoutput.RunHostCmd(pausePod1.Namespace, pausePod1.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to NodePort address")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to NodePort address")
|
||||
|
||||
cmd = fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, nodePortAddress1)
|
||||
_, err = e2eoutput.RunHostCmd(pausePod1.Namespace, pausePod1.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to NodePort address")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to NodePort address")
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
@ -2529,7 +2529,7 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
// the second pause pod is on a different node, so it should see a connection error every time
|
||||
cmd := fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, serviceAddress)
|
||||
_, err := e2eoutput.RunHostCmd(pausePod1.Namespace, pausePod1.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to cluster IP")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to cluster IP")
|
||||
}
|
||||
})
|
||||
|
||||
@ -2599,7 +2599,7 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
// the second pause pod is on a different node, so it should see a connection error every time
|
||||
cmd := fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, serviceAddress)
|
||||
_, err := e2eoutput.RunHostCmd(pausePod1.Namespace, pausePod1.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to cluster IP")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to cluster IP")
|
||||
}
|
||||
})
|
||||
|
||||
@ -2672,7 +2672,7 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
// the second pause pod is on a different node, so it should see a connection error every time
|
||||
cmd := fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, serviceAddress)
|
||||
_, err := e2eoutput.RunHostCmd(pausePod1.Namespace, pausePod1.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to cluster IP")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to cluster IP")
|
||||
}
|
||||
|
||||
ginkgo.By("Creating 2 pause hostNetwork pods that will try to connect to the webserver")
|
||||
@ -2701,7 +2701,7 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
// the second pause pod is on a different node, so it should see a connection error every time
|
||||
cmd := fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, serviceAddress)
|
||||
_, err := e2eoutput.RunHostCmd(pausePod3.Namespace, pausePod3.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to cluster IP")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to cluster IP")
|
||||
}
|
||||
})
|
||||
|
||||
@ -2943,7 +2943,7 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
|
||||
cmd := fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, serviceAddress)
|
||||
_, err := e2eoutput.RunHostCmd(pausePod1.Namespace, pausePod1.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to cluster IP")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to cluster IP")
|
||||
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
@ -3099,7 +3099,7 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
// connections are neither internal nor external and always get Cluster traffic policy.
|
||||
cmd := fmt.Sprintf(`curl -q -s --connect-timeout 5 %s/hostname`, nodePortAddress1)
|
||||
_, err := e2eoutput.RunHostCmd(pausePod0.Namespace, pausePod0.Name, cmd)
|
||||
framework.ExpectError(err, "expected error when trying to connect to node port for pausePod0")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "expected error when trying to connect to node port for pausePod0")
|
||||
|
||||
execHostnameTest(*pausePod0, nodePortAddress0, webserverPod0.Name)
|
||||
execHostnameTest(*pausePod1, nodePortAddress0, webserverPod0.Name)
|
||||
@ -3311,7 +3311,7 @@ var _ = common.SIGDescribe("Services", func() {
|
||||
|
||||
ginkgo.By("fetching the Endpoint")
|
||||
_, err = f.ClientSet.CoreV1().Endpoints(testNamespaceName).Get(ctx, testEndpointName, metav1.GetOptions{})
|
||||
framework.ExpectError(err, "should not be able to fetch Endpoint")
|
||||
gomega.Expect(err).To(gomega.HaveOccurred(), "should not be able to fetch Endpoint")
|
||||
})
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user