-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* enhancement(5832): added integration tests * enhancement(5832): updated fixture install, updated assertions * enhancement(5832): added kubernetes test * enhancement(5832): ran mage update * enhancement(5832): execute rpm test in default group * Revert "enhancement(5832): execute rpm test in default group" This reverts commit fa93a8e. * enhancement(5832): debugging ci issues * enahancement(5832): added logs to see if any other agent is running, commented out other integration tests * enhancement(5832): added cleanup steps to rpm tests * enhancement(5832): trying 777 permission * enhancement(5832): removed diagnostics, added rpm cleanup step that purges all agent files * enhancement(5832): running all tests * enhancement(5832): uncommented integration test pipeline * enhancement(5832): reverting unnecessary changes * enhancement(5832): uncommenting integration tests * enhancement(5832): reverted integration_tests.sh changes * enhancement(5832): reverted fixture_install.go changes * enhancement(5832): remove print * enhancement(5832): logging output if cleanup fails * enhancement(5832): updated k8s test, refactored upgrade test into test step (cherry picked from commit 3f608bf) Co-authored-by: Kaan Yalti <kaan.yalti@elastic.co> Co-authored-by: Andrzej Stencel <andrzej.stencel@elastic.co> Co-authored-by: Michal Pristas <michal.pristas@gmail.com>
- Loading branch information
1 parent
808f803
commit 05b4b98
Showing
4 changed files
with
183 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
// you may not use this file except in compliance with the Elastic License 2.0. | ||
|
||
//go:build integration | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/elastic/elastic-agent/internal/pkg/agent/application/coordinator" | ||
atesting "github.com/elastic/elastic-agent/pkg/testing" | ||
"github.com/elastic/elastic-agent/pkg/testing/define" | ||
) | ||
|
||
func TestRestrictUpgradeDeb(t *testing.T) { | ||
define.Require(t, define.Requirements{ | ||
Group: Deb, | ||
Stack: &define.Stack{}, | ||
Sudo: true, | ||
OS: []define.OS{ | ||
{ | ||
Type: define.Linux, | ||
Distro: "ubuntu", | ||
}, | ||
}, | ||
}) | ||
t.Run("when agent is deployed via deb, a user should not be able to upgrade the agent using the cli", func(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
fixture, err := define.NewFixtureFromLocalBuild(t, define.Version(), atesting.WithPackageFormat("deb")) | ||
require.NoError(t, err) | ||
installOpts := atesting.InstallOpts{ | ||
NonInteractive: true, | ||
Privileged: true, | ||
Force: true, | ||
} | ||
|
||
_, err = fixture.InstallWithoutEnroll(ctx, &installOpts) | ||
require.NoError(t, err) | ||
|
||
require.Eventuallyf(t, func() bool { | ||
err = fixture.IsHealthy(ctx) | ||
return err == nil | ||
}, 5*time.Minute, time.Second, | ||
"Elastic-Agent did not report healthy. Agent status error: \"%v\"", | ||
err, | ||
) | ||
|
||
out, err := fixture.Exec(ctx, []string{"upgrade", "1.0.0"}) | ||
require.Error(t, err) | ||
require.Contains(t, string(out), coordinator.ErrNotUpgradable.Error()) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
// you may not use this file except in compliance with the Elastic License 2.0. | ||
|
||
//go:build integration | ||
|
||
package integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/elastic/elastic-agent/internal/pkg/agent/application/coordinator" | ||
atesting "github.com/elastic/elastic-agent/pkg/testing" | ||
"github.com/elastic/elastic-agent/pkg/testing/define" | ||
) | ||
|
||
func TestRestrictUpgradeRPM(t *testing.T) { | ||
define.Require(t, define.Requirements{ | ||
Group: RPM, | ||
Stack: &define.Stack{}, | ||
Sudo: true, | ||
OS: []define.OS{ | ||
{ | ||
Type: define.Linux, | ||
Distro: "rhel", | ||
}, | ||
}, | ||
}) | ||
t.Run("when agent is deployed via rpm, a user should not be able to upgrade the agent using the cli", func(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
fixture, err := define.NewFixtureFromLocalBuild(t, define.Version(), atesting.WithPackageFormat("rpm")) | ||
require.NoError(t, err) | ||
installOpts := atesting.InstallOpts{ | ||
NonInteractive: true, | ||
Privileged: true, | ||
Force: true, | ||
} | ||
|
||
_, err = fixture.InstallWithoutEnroll(ctx, &installOpts) | ||
require.NoError(t, err) | ||
|
||
require.Eventuallyf(t, func() bool { | ||
err = fixture.IsHealthy(ctx) | ||
return err == nil | ||
}, 5*time.Minute, time.Second, | ||
"Elastic-Agent did not report healthy. Agent status error: \"%v\"", | ||
err, | ||
) | ||
|
||
out, err := fixture.Exec(ctx, []string{"upgrade", "1.0.0"}) | ||
require.Error(t, err) | ||
require.Contains(t, string(out), coordinator.ErrNotUpgradable.Error()) | ||
}) | ||
} |