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

Add breakdown of tests output for integration testing framework #5825

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Oct 18, 2024

What does this PR do?

Adds a mage integration:breakdown and mage integration:breakdownMatrix targets that write an intermediate output of the list of operating systems and which tests need to run on each version of those operating systems.

Why is it important?

Allows an easy way to see which tests run on which os/arch/distro/version combinations, along with if a stack is required and if the test needs the stack or not.

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

None

How to test this PR locally

mage integration:breakdown

or

mage integration:breakdownMatrix

Enable output

- name: fqdn-sudo
  os:
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
  require_sudo: true
  tests:
    - TestFQDN
- name: kubernetes
  os:
    - type: kubernetes
      arch: amd64
      version: 1.31.0
      docker_variant: service
    - type: kubernetes
      arch: arm64
      version: 1.31.0
      docker_variant: service
    - type: kubernetes
      arch: amd64
      version: 1.31.0
      docker_variant: basic
    - type: kubernetes
      arch: arm64
      version: 1.31.0
      docker_variant: basic
    - type: kubernetes
      arch: amd64
      version: 1.31.0
      docker_variant: wolfi
    - type: kubernetes
      arch: arm64
      version: 1.31.0
      docker_variant: wolfi
    - type: kubernetes
      arch: amd64
      version: 1.31.0
      docker_variant: ubi
    - type: kubernetes
      arch: arm64
      version: 1.31.0
      docker_variant: ubi
    - type: kubernetes
      arch: amd64
      version: 1.31.0
      docker_variant: complete
    - type: kubernetes
      arch: arm64
      version: 1.31.0
      docker_variant: complete
    - type: kubernetes
      arch: amd64
      version: 1.31.0
      docker_variant: complete-wolfi
    - type: kubernetes
      arch: arm64
      version: 1.31.0
      docker_variant: complete-wolfi
  require_sudo: false
  tests: []
- name: deb-sudo
  os:
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
  require_sudo: true
  tests:
    - TestDebLogIngestFleetManaged
    - TestDebFleetUpgrade
- name: rpm-sudo
  os:
    - type: linux
      arch: amd64
      version: "8"
      distro: rhel
    - type: linux
      arch: arm64
      version: unknown
      distro: rhel
  require_sudo: true
  tests:
    - TestRpmLogIngestFleetManaged
    - TestRpmFleetUpgrade
- name: fleet-sudo
  os:
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
    - type: windows
      arch: amd64
      version: "2022"
    - type: darwin
      arch: amd64
      version: unknown
      distro: unknown
    - type: darwin
      arch: arm64
      version: unknown
      distro: unknown
  require_sudo: true
  tests:
    - TestLongRunningAgentForLeaks
    - TestDelayEnroll
    - TestDelayEnrollUnprivileged
    - TestRedactFleetSecretPathsDiagnostics
    - TestInstallAndCLIUninstallWithEndpointSecurity
    - TestInstallAndUnenrollWithEndpointSecurity
    - TestInstallWithEndpointSecurityAndRemoveEndpointIntegration
    - TestEndpointSecurityNonDefaultBasePath
    - TestEndpointSecurityUnprivileged
    - TestEndpointSecurityCannotSwitchToUnprivileged
    - TestEndpointLogsAreCollectedInDiagnostics
    - TestForceInstallOverProtectedPolicy
    - TestInspect
    - TestSetLogLevelFleetManaged
    - TestLogIngestionFleetManaged
    - TestMetricsMonitoringCorrectBinaries
    - TestEndpointAgentServiceMonitoring
    - TestMonitoringPreserveTextConfig
    - TestMonitoringLivenessReloadable
    - TestComponentBuildHashInDiagnostics
    - TestProxyURL
    - TestFleetManagedUpgradeUnprivileged
- name: default
  os:
    - type: darwin
      arch: amd64
      version: unknown
      distro: unknown
    - type: darwin
      arch: arm64
      version: unknown
      distro: unknown
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
    - type: windows
      arch: amd64
      version: "2022"
  require_sudo: false
  tests:
    - TestInstallWithoutBasePath
    - TestInstallWithBasePath
    - TestInstallPrivilegedWithoutBasePath
    - TestInstallPrivilegedWithBasePath
    - TestInstallUninstallAudit
    - TestRepeatedInstallUninstall
    - TestSwitchPrivilegedWithoutBasePath
    - TestSwitchPrivilegedWithBasePath
    - TestSwitchUnprivilegedWithoutBasePath
    - TestSwitchUnprivilegedWithBasePath
    - TestBeatsServerless
- name: container-sudo
  os:
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
  require_sudo: true
  tests:
    - TestContainerCMD
    - TestContainerCMDWithAVeryLongStatePath
    - TestContainerCMDEventToStderr
    - TestEventLogOutputConfiguredViaFleet
- name: fleet-privileged-sudo
  os:
    - type: darwin
      arch: amd64
      version: unknown
      distro: unknown
    - type: darwin
      arch: arm64
      version: unknown
      distro: unknown
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
    - type: windows
      arch: amd64
      version: "2022"
  require_sudo: true
  tests:
    - TestInstallFleetServerBootstrap
    - TestFleetManagedUpgradePrivileged
- name: upgrade-sudo
  os:
    - type: darwin
      arch: amd64
      version: unknown
      distro: unknown
    - type: darwin
      arch: arm64
      version: unknown
      distro: unknown
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
    - type: windows
      arch: amd64
      version: "2022"
  require_sudo: true
  tests:
    - TestUpgradeBrokenPackageVersion
    - TestStandaloneUpgradeWithGPGFallback
    - TestStandaloneUpgradeWithGPGFallbackOneRemoteFailing
    - TestStandaloneUpgradeRollback
    - TestStandaloneUpgradeRollbackOnRestarts
    - TestStandaloneUpgradeFailsWhenUpgradeIsInProgress
    - TestStandaloneUpgradeRetryDownload
    - TestStandaloneUpgradeSameCommit
    - TestStandaloneUpgrade
    - TestStandaloneUpgradeUninstallKillWatcher
- name: fleet-airgapped-sudo
  os:
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
  require_sudo: true
  tests:
    - TestFleetAirGappedUpgradeUnprivileged
- name: fleet-airgapped-privileged-sudo
  os:
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
  require_sudo: true
  tests:
    - TestFleetAirGappedUpgradePrivileged
- name: fleet-upgrade-to-pr-build-sudo
  os:
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
  require_sudo: true
  tests:
    - TestFleetUpgradeToPRBuild
- name: default-sudo
  os:
    - type: darwin
      arch: amd64
      version: unknown
      distro: unknown
    - type: darwin
      arch: arm64
      version: unknown
      distro: unknown
    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu
    - type: linux
      arch: arm64
      version: "24.04"
      distro: ubuntu
    - type: windows
      arch: amd64
      version: "2022"
  require_sudo: true
  tests:
    - TestInstallWithoutBasePath
    - TestInstallWithBasePath
    - TestInstallPrivilegedWithoutBasePath
    - TestInstallPrivilegedWithBasePath
    - TestInstallUninstallAudit
    - TestRepeatedInstallUninstall
    - TestSwitchPrivilegedWithoutBasePath
    - TestSwitchPrivilegedWithBasePath
    - TestSwitchUnprivilegedWithoutBasePath
    - TestSwitchUnprivilegedWithBasePath
    - TestBeatsServerless

@blakerouse blakerouse added Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog labels Oct 18, 2024
@blakerouse blakerouse self-assigned this Oct 18, 2024
@blakerouse blakerouse requested a review from a team as a code owner October 18, 2024 15:26
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

Copy link
Contributor

mergify bot commented Oct 18, 2024

This pull request does not have a backport label. Could you fix it @blakerouse? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label to automatically backport to the 8./d branch. /d is the digit

Copy link
Contributor

mergify bot commented Oct 18, 2024

backport-v8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Oct 18, 2024
@ycombinator ycombinator requested review from pazone and removed request for andrzej-stencel October 18, 2024 21:05
@pchila
Copy link
Member

pchila commented Oct 21, 2024

I understand that what you added in the description of the PR is the output of the new mage target, but maybe we can discuss the structure of the output a bit since there are bits that may benefit from further polishing

  1. Simple linux test description:
  - id: linux-amd64-ubuntu-2404-default
    os:
      type: linux
      arch: amd64
     version: "24.04"
      distro: ubuntu
    batch:
      group: default
      stack:
          version: 9.0.0-SNAPSHOT
      tests:
          - name: github.com/elastic/elastic-agent/testing/integration
            tests:
              - name: TestAPMConfig
                stack: true
              - name: TestDiagnosticsOptionalValues
                stack: false
             ...
              - name: TestPackageVersion
                stack: false
      sudo_tests:
          - name: github.com/elastic/elastic-agent/testing/integration
            tests:
              - name: TestBeatsServerless
                stack: true
              - name: TestInstallWithoutBasePath
                stack: false
             ...
              - name: TestSwitchUnprivilegedWithBasePath
                stack: false
  • Is it possible to extract OS type and arch to a platform layer that groups all the tests for a given platform? Similar to the concept we already use in magefile ?
  • Can we change the distro attributes of OS with just name (distro is very linux-specific attribute and at the end of the day is just the name of a specific linux OS we require)? Using name may open the way of specifying different windows variants should we need to...
  • Do we always require ubuntu in all non rhel/deb tests ? I assume that for most of the tests we don't care which linux distribution is used as long as we can install elastic-agent using the .tar.gz archive
  • sudo_test vs test: shouldn't this be a boolean value if a test requires sudo to be run? (such tests seem to be the majority)
  1. K8s test description:
  - id: kubernetes-amd64-1310-basic-kubernetes
  os:
    type: kubernetes
    arch: amd64
    version: 1.31.0
    docker_variant: basic
  batch:
    group: kubernetes
    stack:
        version: 9.0.0-SNAPSHOT
    tests:
        - name: github.com/elastic/elastic-agent/testing/integration
          tests:
          

How is docker_variant an attribute of OS in this case? Isn't it just a specific elastic-agent artifact we want to test? Maybe we need to formalize what artifact a given test requires?
Having an OS with type: kubernetes also looks a bit strange, maybe we should move the kubernetes in another package with different definitions that will test only on k8s clusters?

I know that the proposed format is what the integration framework currently use internally but his may be an opportunity to clean up the structure a bit and I hope we can work a bit on that

@blakerouse
Copy link
Contributor Author

Every question you proposed is possible, just need a format to be designed that you deam acceptable to reflect your questions. Based on the way your questions are worded you have a design in-mind, please propose it.

The current format is the format I designed for the internal representation of the testing framework, it makes sense to me and to me is very easy to understand. I don't think me spending time on designing a different one is going to provide the result you are looking for, as you already have one in mind.

There is also another format that is a layer up that doesn't add the ubuntu and OS version information unless the test specifically requires it. This layer is after items have been batched together and placed on a target, but that allows the matrix: true to occur.

Please provide a recommended layout that you find more appropriate and I am sure this output can be transformed into that output.

@ycombinator
Copy link
Contributor

@pazone since your code will ultimately be consuming the output being produced by the code in this PR, please post the ideal output that you'd like to see. You can use the output posted in this PR's description as a starting point and take a look at the discussion in the last couple of comments as well for any ideas.

Once we have your desired output, that will serve as the interface between the integration testing framework and your BK pipeline generator code, and @blakerouse can make tweaks to the code in this PR as needed to produce that output.

@pazone
Copy link
Contributor

pazone commented Oct 23, 2024

The ideal output would be
mage -v integration:breakdown "fleet" "sudo" and |-separated list of the tests like:

TestAPMConfig|TestAnotherThing

It will be consumed by go test

The OS/ARCH/Version can be determined automatically because we run it on the target VM. This allows us to use matrix step representation.

If the breakdown is also needed for other purposes, we can use a less ideal solution:
Create another target that will utilize this yaml.
Something like this:

mage integration:breakdown | mage integration:gettests fleet sudo ... 

And the gettests target outputs the | separated list of tests, required for the specified group, os, and sudo/non-sudo glag.

Anyway eventually we need to have this test list

@ycombinator
Copy link
Contributor

@pazone We need to agree on the exact output as it will serve as the contract between the integration testing framework and your BK pipeline generator code. Could you please provide a complete sample of the ideal output, similar to what @blakerouse has provided in this PR's description? Feel free to use that as a starting point and tweak it. This way, there will be no ambiguity about the contract. Thanks.

@pazone
Copy link
Contributor

pazone commented Oct 23, 2024

@ycombinator The |-separated list of tests is required for gotest. That's what we need.
Input parameters: group and sudo/non-sudo flag
Output:

TestAPMConfig|TestAnotherThing|...

^^^ That's the contract.

I can bring more context, If the tests filtering isn't clear enough.

@blakerouse
Copy link
Contributor Author

@ycombinator @pazone I have updated this PR to match the discussed format during the meeting. I have updated the output in the PR description to show the updated output.

Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@pazone
Copy link
Contributor

pazone commented Oct 28, 2024

@blakerouse @ycombinator I'm now creating a filter for the tests using this breakdown. Thanks

@pazone
Copy link
Contributor

pazone commented Oct 28, 2024

Do I understand correctly that container-sudo runs on Unubtu VMs, not containers?

@ycombinator
Copy link
Contributor

Do I understand correctly that container-sudo runs on Unubtu VMs, not containers?

Yes, your understanding is correct. The tests in that group are all running elastic-agent container which is the entrypoint command when Elastic Agent is run inside a container.

@pazone
Copy link
Contributor

pazone commented Oct 29, 2024

@blakerouse @ycombinator I need help. I'm having problems getting current OS info without introducing additional packages. Do we have anything already implemented? I need the current OS info in this format for filtering:

- type: linux
   arch: amd64
   version: "24.04"
   distro: ubuntu

@ycombinator
Copy link
Contributor

I need the current OS info in this format for filtering:

- type: linux
   arch: amd64
   version: "24.04"
   distro: ubuntu

@pazone The format you posted looks identical to the format in this PR's (updated) description:

    - type: linux
      arch: amd64
      version: "24.04"
      distro: ubuntu

So I'm not sure what you're asking for. 🤔

@pazone
Copy link
Contributor

pazone commented Oct 30, 2024

@ycombinator I'm trying to make it work as described here: #5825 (comment). To do that, I have to determine current OS facts:

  • distro
  • version
  • type
  • arch

It's not trivial to implement this without using third-party packages. The question is: Have we already implemented anything similar? Maybe I can reuse something?

@pazone
Copy link
Contributor

pazone commented Oct 30, 2024

Ok, found this: https://github.com/elastic/go-sysinfo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-8.x Automated backport to the 8.x branch with mergify skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants