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

[8.16](backport #5900) Introduce filter by group and dry-run for integration tests #6398

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Dec 19, 2024

What does this PR do?

This PR adds a TestMain() to the testing/integration package to allow passing some command-line arguments when running integration tests using go test:

  • -integration.groups allows to specify a comma-separated list of groups to filter on
  • -integration.dry-run will validate define constraints but will skip the real tests that contain define directives and add a placeholder <Test name>/dry-run which will pass if all the define checks pass

The groups flag allows for a simple way of selecting a subset of tests (for either real running or dry-runs)
The sudo flag allows to filter tests based on their sudo requirements (if those need to run as root/administrator or not)
The dry-run argument allows for quick execution when experimenting with group filtering (making sure that what would be executed matches expectations)

Why is it important?

Running by groups should simplify initial implementation of running Integration tests on CI

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in ./changelog/fragments using the changelog tool
  • I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

go test -tags integration github.com/elastic/elastic-agent/testing/integration -v -args -integration.groups="fleet,default" -integration.dry-run=true

(since it's a dry-run it won't actually run the tests)

=== RUN   TestLongRunningAgentForLeaks
    define.go:170: not running as root and test requires root
--- SKIP: TestLongRunningAgentForLeaks (0.00s)
=== RUN   TestAPMConfig
=== RUN   TestAPMConfig/dry-run
    define_flags.go:52: Test dry-run successful
=== NAME  TestAPMConfig
    define_flags.go:54: Skipped because dry-run mode has been specified.
--- SKIP: TestAPMConfig (0.00s)
    --- PASS: TestAPMConfig/dry-run (0.00s)
=== RUN   TestBeatsServerless
    define.go:170: not running as root and test requires root
--- SKIP: TestBeatsServerless (0.00s)
=== RUN   TestContainerCMD
    define.go:149: group container not found in [fleet default]. Skipping
--- SKIP: TestContainerCMD (0.00s)
=== RUN   TestContainerCMDWithAVeryLongStatePath
    define.go:149: group container not found in [fleet default]. Skipping
--- SKIP: TestContainerCMDWithAVeryLongStatePath (0.00s)

... a long list of tests is omitted here ...

=== RUN   TestStandaloneUpgradeFailsWhenUpgradeIsInProgress
    define.go:149: group upgrade not found in [fleet default]. Skipping
--- SKIP: TestStandaloneUpgradeFailsWhenUpgradeIsInProgress (0.00s)
=== RUN   TestStandaloneUpgradeRetryDownload
    define.go:149: group upgrade not found in [fleet default]. Skipping
--- SKIP: TestStandaloneUpgradeRetryDownload (0.00s)
=== RUN   TestStandaloneUpgradeSameCommit
    define.go:149: group upgrade not found in [fleet default]. Skipping
--- SKIP: TestStandaloneUpgradeSameCommit (0.00s)
=== RUN   TestStandaloneUpgrade
    define.go:149: group upgrade not found in [fleet default]. Skipping
--- SKIP: TestStandaloneUpgrade (0.00s)
=== RUN   TestStandaloneUpgradeUninstallKillWatcher
    define.go:149: group upgrade not found in [fleet default]. Skipping
--- SKIP: TestStandaloneUpgradeUninstallKillWatcher (0.00s)
PASS
ok      github.com/elastic/elastic-agent/testing/integration    1.123s

Adding a sudo filter for running only test that do not require sudo:

sudo go test -tags integration github.com/elastic/elastic-agent/testing/integration -v -args -integration.groups="fleet,default" -integration.dry-run=true -integration.sudo=true

=== RUN   TestLongRunningAgentForLeaks
=== RUN   TestLongRunningAgentForLeaks/dry-run
    define_flags.go:85: Test dry-run successful
=== NAME  TestLongRunningAgentForLeaks
    define_flags.go:87: Skipped because dry-run mode has been specified.
--- SKIP: TestLongRunningAgentForLeaks (0.00s)
    --- PASS: TestLongRunningAgentForLeaks/dry-run (0.00s)
=== RUN   TestAPMConfig
    define.go:154: sudo requirement false not matching sudo filter true. Skipping
--- SKIP: TestAPMConfig (0.00s)
=== RUN   TestBeatsServerless
=== RUN   TestBeatsServerless/dry-run
    define_flags.go:85: Test dry-run successful
=== NAME  TestBeatsServerless
    define_flags.go:87: Skipped because dry-run mode has been specified.
--- SKIP: TestBeatsServerless (0.00s)
    --- PASS: TestBeatsServerless/dry-run (0.00s)
=== RUN   TestContainerCMD
    define.go:149: group container not found in groups filter [fleet default]. Skipping
--- SKIP: TestContainerCMD (0.00s)
... a long list of tests is omitted here ...
=== RUN   TestOtelFileProcessing
    define.go:154: sudo requirement false not matching sudo filter true. Skipping
--- SKIP: TestOtelFileProcessing (0.00s)
=== RUN   TestOtelLogsIngestion
    define.go:154: sudo requirement false not matching sudo filter true. Skipping
--- SKIP: TestOtelLogsIngestion (0.00s)
=== RUN   TestOtelAPMIngestion
    define.go:154: sudo requirement false not matching sudo filter true. Skipping
--- SKIP: TestOtelAPMIngestion (0.00s)
=== RUN   TestFileBeatReceiver
    define.go:154: sudo requirement false not matching sudo filter true. Skipping
--- SKIP: TestFileBeatReceiver (0.00s)
=== RUN   TestPackageVersion
    define.go:154: sudo requirement false not matching sudo filter true. Skipping
--- SKIP: TestPackageVersion (0.00s)
=== RUN   TestComponentBuildHashInDiagnostics
=== RUN   TestComponentBuildHashInDiagnostics/dry-run
    define_flags.go:85: Test dry-run successful
=== NAME  TestComponentBuildHashInDiagnostics
    define_flags.go:87: Skipped because dry-run mode has been specified.
--- SKIP: TestComponentBuildHashInDiagnostics (0.00s)
    --- PASS: TestComponentBuildHashInDiagnostics/dry-run (0.00s)
=== RUN   TestProxyURL
=== RUN   TestProxyURL/dry-run
    define_flags.go:85: Test dry-run successful
=== NAME  TestProxyURL
    define_flags.go:87: Skipped because dry-run mode has been specified.
--- SKIP: TestProxyURL (0.00s)
    --- PASS: TestProxyURL/dry-run (0.00s)
    ... a long list of tests is omitted here ...
PASS
ok      github.com/elastic/elastic-agent/testing/integration    1.094s

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

This is an automatic backport of pull request #5900 done by [Mergify](https://mergify.com).

* add filtering integration tests by group

* add dry-run integration test flag

* mage check for define.Require should skip TestMain

* Add define filter on sudo requirements

(cherry picked from commit 7978189)
@mergify mergify bot added the backport label Dec 19, 2024
@mergify mergify bot requested a review from a team as a code owner December 19, 2024 09:30
@mergify mergify bot requested review from blakerouse and andrzej-stencel and removed request for a team December 19, 2024 09:30
@mergify mergify bot assigned pchila Dec 19, 2024
Copy link

@pazone
Copy link
Contributor

pazone commented Dec 19, 2024

Tests are failing due to unrelated reasons with 8.16.3 and OGC failure

@pchila pchila requested review from pchila and removed request for blakerouse and andrzej-stencel December 19, 2024 14:28
@pchila
Copy link
Member

pchila commented Dec 19, 2024

8.16.3-SNAPSHOT should be available now, relaunched the k8s tests as well hoping that OGC behaves on this retry...

@pchila pchila merged commit 650adcf into 8.16 Dec 19, 2024
15 checks passed
@pchila pchila deleted the mergify/bp/8.16/pr-5900 branch December 19, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants