From 1682be0f9db782e5277e3827d6fd2417974fa239 Mon Sep 17 00:00:00 2001 From: "Lee E. Hinman" Date: Wed, 3 Apr 2024 12:32:17 -0500 Subject: [PATCH] remove sles --- pkg/testing/ogc/supported.go | 13 ---- pkg/testing/runner/sles.go | 112 --------------------------- pkg/testing/runner/supported.go | 12 --- pkg/testing/runner/supported_test.go | 14 ++-- 4 files changed, 7 insertions(+), 144 deletions(-) delete mode 100644 pkg/testing/runner/sles.go diff --git a/pkg/testing/ogc/supported.go b/pkg/testing/ogc/supported.go index ec4074dc0e2..96bbc5cf520 100644 --- a/pkg/testing/ogc/supported.go +++ b/pkg/testing/ogc/supported.go @@ -72,19 +72,6 @@ var ogcSupported = []LayoutOS{ Username: "ubuntu", RemotePath: "/home/ubuntu/agent", }, - { - OS: define.OS{ - Type: define.Linux, - Arch: define.AMD64, - Distro: runner.Sles, - Version: "15", - }, - Provider: Google, - InstanceSize: "e2-standard-2", // 2 amd64 cpus - RunsOn: "sles-15", - Username: "sles", - RemotePath: "/home/sles/agent", - }, { OS: define.OS{ Type: define.Linux, diff --git a/pkg/testing/runner/sles.go b/pkg/testing/runner/sles.go deleted file mode 100644 index ac634f6c50a..00000000000 --- a/pkg/testing/runner/sles.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package runner - -import ( - "context" - "fmt" - "path" - "strings" - "time" - - "github.com/elastic/elastic-agent/pkg/testing/define" -) - -// SlesRunner is a handler for running tests on SUSE Linux Enterpriser Server -type SlesRunner struct{} - -// Prepare configures the host for running the test -func (SlesRunner) Prepare(ctx context.Context, sshClient SSHClient, logger Logger, arch string, goVersion string) error { - logger.Logf("install devel_basis") - zypperCtx, zypperCancel := context.WithTimeout(ctx, 20*time.Minute) - defer zypperCancel() - stdOut, errOut, err := sshClient.ExecWithRetry(zypperCtx, "sudo", []string{"zypper", "install", "-y ", "-t", "pattern", "devel_basis"}, 15*time.Second) - if err != nil { - return fmt.Errorf("failed to run zypper install devel_basis: %w (stdout: %s, stderr: %s)", err, stdOut, errOut) - } - - // install golang - logger.Logf("Install golang %s (%s)", goVersion, arch) - goCtx, goCancel := context.WithTimeout(ctx, 20*time.Minute) - defer goCancel() - downloadURL := fmt.Sprintf("https://go.dev/dl/go%s.linux-%s.tar.gz", goVersion, arch) - filename := path.Base(downloadURL) - stdOut, errOut, err = sshClient.Exec(goCtx, "curl", []string{"-Ls", downloadURL, "--output", filename}, nil) - if err != nil { - return fmt.Errorf("failed to download go from %s with curl: %w (stdout: %s, stderr: %s)", downloadURL, err, stdOut, errOut) - } - stdOut, errOut, err = sshClient.Exec(goCtx, "sudo", []string{"tar", "-C", "/usr/local", "-xzf", filename}, nil) - if err != nil { - return fmt.Errorf("failed to extract go to /usr/local with tar: %w (stdout: %s, stderr: %s)", err, stdOut, errOut) - } - stdOut, errOut, err = sshClient.Exec(goCtx, "sudo", []string{"ln", "-s", "/usr/local/go/bin/go", "/usr/bin/go"}, nil) - if err != nil { - return fmt.Errorf("failed to symlink /usr/local/go/bin/go to /usr/bin/go: %w (stdout: %s, stderr: %s)", err, stdOut, errOut) - } - stdOut, errOut, err = sshClient.Exec(goCtx, "sudo", []string{"ln", "-s", "/usr/local/go/bin/gofmt", "/usr/bin/gofmt"}, nil) - if err != nil { - return fmt.Errorf("failed to symlink /usr/local/go/bin/gofmt to /usr/bin/gofmt: %w (stdout: %s, stderr: %s)", err, stdOut, errOut) - } - - return nil -} - -// Copy places the required files on the host -func (SlesRunner) Copy(ctx context.Context, sshClient SSHClient, logger Logger, repoArchive string, builds []Build) error { - return linuxCopy(ctx, sshClient, logger, repoArchive, builds) -} - -// Run the test -func (SlesRunner) Run(ctx context.Context, verbose bool, sshClient SSHClient, logger Logger, agentVersion string, prefix string, batch define.Batch, env map[string]string) (OSRunnerResult, error) { - var tests []string - for _, pkg := range batch.Tests { - for _, test := range pkg.Tests { - tests = append(tests, fmt.Sprintf("%s:%s", pkg.Name, test.Name)) - } - } - var sudoTests []string - for _, pkg := range batch.SudoTests { - for _, test := range pkg.Tests { - sudoTests = append(sudoTests, fmt.Sprintf("%s:%s", pkg.Name, test.Name)) - } - } - - logArg := "" - if verbose { - logArg = "-v" - } - var result OSRunnerResult - if len(tests) > 0 { - vars := fmt.Sprintf(`GOPATH="$HOME/go" PATH="$HOME/go/bin:$PATH" AGENT_VERSION="%s" TEST_DEFINE_PREFIX="%s" TEST_DEFINE_TESTS="%s"`, agentVersion, prefix, strings.Join(tests, ",")) - vars = extendVars(vars, env) - - script := fmt.Sprintf(`cd agent && %s ~/go/bin/mage %s integration:testOnRemote`, vars, logArg) - results, err := runTests(ctx, logger, "non-sudo", prefix, script, sshClient, batch.Tests) - if err != nil { - return OSRunnerResult{}, fmt.Errorf("error running non-sudo tests: %w", err) - } - result.Packages = results - } - - if len(sudoTests) > 0 { - prefix := fmt.Sprintf("%s-sudo", prefix) - vars := fmt.Sprintf(`GOPATH="$HOME/go" PATH="$HOME/go/bin:$PATH:/usr/sbin" AGENT_VERSION="%s" TEST_DEFINE_PREFIX="%s" TEST_DEFINE_TESTS="%s"`, agentVersion, prefix, strings.Join(sudoTests, ",")) - vars = extendVars(vars, env) - script := fmt.Sprintf(`cd agent && sudo %s ~/go/bin/mage %s integration:testOnRemote`, vars, logArg) - - results, err := runTests(ctx, logger, "sudo", prefix, script, sshClient, batch.SudoTests) - if err != nil { - return OSRunnerResult{}, fmt.Errorf("error running sudo tests: %w", err) - } - result.SudoPackages = results - } - - return result, nil -} - -// Diagnostics gathers any diagnostics from the host. -func (SlesRunner) Diagnostics(ctx context.Context, sshClient SSHClient, logger Logger, destination string) error { - return linuxDiagnostics(ctx, sshClient, logger, destination) -} diff --git a/pkg/testing/runner/supported.go b/pkg/testing/runner/supported.go index b86acfd2c19..c872066167c 100644 --- a/pkg/testing/runner/supported.go +++ b/pkg/testing/runner/supported.go @@ -13,7 +13,6 @@ import ( const ( Rhel = "rhel" - Sles = "sles" // Ubuntu is a Linux distro. Ubuntu = "ubuntu" ) @@ -82,16 +81,6 @@ var ( }, Runner: RhelRunner{}, } - // SlesAMD64_15 - SUSE Linux Enterprise Server (amd64) 15 - SlesAMD64_15 = SupportedOS{ - OS: define.OS{ - Type: define.Linux, - Arch: define.AMD64, - Distro: Sles, - Version: "15", - }, - Runner: SlesRunner{}, - } // WindowsAMD64_2022 - Windows (amd64) Server 2022 WindowsAMD64_2022 = SupportedOS{ OS: define.OS{ @@ -162,7 +151,6 @@ var supported = []SupportedOS{ UbuntuARM64_2204, UbuntuARM64_2004, RhelAMD64_8, - SlesAMD64_15, WindowsAMD64_2022, WindowsAMD64_2022_Core, WindowsAMD64_2019, diff --git a/pkg/testing/runner/supported_test.go b/pkg/testing/runner/supported_test.go index d7a29dda5bd..84ca2516a60 100644 --- a/pkg/testing/runner/supported_test.go +++ b/pkg/testing/runner/supported_test.go @@ -79,26 +79,26 @@ func TestGetSupported(t *testing.T) { }, }, { - Name: "sles/not specific", + Name: "rhel/not specific", OS: define.OS{ Type: define.Linux, Arch: define.AMD64, - Distro: Sles, + Distro: Rhel, }, Results: []SupportedOS{ - SlesAMD64_15, + RhelAMD64_8, }, }, { - Name: "sles/specific", + Name: "rhel/specific", OS: define.OS{ Type: define.Linux, Arch: define.AMD64, - Distro: Sles, - Version: "15", + Distro: Rhel, + Version: "8", }, Results: []SupportedOS{ - SlesAMD64_15, + RhelAMD64_8, }, }, }