Skip to content

Commit

Permalink
Stop asserting version running
Browse files Browse the repository at this point in the history
  • Loading branch information
coignetp committed Jul 3, 2024
1 parent 233febd commit d322ba7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
37 changes: 0 additions & 37 deletions test/new-e2e/tests/installer/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
package host

import (
"crypto/tls"
"encoding/json"
"fmt"
"io/fs"
"net/http"
"os/user"
"path/filepath"
"sort"
Expand Down Expand Up @@ -178,40 +175,6 @@ func (h *Host) InstallerVersion() string {
return strings.TrimSpace(h.remote.MustExecute("sudo datadog-installer version"))
}

// AgentVersion returns the version of the agent on the host
func (h *Host) AgentVersion() string {
// Needs sudo to read the auth token
authTokenRaw := h.remote.MustExecute("sudo cat /etc/datadog-agent/auth_token")
authToken := strings.TrimSpace(string(authTokenRaw))

request, err := http.NewRequest("GET", "https://localhost:5001/agent/version", nil)
require.NoError(h.t, err)
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Authorization", "Bearer "+authToken)
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
response, err := client.Do(request)
require.NoError(h.t, err)
defer response.Body.Close()
body := make([]byte, response.ContentLength)
_, err = response.Body.Read(body)
require.NoError(h.t, err)

var versionParsed struct {
Major int `json:"Major"`
Minor int `json:"Minor"`
Patch int `json:"Patch"`
}
require.NoError(h.t, json.Unmarshal([]byte(body), &versionParsed))

ver := fmt.Sprintf("%d.%d.%d", versionParsed.Major, versionParsed.Minor, versionParsed.Patch)

return ver
}

// AssertPackageInstalledByInstaller checks if a package is installed by the installer on the host.
func (h *Host) AssertPackageInstalledByInstaller(pkgs ...string) {
for _, pkg := range pkgs {
Expand Down
9 changes: 0 additions & 9 deletions test/new-e2e/tests/installer/upgrade_scenario_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package installer
import (
"encoding/json"
"fmt"
"strings"
"time"

"github.com/DataDog/datadog-agent/test/new-e2e/tests/installer/host"
Expand Down Expand Up @@ -185,10 +184,6 @@ func (s *upgradeScenarioSuite) assertSuccessfulStartExperiment(timestamp host.Jo

installerStatus := s.getInstallerStatus()
require.Equal(s.T(), version, installerStatus.Packages["datadog-agent"].ExperimentVersion)

// Assert running version
v := s.host.AgentVersion()
require.Equal(s.T(), strings.TrimSuffix(version, "-1"), v)
}

func (s *upgradeScenarioSuite) assertSuccessfulPromoteExperiment(timestamp host.JournaldTimestamp, version string) {
Expand All @@ -211,10 +206,6 @@ func (s *upgradeScenarioSuite) assertSuccessfulPromoteExperiment(timestamp host.
installerStatus := s.getInstallerStatus()
require.Equal(s.T(), version, installerStatus.Packages["datadog-agent"].StableVersion)
require.Equal(s.T(), "", installerStatus.Packages["datadog-agent"].ExperimentVersion)

// Assert running version
v := s.host.AgentVersion()
require.Equal(s.T(), strings.TrimSuffix(version, "-1"), v)
}

func (s *upgradeScenarioSuite) assertSuccessfulStopExperiment(timestamp host.JournaldTimestamp) {
Expand Down

0 comments on commit d322ba7

Please sign in to comment.