Skip to content

Commit 8f87430

Browse files
authored
chore(test): fix e2e installer test CI conf for ansible (#49864)
This commit factorizes the code to override Ansible configuration in installer e2e tests during CI. It also enables some more testing (which are currently skipped because of this configuration bug). Co-authored-by: matthieu.dubet <matthieu.dubet@datadoghq.com>
1 parent bbb572d commit 8f87430

5 files changed

Lines changed: 24 additions & 26 deletions

File tree

test/new-e2e/tests/installer/script/all_scripts_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,8 @@ type installerScriptSuite interface {
113113
}
114114

115115
func newInstallerScriptSuite(pkg string, e2eos e2eos.Descriptor, arch e2eos.Architecture, opts ...awshost.ProvisionerOption) installerScriptBaseSuite {
116-
var scriptURLPrefix string
117-
if pipelineID, ok := os.LookupEnv("E2E_PIPELINE_ID"); ok {
118-
scriptURLPrefix = fmt.Sprintf("https://s3.amazonaws.com/installtesting.datad0g.com/pipeline-%s/scripts/", pipelineID)
119-
} else if commitHash, ok := os.LookupEnv("CI_COMMIT_SHA"); ok {
120-
scriptURLPrefix = fmt.Sprintf("https://s3.amazonaws.com/installtesting.datad0g.com/%s/scripts/", commitHash)
121-
} else {
122-
require.FailNowf(nil, "missing script identifier", "CI_COMMIT_SHA or CI_PIPELINE_ID must be set")
123-
}
124-
125116
return installerScriptBaseSuite{
126-
scriptURLPrefix: scriptURLPrefix,
117+
scriptURLPrefix: "https://" + installer.InstallerScriptBaseURL() + "/scripts/",
127118
os: e2eos,
128119
arch: arch,
129120
pkg: pkg,

test/new-e2e/tests/installer/unix/all_packages_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,17 @@ func (s *packageBaseSuite) RunInstallScript(params ...string) {
238238
time.Sleep(time.Second)
239239
}
240240

241-
// Write the playbook
241+
// Write the playbook. InstallScriptEnv sets datadog_installer_registry to the
242+
// pipeline OCI registry (installtesting.datad0g.com.internal.dda-testing.com), which
243+
// the role passes as DD_INSTALLER_REGISTRY_URL_INSTALLER_PACKAGE to install-ssi.sh.
244+
// The script URL is overridden via -e (extra vars beat set_fact) so ansible fetches
245+
// the pipeline-specific install-ssi.sh from S3 instead of the production script.
242246
env := InstallScriptEnv(s.arch)
243247
playbookPath := s.writeAnsiblePlaybook(env, params...)
248+
scriptURL := "https://" + InstallerScriptBaseURL() + "/scripts/install-ssi.sh"
244249

245250
// Run the playbook
246-
s.Env().RemoteHost.MustExecute(fmt.Sprintf("%sansible-playbook -vvv %s", ansiblePrefix, playbookPath))
251+
s.Env().RemoteHost.MustExecute(fmt.Sprintf("%sansible-playbook -vvv %s -e 'datadog_installer_install_ssi_script_url=%s'", ansiblePrefix, playbookPath, scriptURL))
247252

248253
// touch install files for compatibility
249254
s.Env().RemoteHost.MustExecute("touch /tmp/datadog-installer-stdout.log")

test/new-e2e/tests/installer/unix/package_apm_inject_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,6 @@ func (s *packageApmInjectSuite) assertAppArmorProfile() {
558558
// install; direct instrumentation covers the current boot. The service's ExecStart/ExecStop
559559
// commands (instrument-start/instrument-stop) manage /etc/ld.so.preload on every reboot.
560560
func (s *packageApmInjectSuite) TestSystemdService() {
561-
if s.installMethod == InstallMethodAnsible {
562-
s.T().Skip("Ansible runs stable install-ssi script")
563-
}
564561
if _, err := s.Env().RemoteHost.Execute("test \"$(cat /proc/1/comm 2>/dev/null)\" = systemd"); err != nil {
565562
s.T().Skip("systemd is not running as PID 1 on this host")
566563
}
@@ -596,9 +593,6 @@ func (s *packageApmInjectSuite) TestSystemdService() {
596593
// /etc/ld.so.preload when systemd is not the init system, without creating a service file.
597594
// This test only runs on hosts where systemd is not PID 1; TestSystemdService covers the systemd path.
598595
func (s *packageApmInjectSuite) TestInstrumentHost_NoSystemd() {
599-
if s.installMethod == InstallMethodAnsible {
600-
s.T().Skip("Ansible runs stable install-ssi script")
601-
}
602596
if _, err := s.Env().RemoteHost.Execute("test \"$(cat /proc/1/comm 2>/dev/null)\" = systemd"); err == nil {
603597
s.T().Skip("systemd is PID 1 on this host; TestSystemdService covers that path")
604598
}

test/new-e2e/tests/installer/unix/package_ddot_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,7 @@ func (s *packageDDOTSuite) RunInstallScriptWithError(params ...string) error {
4242
}
4343
if hasOTelCollector {
4444
// This is temporary until the install script is updated to support calling the installer script
45-
var scriptURLPrefix string
46-
if pipelineID, ok := os.LookupEnv("E2E_PIPELINE_ID"); ok {
47-
scriptURLPrefix = fmt.Sprintf("https://s3.amazonaws.com/installtesting.datad0g.com/pipeline-%s/scripts/", pipelineID)
48-
} else if commitHash, ok := os.LookupEnv("CI_COMMIT_SHA"); ok {
49-
scriptURLPrefix = fmt.Sprintf("https://s3.amazonaws.com/installtesting.datad0g.com/%s/scripts/", commitHash)
50-
} else {
51-
require.FailNowf(nil, "missing script identifier", "CI_COMMIT_SHA or CI_PIPELINE_ID must be set")
52-
}
45+
scriptURLPrefix := "https://" + InstallerScriptBaseURL() + "/scripts/"
5346
_, err := s.Env().RemoteHost.Execute(fmt.Sprintf(`%s bash -c "$(curl -L %sinstall.sh)" > /tmp/datadog-installer-stdout.log 2> /tmp/datadog-installer-stderr.log`, strings.Join(params, " "), scriptURLPrefix), client.WithEnvVariables(InstallInstallerScriptEnvWithPackages()))
5447
return err
5548
}

test/new-e2e/tests/installer/unix/package_definitions.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ func installScriptInstallerEnv(env map[string]string, packagesConfig []TestPacka
112112
}
113113
}
114114

115+
// InstallerScriptBaseURL returns the host+path prefix (no scheme, no trailing suffix) where
116+
// pipeline-specific install scripts are hosted. Pipeline builds write scripts to
117+
// s3://installtesting.datad0g.com/pipeline-{CI_PIPELINE_ID}/scripts/, commit builds to
118+
// s3://installtesting.datad0g.com/{CI_COMMIT_SHA}/scripts/. Falls back to production when
119+
// neither variable is set.
120+
func InstallerScriptBaseURL() string {
121+
if pipelineID, ok := os.LookupEnv("E2E_PIPELINE_ID"); ok {
122+
return "s3.amazonaws.com/installtesting.datad0g.com/pipeline-" + pipelineID
123+
}
124+
if commitHash, ok := os.LookupEnv("CI_COMMIT_SHA"); ok {
125+
return "s3.amazonaws.com/installtesting.datad0g.com/" + commitHash
126+
}
127+
return "install.datadoghq.com"
128+
}
129+
115130
// InstallScriptEnv returns the environment variables for the install script
116131
func InstallScriptEnv(arch e2eos.Architecture) map[string]string {
117132
return InstallScriptEnvWithPackages(arch, PackagesConfig)

0 commit comments

Comments
 (0)