Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix e2e test RejectServiceTraffic #3892

Merged
merged 1 commit into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/e2e/antreapolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1649,9 +1649,9 @@ func testRejectServiceTraffic(t *testing.T, data *TestData) {
builder1 = builder1.SetName("acnp-reject-egress-svc-traffic").
SetPriority(1.0).
SetAppliedToGroup([]ACNPAppliedToSpec{{PodSelector: map[string]string{"antrea-e2e": "agnhost-client"}}})
builder1.AddEgress(ProtocolTCP, &p80, nil, nil, nil, nil, nil, nil, nil, map[string]string{"antrea-e2e": "s1"}, nil,
builder1.AddEgress(ProtocolTCP, &p80, nil, nil, nil, nil, nil, nil, nil, svc1.Spec.Selector, nil,
nil, nil, false, nil, crdv1alpha1.RuleActionReject, "", "", nil)
builder1.AddEgress(ProtocolTCP, &p80, nil, nil, nil, nil, nil, nil, nil, map[string]string{"antrea-e2e": "s2"}, nil,
builder1.AddEgress(ProtocolTCP, &p80, nil, nil, nil, nil, nil, nil, nil, svc2.Spec.Selector, nil,
nil, nil, false, nil, crdv1alpha1.RuleActionReject, "", "", nil)

acnpEgress := builder1.Get()
Expand All @@ -1678,7 +1678,7 @@ func testRejectServiceTraffic(t *testing.T, data *TestData) {
builder2 := &ClusterNetworkPolicySpecBuilder{}
builder2 = builder2.SetName("acnp-reject-ingress-svc-traffic").
SetPriority(1.0).
SetAppliedToGroup([]ACNPAppliedToSpec{{PodSelector: map[string]string{"antrea-e2e": "s1"}}, {PodSelector: map[string]string{"antrea-e2e": "s2"}}})
SetAppliedToGroup([]ACNPAppliedToSpec{{PodSelector: svc1.Spec.Selector}, {PodSelector: svc2.Spec.Selector}})
builder2.AddIngress(ProtocolTCP, &p80, nil, nil, nil, nil, nil, nil, nil, map[string]string{"antrea-e2e": "agnhost-client"}, nil,
nil, nil, false, nil, crdv1alpha1.RuleActionReject, "", "", nil)

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (data *TestData) createAgnhostServiceAndBackendPods(t *testing.T, name, nam
ipProtocol = corev1.IPv6Protocol
}
require.NoError(t, data.podWaitForRunning(defaultTimeout, name, namespace))
svc, err := data.CreateService(name, namespace, 80, 80, map[string]string{"app": "agnhost"}, false, false, svcType, &ipProtocol)
svc, err := data.CreateService(name, namespace, 80, 80, map[string]string{"app": "agnhost", "antrea-e2e": name}, false, false, svcType, &ipProtocol)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt if this change really works. Lable "antrea-e2e":$podName is also added on all Pods automaticallly which are created by function createPodOnNode. If "app": "agnhost" is matching other Pods created not in this case, it should be the same.

If the target of this change is to use a different Service selector to get accurate Pods, we should introduce a different label/selector key in the created object from the default settings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lable "antrea-e2e":$podName is also added on all Pods automaticallly which are created by function createPodOnNode

That's the purpose of the change, podName is different, right? createPodOnNode(pod1) and createPodOnNode(pod2) will get two Pods with different labels: {"app": "agnhost", "antrea-e2e": "pod1"}, {"app": "agnhost", "antrea-e2e": "pod2"}, and service1 only selects the former and service2 only selects the latter, anything wrong?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wenyingd does the explanation address your question?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for the explanation.

require.NoError(t, err)

cleanup := func() {
Expand Down