Skip to content

Commit

Permalink
Addressed pr review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JoukoVirtanen committed Jan 14, 2025
1 parent bb40e2e commit 6abe33d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
30 changes: 18 additions & 12 deletions integration-tests/pkg/types/runtime_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,27 @@ import (
"gopkg.in/yaml.v3"
)

type ExternalIpsConfig struct {
Enabled string `yaml:"enabled"`
}

type NetworkConfig struct {
ExternalIps ExternalIpsConfig `yaml:"externalIps"`
}

type RuntimeConfig struct {
Networking struct {
ExternalIps struct {
Enabled string `yaml:"enabled"`
} `yaml:"externalIps"`
} `yaml:"networking"`
Networking NetworkConfig `yaml:"networking"`
}

// e.g.
// runtimeConfig := types.RuntimeConfig {
// Networking: types.NetworkConfig {
// ExternalIps: types.ExternalIpsConfig {
// Enabled: "ENABLED"
// },
// },
// }

func (n *RuntimeConfig) Equal(other RuntimeConfig) bool {
return n.Networking.ExternalIps.Enabled == other.Networking.ExternalIps.Enabled
}
Expand All @@ -25,10 +38,3 @@ func (n *RuntimeConfig) GetRuntimeConfigStr() (string, error) {

return string(yamlBytes), err
}

func GetRuntimeConfigEnabledStr(enabled string) (string, error) {
var runtimeConfig RuntimeConfig
runtimeConfig.Networking.ExternalIps.Enabled = enabled

return runtimeConfig.GetRuntimeConfigStr()
}
25 changes: 17 additions & 8 deletions integration-tests/suites/k8s/config_reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,28 @@ var (
CONFIG_MAP_NAME = "collector-config"
)

func init() {
var err error
var runtimeConfig types.RuntimeConfig
runtimeConfig.Networking.ExternalIps.Enabled = "ENABLED"

EXT_IP_ENABLE, err = runtimeConfig.GetRuntimeConfigStr()
if err != nil {
panic(err)
}

runtimeConfig.Networking.ExternalIps.Enabled = "DISABLED"
EXT_IP_DISABLE, err = runtimeConfig.GetRuntimeConfigStr()
if err != nil {
panic(err)
}
}

type K8sConfigReloadTestSuite struct {
K8sTestSuiteBase
}

func (k *K8sConfigReloadTestSuite) SetupSuite() {
var err error

EXT_IP_ENABLE, err = types.GetRuntimeConfigEnabledStr("ENABLED")
k.Require().NoError(err, "Failed to get runtime config for ENABLED")

EXT_IP_DISABLE, err = types.GetRuntimeConfigEnabledStr("DISABLED")
k.Require().NoError(err, "Failed to get runtime config for DISABLED")

k.T().Cleanup(func() {
k.Sensor().Stop()
k.teardownTargetNamespace()
Expand Down
4 changes: 3 additions & 1 deletion integration-tests/suites/runtime_config_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func (s *RuntimeConfigFileTestSuite) setRuntimeConfig(runtimeConfigFile string,
}

func (s *RuntimeConfigFileTestSuite) setExternalIpsEnabled(runtimeConfigFile string, enabled string) {
runtimeConfigStr, err := types.GetRuntimeConfigEnabledStr(enabled)
var runtimeConfig types.RuntimeConfig
runtimeConfig.Networking.ExternalIps.Enabled = enabled
runtimeConfigStr, err := runtimeConfig.GetRuntimeConfigStr()
s.Require().NoError(err)
s.setRuntimeConfig(runtimeConfigFile, runtimeConfigStr)
}
Expand Down

0 comments on commit 6abe33d

Please sign in to comment.