-
Notifications
You must be signed in to change notification settings - Fork 243
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
[Integration] Fixes for integration tests #3821
Conversation
7217725
to
eeba875
Compare
test/integration/proxy_test.go
Outdated
Expect(RunCRCExpectSuccess("config", "set", "network-mode", networkMode), ContainSubstring("Network mode")) | ||
if runtime.GOOS == "linux" { | ||
Expect(RunCRCExpectSuccess("config", "set", "network-mode", networkMode), ContainSubstring("Network mode")) | ||
} |
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 argue that it's not very useful to test a non-default network mode, as this is not what most users will experience. Are there some issues if we run with the default network mode on linux?
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.
@jsliacan WDYS?
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.
The reason why it was this way was mostly convenience - at the time when I wrote that test, you could set network mode on all platforms, so no extra code needed for linux. Also, linux system mode is subject to the e2e proxy test (which is only for linux). So this seemed to cover another (albeit less useful) case of user mode on linux.
That said, I see how it's a non-default option and thus might not be worth testing at this point. If you say that that's the case I'm happy to parametrize the proxy address by platform and use system mode on linux.
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.
If you say that that's the case I'm happy to parametrize the proxy address by platform and use system mode on linux.
Ah, if this makes the proxy test/code simpler, this can be a reason for using user
mode networking on linux. Let's keep this for now to try to fix integration tests.
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.
With system networking, it's
crc/test/extended/util/proxy.go
Line 68 in 85cc718
addr := flag.String("127.0.0.1", ":8888", "proxy listen address") // using network-mode=user |
NB: should have looked at your recent changes before commenting ^^
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 surprised this works with user-mode networking though if you don't' set * host-network-access Allow TCP/IP connections from the CRC VM to services running on the host (true/false, default: false)
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.
overall OK. moving to a serial execution... Does this add to the total runtime?
the networkmode is an open question
eeba875
to
20f95c2
Compare
2f86ee5
to
fb8382e
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.
Really not clear why the tests would still be failing :(
But looks good to me, ideally the last commit would be squashed to the right place.
/retest |
@jsliacan: The following test failed, say
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. |
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.
2 minor comments, otherwise looks good!
@@ -140,11 +140,14 @@ func CheckCRCStatus(state string) error { | |||
expression = `.*CRC VM:.*\s.*: .*Stopped.*` | |||
} | |||
|
|||
err := util.ExecuteCommand(CRC("status").ToString()) | |||
cmd := exec.Command("crc", "status") | |||
out, err := cmd.Output() |
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 do we want to avoid this?
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.
Because I need to explicitly get the stdout to check what was in it, and util.ExecuteCommand
does not return that and isn't easily modifiable to do so (and even if it was, it's used in many many places which would need changing too). So going around it like above seemed better. I hope I am not overlooking something here, but that was the reasoning.
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.
looking at util/shell.go
code, CommandReturnShouldMatch("stdout"
calls CompareExpectedWithActualContains(expected, shell.GetLastCmdOutput("stdout"))
which is supposed to get the command stdout output. Not clear why it's not working for 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 suggest keeping this one out of the PR so that we can merge it, and to address issues related to this in a follow-up PR.
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 integration tests, we do not use the shell construct (to simulate a user interacting with crc in one shell session). In e2e, we do (initialized here):
err := util.StartHostShellInstance(testWithShell)
We had issues with running crc setup
(with all the progress bars etc.) in e2e tests and had to move the execution of that command out of the general shell. So with integration, we didn't use the shell construct at all.
Given that we do not have an instance of ShellInstance available, functions which rely on it won't work as expected. Therefore, instead of retrieving the stdout content from the shell
variable that would contain it if it existed, we need to pass it between command execution (crc status
) and output analysis (does it contain Running
?) by hand. And that's what this commit does. Without it, WaitForClusterInState
won't have any effect (except for wasting 10mins).
So if we omit this change from this PR, integration tests will keep failing, albeit with a different error than initially when we started out.
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 would be a nice explanation to have in the commit log ;)
CheckCRCStatus
is used by both e2e and integration tests, is it ok to remove the use of shell
for e2e?
And what about all the users of ExecuteCommand()
in cmd.go? They also rely on shell.go
, is this going to cause issues?
If this change is good enough to fix integration tests without breaking e2e, we can go with it, but some follow-up cleanups would be very useful imo (a clean separation between helpers using exec.Command
, and helpers using shell.go
). The former would only be used in integration tests, and the latter in e2e.
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 would be a nice explanation to have in the commit log ;)
Will add it there.
CheckCRCStatus is used by both e2e and integration tests, is it ok to remove the use of shell for e2e?
It is ok in the sense that it'll work. However, it'll dent the effort to simulate single-session user interaction with CRC.
And what about all the users of ExecuteCommand() in cmd.go? They also rely on shell.go, is this going to cause issues?
As long as you don't need to retrieve anything aside from the error, it will do the job the same way.
some follow-up cleanups would be very useful imo
I don't know the extent of this. It could have further consequences -- maybe it makes less sense to share the code between e2e and integration then. I opened an issue to track this: #3859
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.
maybe it makes less sense to share the code between e2e and integration then
Maybe some go interface can be defined and used in the shared code. The interface would either make use of the shell code to run the command/get stdout/..., or would directly run the command for the integration tests.
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("podman preset", Serial, Label("podman-preset"), func() { | ||
var _ = Describe("podman preset", Serial, Ordered, Label("podman-preset"), 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.
Is it intentional that the Ordered
addition is in this integration: cleanup to AfterAll and BeforeSuite
commit and not in integration: run ginkgo nodes serially and in ordered fashion
? If it's not intentional, I've already split it in https://github.com/cfergeau/crc/commits/ginkgo-issue
I forgot that I need to unset HTTPS_PROXY and HTTP_PROXY env variables that are implicitly set during the test. |
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 do not see 497c1d0#r1346340794 in the commit log for " tests: avoid using shell struct in CheckCRCStatus" but apart from this, ACK.
The outer Describe block needs to be Ordered to be able to use AfterAll inside it. Cleanup in BeforeSuite and AfterAll functions should take care of clean environment before and after each testcase.
In e2e we use WaitForClusterInState after `crc start` finishes to give time to the cluster to stabilize (all operators are reliably up). This is also needed here before we login to the cluster.
In integration tests we do not make use of ShellInstance, so in order to be able to share WaitForClusterInState between e2e and integration, we need CheckCRCStatus not to rely on ShellInstance. See also this comment: crc-org#3821 (comment).
2e47f70
to
f50b81c
Compare
Last changes include |
42edf70
to
840e690
Compare
840e690
to
0a47db1
Compare
@@ -50,7 +50,7 @@ var _ = Describe("podman preset", Serial, Ordered, Label("podman-preset"), func( | |||
unexpandedPath := filepath.Join(userHomeDir, ".crc/bin/oc;${PATH}") | |||
path = os.ExpandEnv(unexpandedPath) | |||
csshk = filepath.Join(userHomeDir, ".crc/machines/crc/id_ecdsa") | |||
dh = "npipe:////./pipe/rc-podman" | |||
dh = "npipe:////./pipe/crc-podman" |
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 also happens in the E2E tests
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.
True, thanks. Grepped it now and the e2e occurrence was the last one. Changed it and updated the commit too.
93866b7
to
23adf9a
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cfergeau 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 |
(waiting for integration-crc to run before merging it) |
@jsliacan: The following test failed, say
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. |
e2e-integration now succeed. |
In integration tests we do not make use of ShellInstance, so in order to be able to share WaitForClusterInState between e2e and integration, we need CheckCRCStatus not to rely on ShellInstance. See also this comment: #3821 (comment).
Fixes: Issue #3771
Related to Issue #3796