-
Notifications
You must be signed in to change notification settings - Fork 193
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
E2E refactor podcreation #149
E2E refactor podcreation #149
Conversation
|
||
func testPod2ServiceTCP(f *framework.Framework) { | ||
It("Should be able to perform a Pod to Service TCP connection and exchange data between different clusters NonGW to GW", 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.
IMO, the following two tests should cover most of the use-cases.
- GatewayNode to GatewayNode
- nonGWNode to nonGWNode
The second use-case is like a superset and it covers most of the combinations.
So, please change this test (line 17) to Gateway to Gateway.
Also, make this as the first test to run and the above one (i.e., line 13) as the second test.
The concept of TestPodConfig and TestPod is defined, letting us create testing pods from a single interface, and automating the creation of UUID data to exchange. As late modifications has shown that the number of parameters keeps growing having a single fixture to create test pods will make easier to write and read E2E tests. Depends-On: submariner-io#148
6168d2b
to
5f3bdc3
Compare
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
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, I missed that you have a merge commit. Please rebase to avoid it. There is no need to have merge commits as part of the PR.
@mpeterson that's the aautomatic "update" by github. I can merge it later as a squash and I think it goes away. |
@mpeterson merge commits aren’t an issue, with the squash and merge github strategy it will result on a single commit on top of the existing master . |
Expect(exitStatusC).To(Equal(int32(0))) | ||
connectorPod.WaitForFinishStatus() | ||
framework.Logf("Connector output\n%s", keepLines(connectorPod.TerminationMessage, 2)) | ||
Expect(connectorPod.TerminationCode).To(Equal(int32(0))) |
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 should be in a different method (or two)..
createListenerConnectorPair should be aboult the creation of these pods not verifying they actually did something
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.
It doesn't seem we would ever want to call create w/o verify. We're going to also want to test pod -> pod in addition to pod -> service. How about we call this runAndVerifyNetworkPod2ServicePair
and then add runAndVerifyNetworkPod2PodPair
later?
// create a test pod inside the current test namespace on the specified cluster. | ||
// The pod will listen on TestPort over TCP, send sendString over the connection, | ||
// and write the network response in the pod termination log, then exit with 0 status | ||
func (f *Framework) CreateTCPCheckListenerPod(cluster ClusterIndex, scheduling TestPodScheduling, sendString string) *v1.Pod { | ||
func (tp *TestPod) buildTCPCheckListenerPod() { |
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 already OOP'ing it, this function is super similar to buildTCPCheckConnectorPod
.. Why not have one function that gets the necessary parameters, and when creating the pod you can determine those parameters based on the tp.Config.Type?
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.
There are subtle differences:
one waits to be ready, the other does not...,
one has REMOTE_PORT, the other LISTEN_PORT).
the sh lines are different.
I personally prefer separate functions to lots of "ifs" in the middle of the code.
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 bunch of IFs? You can have parameters you know..
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.
yes but those parameters would need to acted on, wouldn't they?...
I probably not getting your idea. But also, I think there's no need to dive so much into detail, code is not written in stone, we can change it later specially since it is a private method now.
const ( | ||
InvalidPodType TestPodType = iota | ||
ListenerPod | ||
ConnectorPod | ||
) | ||
|
||
type TestPodScheduling int | ||
|
||
const ( | ||
InvalidScheduling TestPodScheduling = iota | ||
GatewayNode | ||
NonGatewayNode | ||
) |
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 feel that by moving this here you're mixing "pods" and "network_pods" which is a distinction that existed earlier, but now every pod is a "network pod" so I'm not sure if it makes sense to even have this code in separate files.
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.
Yeah, I agree on that you're right, may be it's better to consolidate stuff. Non-network pods make no sense to our testing.
May be this file should be network_pods.go and the other one tcp_check_pods.go? or
pods.go + tcp_check_pods.go ?
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.
How about we call it NetworkPod
instead of TestPod
and also the related types NetworkPod*
? And put all the code in network_pods.go.
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.
sounds good, I like your patch.
Expect(err).NotTo(HaveOccurred()) | ||
return terminationCode, terminationMessage | ||
|
||
return tp.Pod.Status.Phase == v1.PodSucceeded || tp.Pod.Status.Phase == v1.PodFailed |
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.
Wouldn't it have a different status only when it had an error (based on the switch on line 128)? In that case it would fail on line 138 anyway, making this check moot
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 one (L128) returns to the inner loop of wait.PollInmediate
You could have still existed while the pod is pending, due to a timeout. In that case I want it to return "false",
because the Pod didn't really "Finish" and we are waiting for finish status.
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 reckon that when timeout is reached it will return an error, in fact "ErrWaitTimeout is returned when the condition exited without success." from https://godoc.org/k8s.io/apimachinery/pkg/util/wait#pkg-variables
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.
ha!, then the method wont work when waiting for timeouts :-/.
In the PR tom sent on top of this one he has modified that logic, and will only Await for successful... we can add a AwaitForFailure or AwaitForTimeout at a later time refactoring that one a bit.
- renamed TestPod to NetworkPod - renamed createListenerConnectorPair t0 runAndVerifyNetworkPod2ServicePair - renamed other function names where appropriate Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
I pushed #197 to address my comments. |
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
// create a test pod inside the current test namespace on the specified cluster. | ||
// The pod will listen on TestPort over TCP, send sendString over the connection, | ||
// and write the network response in the pod termination log, then exit with 0 status | ||
func (f *Framework) CreateTCPCheckListenerPod(cluster ClusterIndex, scheduling TestPodScheduling, sendString string) *v1.Pod { | ||
func (tp *TestPod) buildTCPCheckListenerPod() { |
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 bunch of IFs? You can have parameters you know..
Expect(err).NotTo(HaveOccurred()) | ||
return terminationCode, terminationMessage | ||
|
||
return tp.Pod.Status.Phase == v1.PodSucceeded || tp.Pod.Status.Phase == v1.PodFailed |
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 reckon that when timeout is reached it will return an error, in fact "ErrWaitTimeout is returned when the condition exited without success." from https://godoc.org/k8s.io/apimachinery/pkg/util/wait#pkg-variables
* E2E: Refactor handling of pods The concept of TestPodConfig and TestPod is defined, letting us create testing pods from a single interface, and automating the creation of UUID data to exchange. As late modifications has shown that the number of parameters keeps growing having a single fixture to create test pods will make easier to write and read E2E tests. Depends-On: #148 * Address comments inn #149 - renamed TestPod to NetworkPod - renamed createListenerConnectorPair t0 runAndVerifyNetworkPod2ServicePair - renamed other function names where appropriate Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
This is ready for review, but please look only at the 2nd patch: 6168d2b
The concept of TestPodConfig and TestPod is defined, letting us create
testing pods from a single interface, and automating the creation
of UUID data to exchange.
As late modifications has shown that the number of parameters keeps growing
having a single fixture to create test pods will make easier to write
and read E2E tests.
Depends-On: #148