-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add tcp lb testcases #106
Conversation
/cc @dulek Could you please review this? |
/cc @dulek |
// 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 |
There was a problem hiding this comment.
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 {
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unused?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
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]
Thanks for doing this Ramon! |
/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() { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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()
)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it int32?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: use io.ReadAll
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<3 it. Thank you.
There was a problem hiding this 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!
Covering tech debt in openstack-test https://issues.redhat.com/browse/OSASINFRA-2412
Thanks for your inputs! |
/cc |
@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 |
There was a problem hiding this comment.
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.
/approve I'll leave LGTM for @MaysaMacedo. |
[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 |
[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 |
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
There was a problem hiding this 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
Covering tech debt in openstack-test
https://issues.redhat.com/browse/OSASINFRA-2412