Skip to content

Commit a7034ef

Browse files
authored
Revert "add a DEB integration test (#4301)" (#4419)
This reverts commit 4fd31f1. The Serverless Beats Tests step in our daily builds started failing with: > Error: error running test: missing required Elastic Agent package builds for integration runner to execute: /tmp/beats-build/beats/x-pack/metricbeat/build/distributions/elastic-agent-8.14.0-SNAPSHOT-linux-x86_64.tar.gz, /tmp/beats-build/beats/x-pack/metricbeat/build/distributions/elastic-agent-8.14.0-SNAPSHOT-linux-x86_64.tar.gz.sha512, /tmp/beats-build/beats/x-pack/metricbeat/build/distributions/elastic-agent-8.14.0-SNAPSHOT-x86_64.rpm, /tmp/beats-build/beats/x-pack/metricbeat/build/distributions/elastic-agent-8.14.0-SNAPSHOT-x86_64.rpm.sha512, /tmp/beats-build/beats/x-pack/metricbeat/build/distributions/elastic-agent-8.14.0-SNAPSHOT-amd64.deb, /tmp/beats-build/beats/x-pack/metricbeat/build/distributions/elastic-agent-8.14.0-SNAPSHOT-amd64.deb.sha512 ~/builds/bk-agent-prod-gcp-1710406561496364062/elastic/elastic-agent The last successful build is https://buildkite.com/elastic/elastic-agent/builds/7707 The first failure is https://buildkite.com/elastic/elastic-agent/builds/7735 There were only 2 changes made between these, this change is one of them. Let's try to revert this first because it has the least impact.
1 parent b3e8275 commit a7034ef

19 files changed

+153
-446
lines changed

.buildkite/scripts/steps/integration_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ else
1919
OVERRIDE_TEST_AGENT_VERSION=""
2020
fi
2121
# PACKAGE
22-
AGENT_PACKAGE_VERSION="${OVERRIDE_AGENT_PACKAGE_VERSION}" DEV=true EXTERNAL=true SNAPSHOT=true PLATFORMS=linux/amd64,linux/arm64,windows/amd64 PACKAGES=tar.gz,zip,rpm,deb mage package
22+
AGENT_PACKAGE_VERSION="${OVERRIDE_AGENT_PACKAGE_VERSION}" DEV=true EXTERNAL=true SNAPSHOT=true PLATFORMS=linux/amd64,linux/arm64,windows/amd64 PACKAGES=tar.gz,zip mage package
2323

2424
# Run integration tests
2525
set +e

dev-tools/mage/pkg.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func Package() error {
3434
// platforms := updateWithDarwinUniversal(Platforms)
3535
platforms := Platforms
3636

37-
tasks := make(map[string][]interface{})
37+
var tasks []interface{}
3838
for _, target := range platforms {
3939
for _, pkg := range Packages {
4040
if pkg.OS != target.GOOS() || pkg.Arch != "" && pkg.Arch != target.Arch() {
@@ -94,15 +94,12 @@ func Package() error {
9494

9595
spec = spec.Evaluate()
9696

97-
tasks[target.GOOS()+"-"+target.Arch()] = append(tasks[target.GOOS()+"-"+target.Arch()], packageBuilder{target, spec, pkgType}.Build)
97+
tasks = append(tasks, packageBuilder{target, spec, pkgType}.Build)
9898
}
9999
}
100100
}
101101

102-
for k, v := range tasks {
103-
fmt.Printf(">> package: Building %s\n", k)
104-
Parallel(v...)
105-
}
102+
Parallel(tasks...)
106103
return nil
107104
}
108105

pkg/testing/define/define.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func runOrSkip(t *testing.T, req Requirements, local bool) *Info {
151151
panic("failed to get OS information")
152152
}
153153
if !req.runtimeAllowed(runtime.GOOS, runtime.GOARCH, osInfo.Version, osInfo.Platform) {
154-
t.Skipf("platform: %s, architecture: %s, version: %s, and distro: %s combination is not supported by test. required: %v", runtime.GOOS, runtime.GOARCH, osInfo.Version, osInfo.Platform, req.OS)
154+
t.Skip("platform, architecture, version, and distro not supported by test")
155155
return nil
156156
}
157157
namespace, err := getNamespace(t, local)

pkg/testing/fetch_test.go

-39
This file was deleted.

pkg/testing/fetcher.go

+9-19
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,19 @@ var (
3131
// packageArchMap provides a mapping for the endings of the builds of Elastic Agent based on the
3232
// operating system and architecture.
3333
var packageArchMap = map[string]string{
34-
"linux-amd64-targz": "linux-x86_64.tar.gz",
35-
"linux-amd64-deb": "amd64.deb",
36-
"linux-amd64-rpm": "x86_64.rpm",
37-
"linux-arm64-targz": "linux-arm64.tar.gz",
38-
"linux-arm64-deb": "arm64.deb",
39-
"linux-arm64-rpm": "aarch64.rpm",
40-
"windows-amd64-zip": "windows-x86_64.zip",
41-
"darwin-amd64-targz": "darwin-x86_64.tar.gz",
42-
"darwin-arm64-targz": "darwin-aarch64.tar.gz",
34+
"linux-amd64": "linux-x86_64.tar.gz",
35+
"linux-arm64": "linux-arm64.tar.gz",
36+
"windows-amd64": "windows-x86_64.zip",
37+
"darwin-amd64": "darwin-x86_64.tar.gz",
38+
"darwin-arm64": "darwin-aarch64.tar.gz",
4339
}
4440

4541
// GetPackageSuffix returns the suffix ending for the builds of Elastic Agent based on the
4642
// operating system and architecture.
47-
func GetPackageSuffix(operatingSystem string, architecture string, packageFormat string) (string, error) {
48-
suffix, ok := packageArchMap[fmt.Sprintf("%s-%s-%s", operatingSystem, architecture, packageFormat)]
43+
func GetPackageSuffix(operatingSystem string, architecture string) (string, error) {
44+
suffix, ok := packageArchMap[fmt.Sprintf("%s-%s", operatingSystem, architecture)]
4945
if !ok {
50-
return "", fmt.Errorf("%w: %s/%s/%s", ErrUnsupportedPlatform, operatingSystem, architecture, packageFormat)
46+
return "", fmt.Errorf("%w: %s/%s", ErrUnsupportedPlatform, operatingSystem, architecture)
5147
}
5248
return suffix, nil
5349
}
@@ -72,7 +68,7 @@ type Fetcher interface {
7268
//
7369
// The extraction is handled by the caller. This should only download the file
7470
// and place it into the directory.
75-
Fetch(ctx context.Context, operatingSystem string, architecture string, version string, packageFormat string) (FetcherResult, error)
71+
Fetch(ctx context.Context, operatingSystem string, architecture string, version string) (FetcherResult, error)
7672
}
7773

7874
// fetchCache is global to all tests, reducing the time required to fetch the needed artifacts
@@ -109,12 +105,6 @@ func splitFileType(name string) (string, string, error) {
109105
if strings.HasSuffix(name, ".zip") {
110106
return strings.TrimSuffix(name, ".zip"), ".zip", nil
111107
}
112-
if strings.HasSuffix(name, ".deb") {
113-
return strings.TrimSuffix(name, ".deb"), ".deb", nil
114-
}
115-
if strings.HasSuffix(name, ".rpm") {
116-
return strings.TrimSuffix(name, ".rpm"), ".rpm", nil
117-
}
118108
return "", "", fmt.Errorf("unknown file extension type: %s", filepath.Ext(name))
119109
}
120110

pkg/testing/fetcher_artifact.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ func (f *artifactFetcher) Name() string {
5959
}
6060

6161
// Fetch fetches the Elastic Agent and places the resulting binary at the path.
62-
func (f *artifactFetcher) Fetch(ctx context.Context, operatingSystem string, architecture string, version string, packageFormat string) (FetcherResult, error) {
63-
suffix, err := GetPackageSuffix(operatingSystem, architecture, packageFormat)
62+
func (f *artifactFetcher) Fetch(ctx context.Context, operatingSystem string, architecture string, version string) (FetcherResult, error) {
63+
suffix, err := GetPackageSuffix(operatingSystem, architecture)
6464
if err != nil {
6565
return nil, err
6666
}

pkg/testing/fetcher_artifact_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestArtifactFetcher_Default(t *testing.T) {
2929
af.doer = newFakeHttpClient(t)
3030

3131
tmp := t.TempDir()
32-
res, err := f.Fetch(context.Background(), "linux", "amd64", "8.12.0", "targz")
32+
res, err := f.Fetch(context.Background(), "linux", "amd64", "8.12.0")
3333
require.NoError(t, err)
3434

3535
err = res.Fetch(context.Background(), t, tmp)
@@ -46,7 +46,7 @@ func TestArtifactFetcher_Snapshot(t *testing.T) {
4646
af.doer = newFakeHttpClient(t)
4747

4848
tmp := t.TempDir()
49-
res, err := f.Fetch(context.Background(), "linux", "amd64", "8.13.0-SNAPSHOT", "targz")
49+
res, err := f.Fetch(context.Background(), "linux", "amd64", "8.13.0-SNAPSHOT")
5050
require.NoError(t, err)
5151

5252
err = res.Fetch(context.Background(), t, tmp)
@@ -64,7 +64,7 @@ func TestArtifactFetcher_SnapshotOnly(t *testing.T) {
6464
af.doer = newFakeHttpClient(t)
6565

6666
tmp := t.TempDir()
67-
res, err := f.Fetch(context.Background(), "linux", "amd64", "8.13.0", "targz")
67+
res, err := f.Fetch(context.Background(), "linux", "amd64", "8.13.0")
6868
require.NoError(t, err)
6969

7070
err = res.Fetch(context.Background(), t, tmp)
@@ -82,7 +82,7 @@ func TestArtifactFetcher_Build(t *testing.T) {
8282
af.doer = newFakeHttpClient(t)
8383

8484
tmp := t.TempDir()
85-
res, err := f.Fetch(context.Background(), "linux", "amd64", "8.13.0-SNAPSHOT+l5snflwr", "targz")
85+
res, err := f.Fetch(context.Background(), "linux", "amd64", "8.13.0-SNAPSHOT+l5snflwr")
8686
require.NoError(t, err)
8787

8888
err = res.Fetch(context.Background(), t, tmp)

pkg/testing/fetcher_http.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ func (h HttpFetcher) Name() string {
4545
return fmt.Sprintf("httpFetcher-%s", sanitizeFetcherName(h.baseURL))
4646
}
4747

48-
func (h HttpFetcher) Fetch(ctx context.Context, operatingSystem string, architecture string, version string, packageFormat string) (FetcherResult, error) {
49-
suffix, err := GetPackageSuffix(operatingSystem, architecture, packageFormat)
48+
func (h HttpFetcher) Fetch(ctx context.Context, operatingSystem string, architecture string, version string) (FetcherResult, error) {
49+
suffix, err := GetPackageSuffix(operatingSystem, architecture)
5050
if err != nil {
5151
return nil, err
5252
}

pkg/testing/fetcher_http_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func TestHttpFetcher_Fetch(t *testing.T) {
2424
operatingSystem string
2525
architecture string
2626
version string
27-
pkgFormat string
2827
}
2928
tests := []struct {
3029
name string
@@ -39,7 +38,6 @@ func TestHttpFetcher_Fetch(t *testing.T) {
3938
operatingSystem: "linux",
4039
architecture: "arm64",
4140
version: "1.2.3",
42-
pkgFormat: "targz",
4341
},
4442
want: &httpFetcherResult{
4543
baseURL: "https://artifacts.elastic.co/downloads/beats/elastic-agent/",
@@ -54,7 +52,6 @@ func TestHttpFetcher_Fetch(t *testing.T) {
5452
operatingSystem: "windows",
5553
architecture: "amd64",
5654
version: "1.2.3",
57-
pkgFormat: "zip",
5855
},
5956
want: &httpFetcherResult{
6057
baseURL: "http://somehost.somedomain/some/path/here",
@@ -72,7 +69,7 @@ func TestHttpFetcher_Fetch(t *testing.T) {
7269
h := NewHttpFetcher(opts...)
7370
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
7471
defer cancel()
75-
got, err := h.Fetch(ctx, tt.args.operatingSystem, tt.args.architecture, tt.args.version, tt.args.pkgFormat)
72+
got, err := h.Fetch(ctx, tt.args.operatingSystem, tt.args.architecture, tt.args.version)
7673
if !tt.wantErr(t, err, fmt.Sprintf("Fetch(%v, %v, %v, %v)", ctx, tt.args.operatingSystem, tt.args.architecture, tt.args.version)) {
7774
return
7875
}

pkg/testing/fetcher_local.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func (f *localFetcher) Name() string {
5555
}
5656

5757
// Fetch fetches the Elastic Agent and places the resulting binary at the path.
58-
func (f *localFetcher) Fetch(_ context.Context, operatingSystem string, architecture string, version string, packageFormat string) (FetcherResult, error) {
59-
suffix, err := GetPackageSuffix(operatingSystem, architecture, packageFormat)
58+
func (f *localFetcher) Fetch(_ context.Context, operatingSystem string, architecture string, version string) (FetcherResult, error) {
59+
suffix, err := GetPackageSuffix(operatingSystem, architecture)
6060
if err != nil {
6161
return nil, err
6262
}

pkg/testing/fetcher_local_test.go

+2-10
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@ func TestLocalFetcher(t *testing.T) {
2828
snapshotContentHash := []byte("snapshot contents hash")
2929
noSnapshotContent := []byte("not snapshot contents")
3030
noSnapshotContentHash := []byte("not snapshot contents hash")
31-
pkgFormat := "targz"
32-
if runtime.GOOS == "windows" {
33-
pkgFormat = "zip"
34-
}
3531

3632
testdata := t.TempDir()
37-
suffix, err := GetPackageSuffix(runtime.GOOS, runtime.GOARCH, pkgFormat)
33+
suffix, err := GetPackageSuffix(runtime.GOOS, runtime.GOARCH)
3834
require.NoError(t, err)
3935

4036
snapshotPath := fmt.Sprintf("elastic-agent-%s-SNAPSHOT-%s", baseVersion, suffix)
@@ -96,12 +92,8 @@ func TestLocalFetcher(t *testing.T) {
9692
tmp := t.TempDir()
9793

9894
f := LocalFetcher(testdata, tc.opts...)
99-
pkgFormat := "targz"
100-
if runtime.GOOS == "windows" {
101-
pkgFormat = "zip"
102-
}
10395
got, err := f.Fetch(
104-
context.Background(), runtime.GOOS, runtime.GOARCH, tc.version, pkgFormat)
96+
context.Background(), runtime.GOOS, runtime.GOARCH, tc.version)
10597
require.NoError(t, err)
10698

10799
err = got.Fetch(context.Background(), t, tmp)

pkg/testing/fixture.go

+1-28
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type Fixture struct {
4141
fetcher Fetcher
4242
operatingSystem string
4343
architecture string
44-
packageFormat string
4544
logOutput bool
4645
allowErrs bool
4746
connectTimout time.Duration
@@ -84,14 +83,6 @@ func WithOSArchitecture(operatingSystem string, architecture string) FixtureOpt
8483
}
8584
}
8685

87-
// WithPackageFormat changes the package format to use for the fixture.
88-
// By default, targz is picked except for windows which uses zip
89-
func WithPackageFormat(packageFormat string) FixtureOpt {
90-
return func(f *Fixture) {
91-
f.packageFormat = packageFormat
92-
}
93-
}
94-
9586
// WithLogOutput instructs the fixture to log all Elastic Agent output to the test log.
9687
// By default, the Elastic Agent output will not be logged to the test logger.
9788
func WithLogOutput() FixtureOpt {
@@ -148,18 +139,13 @@ func NewFixture(t *testing.T, version string, opts ...FixtureOpt) (*Fixture, err
148139
if !ok {
149140
return nil, errors.New("unable to determine callers file path")
150141
}
151-
pkgFormat := "targz"
152-
if runtime.GOOS == "windows" {
153-
pkgFormat = "zip"
154-
}
155142
f := &Fixture{
156143
t: t,
157144
version: version,
158145
caller: caller,
159146
fetcher: ArtifactFetcher(),
160147
operatingSystem: runtime.GOOS,
161148
architecture: runtime.GOARCH,
162-
packageFormat: pkgFormat,
163149
connectTimout: 15 * time.Second,
164150
// default to elastic-agent, can be changed by a set FixtureOpt below
165151
binaryName: "elastic-agent",
@@ -267,11 +253,6 @@ func (f *Fixture) SrcPackage(ctx context.Context) (string, error) {
267253
return f.srcPackage, nil
268254
}
269255

270-
// PackageFormat returns the package format for the fixture
271-
func (f *Fixture) PackageFormat() string {
272-
return f.packageFormat
273-
}
274-
275256
func ExtractArtifact(l Logger, artifactFile, outputDir string) error {
276257
filename := filepath.Base(artifactFile)
277258
_, ext, err := splitFileType(filename)
@@ -290,11 +271,6 @@ func ExtractArtifact(l Logger, artifactFile, outputDir string) error {
290271
if err != nil {
291272
return fmt.Errorf("failed to unzip %s: %w", artifactFile, err)
292273
}
293-
case ".deb", "rpm":
294-
err := copy.Copy(artifactFile, filepath.Join(outputDir, filepath.Base(artifactFile)))
295-
if err != nil {
296-
return fmt.Errorf("failed to copy %s to %s: %w", artifactFile, outputDir, err)
297-
}
298274
}
299275
l.Logf("Completed extraction of artifact %s to %s", filename, outputDir)
300276
return nil
@@ -837,9 +813,6 @@ func (f *Fixture) binaryPath() string {
837813
workDir = filepath.Join(paths.DefaultBasePath, "Elastic", "Agent")
838814
}
839815
}
840-
if f.packageFormat == "deb" {
841-
workDir = "/usr/bin"
842-
}
843816
defaultBin := "elastic-agent"
844817
if f.binaryName != "" {
845818
defaultBin = f.binaryName
@@ -867,7 +840,7 @@ func (f *Fixture) fetch(ctx context.Context) (string, error) {
867840
cache.dir = dir
868841
}
869842

870-
res, err := f.fetcher.Fetch(ctx, f.operatingSystem, f.architecture, f.version, f.packageFormat)
843+
res, err := f.fetcher.Fetch(ctx, f.operatingSystem, f.architecture, f.version)
871844
if err != nil {
872845
return "", err
873846
}

0 commit comments

Comments
 (0)