Skip to content

Commit

Permalink
APL-2320 Move Suse install script tests to new e2e (#21205)
Browse files Browse the repository at this point in the history
APL-2320 Move Suse install script tests to new e2e
  • Loading branch information
KevinFairise2 authored Dec 1, 2023
1 parent 8256c73 commit c58efae
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .gitlab/new-e2e_common/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@
!reference [.on_kitchen_tests_a7] #TODO: Change when migration is complete to another name without 'kitchen'
variables:
AGENT_MAJOR_VERSION: 7

.new-e2e_install_script:
variables:
TARGETS: ./tests/agent-platform/install-script
TEAM: agent-platform
EXTRA_PARAMS: --osversion $E2E_OSVERS --platform $E2E_PLATFORM --cws-supported-osversion $E2E_CWS_SUPPORTED_OSVERS --major-version $AGENT_MAJOR_VERSION --arch $E2E_ARCH --flavor $FLAVOR
1 change: 1 addition & 0 deletions .gitlab/new-e2e_testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ include:
- /.gitlab/new-e2e_testing/debian.yml
- /.gitlab/new-e2e_testing/ubuntu.yml
- /.gitlab/new-e2e_testing/amazonlinux.yml
- /.gitlab/new-e2e_testing/suse.yml
96 changes: 96 additions & 0 deletions .gitlab/new-e2e_testing/suse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

.new-e2e_os_suse:
variables:
E2E_PLATFORM: suse

.new-e2e_install_script:
variables:
TARGETS: ./tests/agent-platform/install-script
TEAM: agent-platform
EXTRA_PARAMS: --osversion $E2E_OSVERS --platform $E2E_PLATFORM --cws-supported-osversion $E2E_CWS_SUPPORTED_OSVERS --major-version $AGENT_MAJOR_VERSION --arch $E2E_ARCH --flavor $FLAVOR

.new-e2e_suse_a6_x86_64:
variables:
E2E_ARCH: x86_64
E2E_OSVERS: "sles-12,sles-15"
E2E_CWS_SUPPORTED_OSVERS: "sles-12,sles-15"
E2E_BRANCH_OSVERS: "sles-15"
needs: ["deploy_deb_testing-a6_x64"]

.new-e2e_suse_a7_x86_64:
variables:
E2E_ARCH: x86_64
E2E_OSVERS: "sles-12,sles-15"
E2E_CWS_SUPPORTED_OSVERS: "sles-12,sles-15"
E2E_BRANCH_OSVERS: "sles-15"
needs: ["deploy_deb_testing-a7_x64"]

.new-e2e_suse_a7_arm64:
variables:
E2E_ARCH: arm64
E2E_OSVERS: "sles-15"
E2E_CWS_SUPPORTED_OSVERS: "sles-15"
E2E_BRANCH_OSVERS: "sles-15"
needs: ["deploy_deb_testing-a7_arm64"]

new-e2e-agent-platform-install-script-suse-a6-x86_64:
stage: kitchen_testing
extends:
- .new_e2e_template
- .new-e2e_install_script
- .new-e2e_os_suse
- .new-e2e_suse_a6_x86_64
- .new-e2e_agent_a6
variables:
FLAVOR: datadog-agent

new-e2e-agent-platform-install-script-suse-a7-x86_64:
stage: kitchen_testing
extends:
- .new_e2e_template
- .new-e2e_install_script
- .new-e2e_os_suse
- .new-e2e_suse_a7_x86_64
- .new-e2e_agent_a7
rules:
!reference [.on_default_new-e2e_tests_a7]
variables:
FLAVOR: datadog-agent

new-e2e-agent-platform-install-script-suse-a7-arm64:
stage: kitchen_testing
extends:
- .new_e2e_template
- .new-e2e_install_script
- .new-e2e_os_suse
- .new-e2e_suse_a7_arm64
- .new-e2e_agent_a7
rules:
!reference [.on_all_new-e2e_tests_a7]
variables:
FLAVOR: datadog-agent

new-e2e-agent-platform-install-script-suse-iot-agent-a7-x86_64:
stage: kitchen_testing
extends:
- .new_e2e_template
- .new-e2e_install_script
- .new-e2e_os_suse
- .new-e2e_suse_a7_x86_64
- .new-e2e_agent_a7
rules:
!reference [.on_default_new-e2e_tests_a7]
variables:
FLAVOR: datadog-iot-agent

new-e2e-agent-platform-install-script-suse-dogstatsd-a7-x86_64:
stage: kitchen_testing
extends:
- .new_e2e_template
- .new-e2e_install_script
- .new-e2e_os_suse
- .new-e2e_suse_a7_x86_64
- .new-e2e_agent_a7
variables:
FLAVOR: datadog-dogstatsd

23 changes: 23 additions & 0 deletions test/new-e2e/tests/agent-platform/common/pkg-manager/zypper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

package pkgmanager

import "github.com/DataDog/datadog-agent/test/new-e2e/pkg/utils/e2e/client"

// ZypperPackageManager is a package manager for zypper
type ZypperPackageManager struct {
vmClient client.VM
}

// NewZypperPackageManager return zypper package manager
func NewZypperPackageManager(vmClient client.VM) *ZypperPackageManager {
return &ZypperPackageManager{vmClient: vmClient}
}

// Remove executes remove command from zypper
func (s *ZypperPackageManager) Remove(pkg string) (string, error) {
return s.vmClient.ExecuteWithError("sudo zypper remove -y " + pkg)
}
5 changes: 5 additions & 0 deletions test/new-e2e/tests/agent-platform/common/test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func getPackageManager(vmClient e2eClient.VM) PackageManager {
if _, err := vmClient.ExecuteWithError("command -v yum"); err == nil {
return pkgmanager.NewYumPackageManager(vmClient)
}

if _, err := vmClient.ExecuteWithError("command -v zypper"); err == nil {
return pkgmanager.NewZypperPackageManager(vmClient)
}

return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,31 @@ func TestInstallScript(t *testing.T) {
cwsSupportedOsVersionList := strings.Split(*cwsSupportedOsVersion, ",")

fmt.Println("Parsed platform json file: ", platformJSON)

vmOpts := []ec2params.Option{}
for _, osVers := range osVersions {
osVers := osVers

if platformJSON[*platform][*architecture][osVers] == "" {
// Fail if the image is not defined instead of silently running with default Ubuntu AMI
t.Fatalf("No image found for %s %s %s", *platform, *architecture, osVers)
}

cwsSupported := false
for _, cwsSupportedOs := range cwsSupportedOsVersionList {
if cwsSupportedOs == osVers {
cwsSupported = true
}
}

vmOpts = append(vmOpts, ec2params.WithImageName(platformJSON[*platform][*architecture][osVers], archMapping[*architecture], osMapping[*platform]))
if instanceType, ok := os.LookupEnv("E2E_OVERRIDE_INSTANCE_TYPE"); ok {
vmOpts = append(vmOpts, ec2params.WithInstanceType(instanceType))
}
t.Run(fmt.Sprintf("test install script on %s %s %s agent %s", osVers, *architecture, *flavor, *majorVersion), func(tt *testing.T) {
tt.Parallel()
fmt.Printf("Testing %s", osVers)
e2e.Run(tt, &installScriptSuite{cwsSupported: cwsSupported}, e2e.EC2VMStackDef(ec2params.WithImageName(platformJSON[*platform][*architecture][osVers], archMapping[*architecture], osMapping[*platform])), params.WithStackName(fmt.Sprintf("install-script-test-%v-%v-%s-%s-%v", os.Getenv("CI_PIPELINE_ID"), osVers, *architecture, *flavor, *majorVersion)))
e2e.Run(tt, &installScriptSuite{cwsSupported: cwsSupported}, e2e.EC2VMStackDef(vmOpts...), params.WithStackName(fmt.Sprintf("install-script-test-%v-%v-%s-%s-%v", os.Getenv("CI_PIPELINE_ID"), osVers, *architecture, *flavor, *majorVersion)))
})
}
}
Expand Down
9 changes: 9 additions & 0 deletions test/new-e2e/tests/agent-platform/platforms/platforms.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,14 @@
"amazonlinux2022-5-15": "ami-0a8495f6303122235",
"amazonlinux2023": "ami-08fc6fb8ad2e794bb"
}
},
"suse": {
"x86_64": {
"sles-12": "ami-09e1f60648b4fb117",
"sles-15": "ami-08f3662e2d5b3989a"
},
"arm64": {
"sles-15": "ami-02f7663f03ca92749"
}
}
}

0 comments on commit c58efae

Please sign in to comment.