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

Add tcp lb testcases #106

Merged
merged 1 commit into from
Jun 26, 2023
Merged

Conversation

rlobillo
Copy link
Contributor

@rlobillo rlobillo commented Jun 1, 2023

Covering tech debt in openstack-test

https://issues.redhat.com/browse/OSASINFRA-2412

@openshift-ci openshift-ci bot requested review from eurijon and stephenfin June 1, 2023 15:21
@rlobillo
Copy link
Contributor Author

rlobillo commented Jun 2, 2023

/cc @dulek Could you please review this?

@rlobillo
Copy link
Contributor Author

rlobillo commented Jun 2, 2023

/cc @dulek

@openshift-ci openshift-ci bot requested a review from dulek June 2, 2023 14:53
// https://issues.redhat.com/browse/OSASINFRA-2753
g.It(fmt.Sprintf("should create an UDP %s LoadBalancer when an UDP svc with type:LoadBalancer is created on Openshift", lbProviderUnderTest), func() {
for _, j := range availableProtocolsUnderTests {
protocolUnderTest := j
Copy link
Contributor

Choose a reason for hiding this comment

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

Why like this? Just assign it directly to protocolUnderTest:

for _, protocolUnderTest := range availableProtocolsUnderTests {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's something we observed in the previous round of tests. Honestly, I don't know why but the whole engine that is calculating the list of tests don't work if I don't do that. I copied the current approach from origin, so I assume they already hit that and that was their solution.

Copy link
Member

Choose a reason for hiding this comment

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

right, goroutines in for cycles...

To make it a bit more digestible, try this:

for i := range availableLbProvidersUnderTests {
	lbProviderUnderTest := availableLbProvidersUnderTests[i]

	for j := range availableProtocolsUnderTests {
		protocolUnderTest := availableProtocolsUnderTests[j]

Copy link
Member

Choose a reason for hiding this comment

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

I’d also check if this Ginkgo thing likes being called in a loop.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, fair enough, origin's approach works for me.

// Error if there is no answer or cannot access the port after 5 seconds.
func getPodNameThroughUdpLb(ip string, port string, message string) (string, error) {
func getPodNameThroughTcpLb(ip string, port string, message string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh right! thanks for noticing

// https://issues.redhat.com/browse/OCPBUGS-2350
g.It(fmt.Sprintf("should apply lb-method on UDP %s LoadBalancer when an UDP svc with monitors and ETP:Local is created on Openshift", lbProviderUnderTest), func() {
for _, j := range availableProtocolsUnderTests {
protocolUnderTest := j
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

Copy link
Member

Choose a reason for hiding this comment

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

for j := range availableProtocolsUnderTests {
	protocolUnderTest := availableProtocolsUnderTests[j]

@dulek
Copy link
Contributor

dulek commented Jun 2, 2023

Thanks for doing this Ramon!

@rlobillo rlobillo requested a review from dulek June 13, 2023 07:31
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 13, 2023
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 14, 2023
@rlobillo
Copy link
Contributor Author

/cc @pierreprinetti

skipIfNotLbProvider(lbProviderUnderTest, cloudProviderConfig)
// https://issues.redhat.com/browse/OSASINFRA-2753
// https://issues.redhat.com/browse/OSASINFRA-2412
g.It(fmt.Sprintf("should create an %s %s LoadBalancer when an %s svc with type:LoadBalancer is created on Openshift", protocolUnderTest, lbProviderUnderTest, protocolUnderTest), func() {
Copy link
Member

Choose a reason for hiding this comment

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

nit: s/when an %s svc/when a %s svc/, which works for both UDP and TCP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

// Send message on provided ip and UDP port and return the answer.
// Error if there is no answer or cannot access the port after 5 seconds.
func getPodNameThroughUdpLb(ip string, port string, message string) (string, error) {
func getPodNameThroughLb(ip string, port string, protocol v1.Protocol, message string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

While you're at it, please accept port as int and cast within this function (for example, with strconv.Itoa())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer not do so as the port is int32 and I'm passing it converted to a string. I don't want to add another cast to convert int32 to int and then int to string. I'd let it be as it is now.

Copy link
Member

Choose a reason for hiding this comment

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

why is it int32?

Copy link
Member

Choose a reason for hiding this comment

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

ah ServicePort. Well it can be int32 in this function signature too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in such case I cannot use strconv.Itoa(port) or equivalent strconv function, at least I wasn't able to find it.

Copy link
Member

Choose a reason for hiding this comment

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


// receive message from server
buffer := make([]byte, 1024)
n, _, err := conn.ReadFromUDP(buffer)
Copy link
Member

Choose a reason for hiding this comment

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

Since you're discarding the UPDAddr, this could be conn.ReadFrom(buffer)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
Copy link
Member

Choose a reason for hiding this comment

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

nit: use io.ReadAll

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -674,6 +719,9 @@ func createTestDeployment(depName string, labels map[string]string, replicas int
isFalse := false
isTrue := true
netExecParams := "--" + strings.ToLower(string(protocol)) + "-port=" + fmt.Sprintf("%d", port)
if protocol == v1.ProtocolTCP {
Copy link
Member

Choose a reason for hiding this comment

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

nit: to improve readability, you could treat all cases at the same time (e.g. with a case/switch) instead of setting a default and then override for TCP.

Something like:

	var netExecParams string
	switch protocol {
	case v1.ProtocolTCP:
		netExecParams = fmt.Sprintf("--http-port=%d", port)
	default:
		netExecParams = fmt.Sprintf("--%s-port=%d", strings.ToLower(string(protocol)), port)
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<3 it. Thank you.

Copy link
Member

@pierreprinetti pierreprinetti left a comment

Choose a reason for hiding this comment

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

I'm far from being a LB expert, so this PR is probably not for me, sorry. I just added a couple comments on the form, that you can totally ignore. For what it's worth, LGTM!

@rlobillo
Copy link
Contributor Author

I'm far from being a LB expert, so this PR is probably not for me, sorry. I just added a couple comments on the form, that you can totally ignore. For what it's worth, LGTM!

Thanks for your inputs!

@MaysaMacedo
Copy link
Contributor

/cc

@openshift-ci openshift-ci bot requested a review from MaysaMacedo June 19, 2023 14:03
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 19, 2023

@rlobillo: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

// https://issues.redhat.com/browse/OSASINFRA-2753
g.It(fmt.Sprintf("should create an UDP %s LoadBalancer when an UDP svc with type:LoadBalancer is created on Openshift", lbProviderUnderTest), func() {
for _, j := range availableProtocolsUnderTests {
protocolUnderTest := j
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, fair enough, origin's approach works for me.

@dulek
Copy link
Contributor

dulek commented Jun 26, 2023

/approve

I'll leave LGTM for @MaysaMacedo.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 26, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 26, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dulek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 26, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 26, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dulek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 88a4f2b into openshift:main Jun 26, 2023
6 checks passed
@dulek
Copy link
Contributor

dulek commented Jun 26, 2023

Whoops, my mistake, I didn't think that it'll catch that LGTM. Any review Maysa will make will need to go through a follow up patch.

e2e.Logf("Pods accessed after 100 UDP requests:\n%v\n", results)
pods, err := oc.KubeClient().CoreV1().Pods(oc.Namespace()).List(ctx, metav1.ListOptions{})
o.Expect(err).NotTo(o.HaveOccurred())
e2e.Logf("Pods accessed after 100 UDP requests:\n%v\n", results)
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like the mention to UDP is a leftover here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for noticing @MaysaMacedo
I created this PR to address this: #112

Copy link
Member

Choose a reason for hiding this comment

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

hey that's a wonderful opportunity for turning port into a number!

Copy link
Contributor

@MaysaMacedo MaysaMacedo left a comment

Choose a reason for hiding this comment

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

LGTM. I just noticed a leftover

@pierreprinetti pierreprinetti deleted the tcp-lb branch June 27, 2023 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants