Skip to content

Commit

Permalink
Remove extra host config values, and simplify kind checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Stringy committed Aug 12, 2024
1 parent e5dcde2 commit 53242de
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion integration-tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestImageLabelJSON(t *testing.T) {

// TestMissingProcScrape only works with local fake proc directory
func TestMissingProcScrape(t *testing.T) {
if config.HostInfo().IsLocal() {
if !config.HostInfo().IsK8s() {
suite.Run(t, new(suites.MissingProcScrapeTestSuite))
}
}
Expand Down
14 changes: 6 additions & 8 deletions integration-tests/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,17 @@ func init() {
// Host contains information about how to connect to the host upon
// which the tests are running
type Host struct {
Kind string
User string
Address string
Options string
Kind string
}

func (h *Host) IsLocal() bool {
return h.Kind == "local"
}

func (h *Host) IsK8s() bool {
return h.Kind == "k8s"
}

// VM contains metadata about the machine upon which the tests are
// running.
type VM struct {
Expand Down Expand Up @@ -116,10 +117,7 @@ func StopTimeout() string {
func HostInfo() *Host {
if host_options == nil {
host_options = &Host{
Kind: ReadEnvVarWithDefault(envHostType, "local"),
User: ReadEnvVar(envHostUser),
Address: ReadEnvVar(envHostAddress),
Options: ReadEnvVar(envHostOptions),
Kind: ReadEnvVarWithDefault(envHostType, "local"),
}
}

Expand Down
5 changes: 1 addition & 4 deletions integration-tests/pkg/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ const (
envCollectorLogLevel = "COLLECTOR_LOG_LEVEL"
envCollectorPreArguments = "COLLECTOR_PRE_ARGUMENTS"

envHostType = "REMOTE_HOST_TYPE"
envHostUser = "REMOTE_HOST_USER"
envHostAddress = "REMOTE_HOST_ADDRESS"
envHostOptions = "REMOTE_HOST_OPTIONS"
envHostType = "REMOTE_HOST_TYPE"

envVMInstanceType = "VM_INSTANCE_TYPE"
envVMConfig = "VM_CONFIG"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type CommandBuilder interface {
}

func New() (Executor, error) {
if config.HostInfo().Kind == "k8s" {
if config.HostInfo().IsK8s() {
return newK8sExecutor()
}
return newDockerExecutor()
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/suites/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (s *IntegrationTestSuiteBase) waitForFileToBeDeleted(file string) error {
case <-timer:
return fmt.Errorf("Timed out waiting for %s to be deleted", file)
case <-ticker.C:
if config.HostInfo().Kind == "local" {
if config.HostInfo().IsLocal() {
if _, err := os.Stat(file); os.IsNotExist(err) {
return nil
}
Expand Down

0 comments on commit 53242de

Please sign in to comment.