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

[Integration] Fixes for integration tests #3821

Merged
merged 10 commits into from
Oct 13, 2023

Conversation

jsliacan
Copy link
Contributor

@jsliacan jsliacan commented Sep 5, 2023

Fixes: Issue #3771

Related to Issue #3796

Expect(RunCRCExpectSuccess("config", "set", "network-mode", networkMode), ContainSubstring("Network mode"))
if runtime.GOOS == "linux" {
Expect(RunCRCExpectSuccess("config", "set", "network-mode", networkMode), ContainSubstring("Network mode"))
}
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jsliacan WDYS?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

@cfergeau cfergeau Sep 29, 2023

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

addr := flag.String("127.0.0.1", ":8888", "proxy listen address") // using network-mode=user
which would need to be changed to something reachable by the VM?

NB: should have looked at your recent changes before commenting ^^

Copy link
Contributor

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)

Copy link
Contributor

@gbraad gbraad left a 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

Copy link
Contributor

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

@jsliacan
Copy link
Contributor Author

jsliacan commented Oct 2, 2023

/retest

@openshift-merge-robot
Copy link
Contributor

@jsliacan: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-crc 1ed1474 link true /test e2e-crc

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.

Copy link
Contributor

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

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 :-/

Copy link
Contributor

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.

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

test/extended/util/proxy.go Outdated Show resolved Hide resolved
. "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() {
Copy link
Contributor

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

@jsliacan
Copy link
Contributor Author

jsliacan commented Oct 5, 2023

I forgot that I need to unset HTTPS_PROXY and HTTP_PROXY env variables that are implicitly set during the test.

Copy link
Contributor

@cfergeau cfergeau left a 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).
@jsliacan
Copy link
Contributor Author

Last changes include git reset onto @cfergeau 's branch with improved commits, additional unset HTTP(S)_PROXY in AfterAll, and updated commit message to explain why we're changing CheckCRCStatus to avoid using ShellInstance.

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

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

Copy link
Contributor Author

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.

@openshift-ci openshift-ci bot added the lgtm label Oct 12, 2023
@openshift-ci openshift-ci bot added the lgtm label Oct 12, 2023
@openshift-ci
Copy link

openshift-ci bot commented Oct 12, 2023

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cfergeau
Copy link
Contributor

(waiting for integration-crc to run before merging it)

@openshift-ci
Copy link

openshift-ci bot commented Oct 12, 2023

@jsliacan: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-crc 23adf9a link true /test e2e-crc

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.

@praveenkumar
Copy link
Member

e2e-integration now succeed.

@praveenkumar praveenkumar merged commit 65e3a58 into crc-org:main Oct 13, 2023
13 checks passed
praveenkumar pushed a commit that referenced this pull request Oct 13, 2023
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants