Skip to content

Fix running integration tests as part of build #12693

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

Merged
merged 3 commits into from
Sep 19, 2022

Conversation

mads-hartmann
Copy link
Contributor

@mads-hartmann mads-hartmann commented Sep 6, 2022

Description

This PR makes it possible to use with-integration-tests to run integration tests as part of the build job. This functionality has existed for a long time, but it was never updated to work with Harvester-based preview environments.

The old approach was to start a separate Werft job which used the eu.gcr.io/gitpod-core-dev/build/integration-tests:{{ .Annotations.version }} image in Werft. This meant it would run the compiled integration tests. However, this image doesn't have any of the utility scripts available we need to configure access to the the preview environment.

So I instead decided to delete the .werft/run-integration-tests.yaml job and instead introduce a small helper script -
test/run.sh - which uses go to run the tests. This is similar to the approach adopted by Workspace (.werft/workspace-run-integration-tests.sh) and IDE (.werft/ide-integration-tests-startup.yaml).

My intention is to use test/run.sh in both the Workspace and IDE integration test jobs too, so that we have a single way to run integration tests which is used in both Werft and Gitpod workspaces - but I'll look into this in a follow up PR.


This PR also adds a new checkbox for with-integration-tests to the PR template so spread awareness of the flag.

Related Issue(s)

Part of #12350

How to test

I ran the script manually from my Gitpod workspace

./test/run.sh
./test/run.sh ide
./test/run.sh webapp
./test/run.sh workspace

I ran it through Werft (see job)

werft job run github -a with-preview="true" -a with-integration-tests="ide"

Release Notes

NONE

Documentation

N/A

Werft options:

  • /werft with-preview
  • /werft with-integration-tests=all
    Valid updates are all, workspace, webapp, ide

@mads-hartmann
Copy link
Contributor Author

mads-hartmann commented Sep 7, 2022

/werft run

👍 started the job as gitpod-build-mads-fix-with-integration-tests.16
(with .werft/ from main)

@mads-hartmann mads-hartmann force-pushed the mads/fix-with-integration-tests branch from fd9729f to f2a2753 Compare September 7, 2022 10:51
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-mads-fix-with-integration-tests.32 because the annotations in the pull request description changed
(with .werft/ from main)

@mads-hartmann mads-hartmann force-pushed the mads/fix-with-integration-tests branch from 21230d3 to c14dfdc Compare September 14, 2022 08:36
@mads-hartmann mads-hartmann changed the title WIP: Fix running integration tests as part of build Fix running integration tests as part of build Sep 14, 2022
@mads-hartmann mads-hartmann force-pushed the mads/fix-with-integration-tests branch from c14dfdc to 6acb87a Compare September 14, 2022 08:59
@roboquat roboquat added size/XL and removed size/L labels Sep 14, 2022
@mads-hartmann mads-hartmann force-pushed the mads/fix-with-integration-tests branch 2 times, most recently from 4e05203 to 3044bdd Compare September 14, 2022 09:46
@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-mads-fix-with-integration-tests.39 because the annotations in the pull request description changed
(with .werft/ from main)

@werft-gitpod-dev-com
Copy link

started the job as gitpod-build-mads-fix-with-integration-tests.40 because the annotations in the pull request description changed
(with .werft/ from main)

@mads-hartmann mads-hartmann force-pushed the mads/fix-with-integration-tests branch 3 times, most recently from ccc51b2 to f84e4bd Compare September 14, 2022 11:25
@mads-hartmann mads-hartmann marked this pull request as ready for review September 14, 2022 11:30
@mads-hartmann mads-hartmann requested a review from a team September 14, 2022 11:31
@mads-hartmann
Copy link
Contributor Author

mads-hartmann commented Sep 14, 2022

@utam0k I'd like you to review this as you've been working on integration tests for workspace recently. Does the README capture how you have been working on integration tests? Are there any instructions or tips & tricks missing? ☺️
@mustard-mh I believe you're worked on integration tests for IDE. If so, I'd love your review on this PR too.
@geropl Wasn't sure who knew most about the previous setup but thought it might be you.

@mustard-mh mustard-mh requested a review from iQQBot September 14, 2022 11:59
@utam0k
Copy link
Contributor

utam0k commented Sep 15, 2022

@mads-hartmann Thanks for your great PR.
I don't think we can't get slack notifications when we do a werft run this way, right? I want to eventually run integration tests daily and receive notifications of them via slack.

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

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

Thank you @mads-hartmann , tested and works! 🚀

@mads-hartmann
Copy link
Contributor Author

mads-hartmann commented Sep 15, 2022

I don't think we can't get slack notifications when we do a werft run this way, right? I want to eventually run integration tests daily and receive notifications of them via slack.

Yeah that's right, currently it won't send Slack notifications. After this PR is merged I'll look into seeing how we can have the IDE and Workspace integration tests jobs use this script.

There are two approaches (at least)

  1. Have the IDE and Workspace integration test jobs use --with-integration-test=<...> when trigger the build job on their integration test branches.
  2. Have the IDE and Workspace integration test jobs use run.sh too

Either way, we'd have to figure out exactly how to trigger the Slack notifications. But let's take that after this PR is merged 🧡

@mads-hartmann mads-hartmann force-pushed the mads/fix-with-integration-tests branch from 0df8deb to 77a6c85 Compare September 16, 2022 08:59
@mads-hartmann
Copy link
Contributor Author

Rebase on main to remove conflict (an image version was bumped in run-integration-tests which this PR removes entirely)

switch (value) {
case null:
case undefined:
return "skip";
Copy link
Contributor

@liam-j-bennett liam-j-bennett Sep 16, 2022

Choose a reason for hiding this comment

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

Why do we default to skip here, but for empty-string/unknown we default to all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's mainly about how we want to interpret how people use (or not use) the with-integration-tests job attribute, especially when used in GH comments/PR descriptions where you can use /werft run with-integration-tests or if you just set the attribute in your PR description (/werft with-integration-tests - in both cases without specifying a value - which case the value is the empty string.

In the CLI it's less common but you could do werft job run github -a with-integration-tests="".

So if it is null/undefined it means they didn't use the with-integration-tests attribute at all - if it's the empty string they did use it, but just didn't specify a value - I decided to interpret that as "they want to run all the tests"

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be useful to add this explanation as a comment in the code, or do you think it is overkill?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a log line of

werft.log(sliceID, "with-integration-tests was not set - will use 'skip'");

As I think that will

  • Capture the essence of the description above. Each of the three cases (not set, set to empty, set to unknown value) now have a log line that describe things a bit
  • This might be useful as it will help people know if they made a typo in the attribute, e.g. "with-integration-test" (missing s)

Copy link
Contributor

@liam-j-bennett liam-j-bennett left a comment

Choose a reason for hiding this comment

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

🚀

Copy link
Contributor

@iQQBot iQQBot left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@iQQBot
Copy link
Contributor

iQQBot commented Sep 16, 2022

For the IDE we currently have two completely separate sets (vscode, jetbrains) of integration tests that are not really connected to each other, it would be nice if they could be separated, but that can be something for later, thank you very much for your work! 🎉

@iQQBot iQQBot removed the request for review from mustard-mh September 16, 2022 15:03
@roboquat roboquat merged commit d9fe8fa into main Sep 19, 2022
@roboquat roboquat deleted the mads/fix-with-integration-tests branch September 19, 2022 09:27
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.

7 participants