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

E2E refactor podcreation #149

Closed

Conversation

mangelajo
Copy link
Contributor

@mangelajo mangelajo commented Sep 12, 2019

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

@mangelajo mangelajo changed the title E2e refactor podcreation E2E refactor podcreation Sep 12, 2019
@mangelajo mangelajo requested review from skitt, tpantelis, Jaanki and sridhargaddam and removed request for skitt September 12, 2019 08:51

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() {
Copy link
Member

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.

  1. GatewayNode to GatewayNode
  2. 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
@mangelajo mangelajo force-pushed the e2e-refactor-podcreation branch from 6168d2b to 5f3bdc3 Compare September 18, 2019 12:59
Copy link
Contributor

@mpeterson mpeterson left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@mpeterson mpeterson left a 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.

@mangelajo
Copy link
Contributor Author

@mpeterson that's the aautomatic "update" by github. I can merge it later as a squash and I think it goes away.

@mangelajo
Copy link
Contributor Author

@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)))
Copy link
Contributor

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

Copy link
Contributor

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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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..

Copy link
Contributor Author

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.

Comment on lines +17 to +29
const (
InvalidPodType TestPodType = iota
ListenerPod
ConnectorPod
)

type TestPodScheduling int

const (
InvalidScheduling TestPodScheduling = iota
GatewayNode
NonGatewayNode
)
Copy link
Contributor

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.

Copy link
Contributor Author

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 ?

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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

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 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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

tpantelis added a commit to tpantelis/submariner that referenced this pull request Oct 30, 2019
- renamed TestPod to NetworkPod
- renamed createListenerConnectorPair t0 runAndVerifyNetworkPod2ServicePair
- renamed other function names where appropriate

Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
@tpantelis
Copy link
Contributor

I pushed #197 to address my comments.

Copy link
Contributor

@Jaanki Jaanki left a 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() {
Copy link
Contributor

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
Copy link
Contributor

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

tpantelis added a commit that referenced this pull request Oct 30, 2019
* 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>
@tpantelis
Copy link
Contributor

oops I mistakenly auto-rebased and merged #197 (I didn't pay attention to the browser window I had open :)). I meant to merge this one first - I guess it doesn't really matter since #197 has all the commits.

@mangelajo
Copy link
Contributor Author

oops I mistakenly auto-rebased and merged #197 (I didn't pay attention to the browser window I had open :)). I meant to merge this one first - I guess it doesn't really matter since #197 has all the commits.

np :) we can close this one then.

@mangelajo mangelajo closed this Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants