-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fleet] add install_script e2e test setup (#31791)
Co-authored-by: Kevin Fairise <[email protected]>
- Loading branch information
1 parent
b92624a
commit b629273
Showing
10 changed files
with
149 additions
and
8 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
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
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,61 @@ | ||
// 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. | ||
|
||
//go:build !windows | ||
|
||
// Package common contains the HostInstaller struct which is used to write the agent agentConfiguration to disk | ||
package common | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/DataDog/datadog-agent/pkg/fleet/installer/env" | ||
) | ||
|
||
func assertFileContent(t *testing.T, file, content string) { | ||
b, err := os.ReadFile(file) | ||
assert.NoError(t, err) | ||
assert.Equal(t, content, string(b)) | ||
} | ||
|
||
func TestAgentConfigs(t *testing.T) { | ||
configDir = t.TempDir() | ||
datadogConfFile = filepath.Join(configDir, "datadog.yaml") | ||
logsConfFile = filepath.Join(configDir, "conf.d/configured_at_install_logs.yaml") | ||
sparkConfigFile = filepath.Join(configDir, "conf.d/spark.d/spark.yaml") | ||
|
||
i, err := newHostInstaller(&env.Env{APIKey: "a"}, 0, 0) | ||
assert.NotNil(t, i) | ||
assert.Nil(t, err) | ||
|
||
i.AddAgentConfig("key", "value") | ||
i.AddLogConfig(LogConfig{Type: "file", Path: "/var/log/app.log", Service: "app"}) | ||
i.AddHostTag("k1", "v1") | ||
i.AddHostTag("k2", "v2") | ||
i.AddSparkInstance(SparkInstance{ClusterName: "cluster", SparkURL: "http://localhost:8080"}) | ||
|
||
assert.NoError(t, i.writeConfigs()) | ||
assertFileContent(t, datadogConfFile, `api_key: a | ||
key: value | ||
logs_enabled: true | ||
tags: | ||
- k1:v1 | ||
- k2:v2 | ||
`) | ||
|
||
assertFileContent(t, logsConfFile, `logs: | ||
- type: file | ||
path: /var/log/app.log | ||
service: app | ||
`) | ||
assertFileContent(t, sparkConfigFile, `instances: | ||
- spark_url: http://localhost:8080 | ||
cluster_name: cluster | ||
`) | ||
} |
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,34 @@ | ||
// 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 installscript | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/e2e" | ||
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments" | ||
awshost "github.com/DataDog/datadog-agent/test/new-e2e/pkg/environments/aws/host" | ||
osdesc "github.com/DataDog/test-infra-definitions/components/os" | ||
"github.com/DataDog/test-infra-definitions/scenarios/aws/ec2" | ||
) | ||
|
||
type vmUpdaterSuite struct { | ||
commitHash string | ||
e2e.BaseSuite[environments.Host] | ||
} | ||
|
||
func (s *vmUpdaterSuite) TestInstallScript() { | ||
url := fmt.Sprintf("https://installtesting.datad0g.com/%s/scripts/install-databricks.sh", s.commitHash) | ||
s.Env().RemoteHost.MustExecute(fmt.Sprintf("curl -L %s > install_script; export DD_INSTALLER_REGISTRY_URL_INSTALLER_PACKAGE=installtesting.datad0g.com; sudo -E bash install_script", url)) | ||
} | ||
|
||
func TestUpdaterSuite(t *testing.T) { | ||
e2e.Run(t, &vmUpdaterSuite{commitHash: os.Getenv("CI_COMMIT_SHA")}, e2e.WithProvisioner(awshost.ProvisionerNoFakeIntake( | ||
awshost.WithEC2InstanceOptions(ec2.WithOSArch(osdesc.UbuntuDefault, osdesc.ARM64Arch)), | ||
))) | ||
} |