diff --git a/test/new-e2e/tests/installer/all_packages_test.go b/test/new-e2e/tests/installer/all_packages_test.go index c754543f11f9b..18fe2d51249bd 100644 --- a/test/new-e2e/tests/installer/all_packages_test.go +++ b/test/new-e2e/tests/installer/all_packages_test.go @@ -104,9 +104,6 @@ func TestPackages(t *testing.T) { continue } suite := test.t(flavor, flavor.Architecture) - if strings.Contains(suite.Name(), "scenario") { - continue - } t.Run(suite.Name(), func(t *testing.T) { t.Parallel() // FIXME: Fedora currently has DNS issues diff --git a/test/new-e2e/tests/installer/upgrade_scenario_test.go b/test/new-e2e/tests/installer/upgrade_scenario_test.go index 1e43b7fcc5d86..9a0b54ab4dd76 100644 --- a/test/new-e2e/tests/installer/upgrade_scenario_test.go +++ b/test/new-e2e/tests/installer/upgrade_scenario_test.go @@ -8,8 +8,6 @@ package installer import ( "encoding/json" "fmt" - "regexp" - "strings" "time" "github.com/DataDog/datadog-agent/test/new-e2e/tests/installer/host" @@ -33,9 +31,14 @@ type catalog struct { } type packageStatus struct { - State string `json:"state"` - StableVersion string `json:"stable_version"` - ExperimentVersion string `json:"experiment_version"` + State string `json:"State"` + StableVersion string `json:"Stable"` + ExperimentVersion string `json:"Experiment"` +} + +type installerStatus struct { + Version string `json:"version"` + Packages map[string]packageStatus `json:"packages"` } var testCatalog = catalog{ @@ -48,14 +51,6 @@ var testCatalog = catalog{ }, } -// datadog-agent -// -// State: OK -// Installed versions: -// ● stable: v7.52.0-rc.1.git.15.6c19b17.pipeline.28815219-1 -// ● experiment: none -var installerStatusRegex = regexp.MustCompile(`([a-zA-Z-]+)\n[ \t]+State:.([a-zA-Z-]+)\n[ \t]+Installed versions:\n[ \t]+..stable:.([a-zA-Z0-9-\.]+)\n[ \t]+..experiment:.([a-zA-Z0-9-\.]+)`) - const ( latestAgentVersion = "7.54.1" latestAgentImageVersion = "7.54.1-1" @@ -126,13 +121,13 @@ func (s *upgradeScenarioSuite) TestStopWithoutExperiment() { s.setCatalog(testCatalog) - beforeStatus := s.getInstallerStatus()["datadog-agent"] + beforeStatus := s.getInstallerStatus() _, err := s.stopExperimentCommand() require.NoError(s.T(), err) - afterStatus := s.getInstallerStatus()["datadog-agent"] - require.Equal(s.T(), beforeStatus, afterStatus) + afterStatus := s.getInstallerStatus() + require.Equal(s.T(), beforeStatus.Packages["datadog-agent"], afterStatus.Packages["datadog-agent"]) } func (s *upgradeScenarioSuite) startExperimentCommand(version string) (string, error) { @@ -188,7 +183,7 @@ func (s *upgradeScenarioSuite) assertSuccessfulStartExperiment(timestamp host.Jo ) installerStatus := s.getInstallerStatus() - require.Equal(s.T(), version, installerStatus["datadog-agent"].ExperimentVersion) + require.Equal(s.T(), version, installerStatus.Packages["datadog-agent"].ExperimentVersion) } func (s *upgradeScenarioSuite) assertSuccessfulPromoteExperiment(timestamp host.JournaldTimestamp, version string) { @@ -209,8 +204,8 @@ func (s *upgradeScenarioSuite) assertSuccessfulPromoteExperiment(timestamp host. ) installerStatus := s.getInstallerStatus() - require.Equal(s.T(), version, installerStatus["datadog-agent"].StableVersion) - require.Equal(s.T(), "none", installerStatus["datadog-agent"].ExperimentVersion) + require.Equal(s.T(), version, installerStatus.Packages["datadog-agent"].StableVersion) + require.Equal(s.T(), "", installerStatus.Packages["datadog-agent"].ExperimentVersion) } func (s *upgradeScenarioSuite) assertSuccessfulStopExperiment(timestamp host.JournaldTimestamp) { @@ -229,29 +224,26 @@ func (s *upgradeScenarioSuite) assertSuccessfulStopExperiment(timestamp host.Jou ) installerStatus := s.getInstallerStatus() - require.Equal(s.T(), "none", installerStatus["datadog-agent"].ExperimentVersion) + require.Equal(s.T(), "", installerStatus.Packages["datadog-agent"].ExperimentVersion) } -func (s *upgradeScenarioSuite) getInstallerStatus() map[string]packageStatus { - // Datadog Installer v7.55.0-devel+git.1079.69749ed - // datadog-agent - // State: OK - // Installed versions: - // ● stable: v7.52.0-rc.1.git.15.6c19b17.pipeline.28815219-1 - // ● experiment: none - resp := s.Env().RemoteHost.MustExecute("sudo datadog-installer status") - status := make(map[string]packageStatus) - - statusResponse := installerStatusRegex.FindAllStringSubmatch(resp, -1) - for _, st := range statusResponse { - if len(st) != 5 { - s.T().Fatal("unexpected status response") - } - status[st[1]] = packageStatus{ - State: st[2], - StableVersion: strings.TrimPrefix(st[3], "v"), - ExperimentVersion: strings.TrimPrefix(st[4], "v"), - } +func (s *upgradeScenarioSuite) getInstallerStatus() installerStatus { + socketPath := "/var/run/datadog-installer/installer.sock" + + requestHeader := " -H 'Content-Type: application/json' -H 'Accept: application/json' " + response := s.Env().RemoteHost.MustExecute(fmt.Sprintf( + "sudo curl -s --unix-socket %s %s http://daemon/status", + socketPath, + requestHeader, + )) + + // {"version":"7.56.0-devel+git.446.acf2836","packages":{ + // "datadog-agent":{"Stable":"7.56.0-devel.git.446.acf2836.pipeline.37567760-1","Experiment":"7.54.1-1"}, + // "datadog-installer":{"Stable":"7.56.0-devel.git.446.acf2836.pipeline.37567760-1","Experiment":""}}} + var status installerStatus + err := json.Unmarshal([]byte(response), &status) + if err != nil { + s.T().Fatal(err) } return status