Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersonQ committed Nov 14, 2023
1 parent 373afe6 commit 438480a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
6 changes: 3 additions & 3 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1165,12 +1165,12 @@ SOFTWARE


--------------------------------------------------------------------------------
Dependency : github.com/elastic/elastic-agent-libs
Version: v0.7.0
Dependency : github.com/AndersonQ/elastic-agent-libs
Version: v0.0.0-20231114192956-a479f50ccb1b
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/elastic-agent-libs@v0.7.0/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/!anderson!q/elastic-agent-libs@v0.0.0-20231114192956-a479f50ccb1b/LICENSE:

Apache License
Version 2.0, January 2004
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,5 @@ replace (

// Exclude this version because the version has an invalid checksum.
exclude github.com/docker/distribution v2.8.0+incompatible

replace github.com/elastic/elastic-agent-libs => github.com/AndersonQ/elastic-agent-libs v0.0.0-20231114192956-a479f50ccb1b

Check failure on line 186 in go.mod

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest)

replacement are not allowed: github.com/elastic/elastic-agent-libs (gomoddirectives)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8/go.mod h1:CzsSbkDixRphAF5hS6wbMKq0eI6ccJRb7/A0M6JBnwg=
github.com/AlecAivazis/survey/v2 v2.3.6/go.mod h1:4AuI9b7RjAR+G7v9+C4YSlX/YL3K3cWNXgWXOhllqvI=
github.com/AndersonQ/elastic-agent-libs v0.0.0-20231114192956-a479f50ccb1b h1:Y5NA7LYqJNRLoHXeANF5io4WqE7jZ4u0hI4biVUgAIs=
github.com/AndersonQ/elastic-agent-libs v0.0.0-20231114192956-a479f50ccb1b/go.mod h1:o+EySawBZGeYu49shJxerg2wRCimS1dhrD4As0MS700=
github.com/Azure/azure-sdk-for-go v16.2.1+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/azure-sdk-for-go v56.3.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc=
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
Expand Down Expand Up @@ -781,8 +783,6 @@ github.com/elastic/elastic-agent-autodiscover v0.6.5 h1:5DeMpuNc8c/tN6HN0A4A2uOF
github.com/elastic/elastic-agent-autodiscover v0.6.5/go.mod h1:chulyCAyZb/njMHgzkhC/yWnt8v/Y6eCRUhmFVnsA5o=
github.com/elastic/elastic-agent-client/v7 v7.5.0 h1:niI3WQ+01Lnp2r5LxK8SyNhrPJe13vBiOkqrDRK2oTA=
github.com/elastic/elastic-agent-client/v7 v7.5.0/go.mod h1:DYoX95xjC4BW/p2avyu724Qr2+hoUIz9eCU9CVS1d+0=
github.com/elastic/elastic-agent-libs v0.7.0 h1:g/+Gzpn4ayXPFbfZsn5lGjbPR1TGqlVpshJVVUNJGlQ=
github.com/elastic/elastic-agent-libs v0.7.0/go.mod h1:o+EySawBZGeYu49shJxerg2wRCimS1dhrD4As0MS700=
github.com/elastic/elastic-agent-system-metrics v0.8.0 h1:EsWbtd83JvnaqnL57bKS1E6GhOdemTRbxdFDcenR8zQ=
github.com/elastic/elastic-agent-system-metrics v0.8.0/go.mod h1:9C1UEfj0P687HAzZepHszN6zXA+2tN2Lx3Osvq1zby8=
github.com/elastic/elastic-integration-corpus-generator-tool v0.5.0/go.mod h1:uf9N86y+UACGybdEhZLpwZ93XHWVhsYZAA4c2T2v6YM=
Expand Down
45 changes: 27 additions & 18 deletions testing/integration/upgrade_fleet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestFleetManagedUpgrade(t *testing.T) {
t.Logf("Testing Elastic Agent upgrade from %s to %s with Fleet...",
define.Version(), endVersionInfo.Binary.String())

testUpgradeFleetManagedElasticAgent(ctx, t, info, startFixture, endFixture)
testUpgradeFleetManagedElasticAgent(ctx, t, info, startFixture, endFixture, defaultPolicy())
}

func TestFleetAirGapedUpgrade(t *testing.T) {
Expand Down Expand Up @@ -154,24 +154,29 @@ func TestFleetAirGapedUpgrade(t *testing.T) {
define.Version(), latest)

downloadSource := kibana.DownloadSource{
Name: "local-airgaped-" + uuid.NewString(),
Name: "local-air-gaped-" + uuid.NewString(),
Host: s.URL + "/downloads/beats/elastic-agent/",
IsDefault: true,
IsDefault: false, // other tests reuse the stack, let's not mess things up
}
t.Logf("creating download source %q, using %q.",
downloadSource.Name, downloadSource.Host)
err = stack.KibanaClient.CreateDownloadSource(ctx, downloadSource)
src, err := stack.KibanaClient.CreateDownloadSource(ctx, downloadSource)
require.NoError(t, err, "could not create download source")

testUpgradeFleetManagedElasticAgent(ctx, t, stack, fixture, upgradeTo)
policy := defaultPolicy()
policy.DownloadSourceID = src.Item.ID

testUpgradeFleetManagedElasticAgent(ctx, t, stack, fixture, upgradeTo, policy)
}

func testUpgradeFleetManagedElasticAgent(
ctx context.Context,
t *testing.T,
info *define.Info,
startFixture *atesting.Fixture,
endFixture *atesting.Fixture) {
endFixture *atesting.Fixture,
policy kibana.AgentPolicy) {
kibClient := info.KibanaClient

startVersionInfo, err := startFixture.ExecVersion(ctx)
require.NoError(t, err)
Expand All @@ -180,19 +185,8 @@ func testUpgradeFleetManagedElasticAgent(
endVersionInfo, err := endFixture.ExecVersion(ctx)
require.NoError(t, err)

policyUUID := uuid.New().String()

kibClient := info.KibanaClient
t.Log("Creating Agent policy...")
policyResp, err := kibClient.CreatePolicy(ctx, kibana.AgentPolicy{
Name: "test-policy-" + policyUUID,
Namespace: "default",
Description: "Test policy " + policyUUID,
MonitoringEnabled: []kibana.MonitoringEnabledOption{
kibana.MonitoringEnabledLogs,
kibana.MonitoringEnabledMetrics,
},
})
policyResp, err := kibClient.CreatePolicy(ctx, policy)
require.NoError(t, err, "failed creating policy")

t.Log("Creating Agent enrollment API key...")
Expand Down Expand Up @@ -275,6 +269,21 @@ func testUpgradeFleetManagedElasticAgent(
assert.NoError(t, err)
}

func defaultPolicy() kibana.AgentPolicy {
policyUUID := uuid.New().String()

policy := kibana.AgentPolicy{
Name: "test-policy-" + policyUUID,
Namespace: "default",
Description: "Test policy " + policyUUID,
MonitoringEnabled: []kibana.MonitoringEnabledOption{
kibana.MonitoringEnabledLogs,
kibana.MonitoringEnabledMetrics,
},
}
return policy
}

// simulateAirGapedEnvironment uses iptables to block outgoing packages to the
// IPs (v4 and v6) associated with host.
func simulateAirGapedEnvironment(t *testing.T, host string) {
Expand Down

0 comments on commit 438480a

Please sign in to comment.