Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions tests/antithesis/test-template/entrypoint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ var NodeCount = "3"

// CheckHealth checks health of all etcd nodes
func CheckHealth() bool {
cfg := common.MakeConfig(NodeCount)
hosts, _, _ := common.GetPaths(cfg)
hosts, _, _ := common.GetPaths()

// iterate over each host and check health
for _, host := range hosts {
Expand Down
38 changes: 10 additions & 28 deletions tests/antithesis/test-template/robustness/common/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,34 @@ import (
)

const (
defaultetcd0 = "etcd0:2379"
defaultetcd1 = "etcd1:2379"
defaultetcd2 = "etcd2:2379"
// mounted by the client in docker compose
defaultetcdDataPath = "/var/etcddata%d"
defaultReportPath = "/var/report/"

endpointsEnv = "ETCD_ROBUSTNESS_ENDPOINTS"
dataPathsEnv = "ETCD_ROBUSTNESS_DATA_PATHS"
reportPathEnv = "ETCD_ROBUSTNESS_REPORT_PATH"
)

func GetPaths(cfg *Config) (hosts []string, reportPath string, dataPaths map[string]string) {
func GetPaths() (hosts []string, reportPath string, dataPaths map[string]string) {
// Check for environment variable overrides first
envDataPathsStr := os.Getenv(dataPathsEnv)
envReportPath := os.Getenv(reportPathEnv)
envEndpointsStr := os.Getenv(endpointsEnv)

defaultHosts, defaultReportPath, defaultDataPaths := defaultPaths(cfg)

hosts = defaultHosts
// Temporary disable to make PR simpler to review
//revive:disable:early-return
if envEndpointsStr != "" {
hosts = strings.Split(envEndpointsStr, ",")
for i, host := range hosts {
hosts[i] = strings.TrimSpace(host)
}
} else {
panic(fmt.Sprintf("No endpoints specified in %s", endpointsEnv))
}

reportPath = defaultReportPath
if envReportPath != "" {
reportPath = envReportPath
} else {
panic(fmt.Sprintf("No report path specified in %s", reportPathEnv))
}

dataPaths = defaultDataPaths
if envDataPathsStr != "" {
envDataPaths := strings.Split(envDataPathsStr, ",")
if len(envDataPaths) != len(hosts) {
Expand All @@ -67,21 +61,9 @@ func GetPaths(cfg *Config) (hosts []string, reportPath string, dataPaths map[str
for i, endpoint := range hosts {
dataPaths[endpoint] = strings.TrimSpace(envDataPaths[i])
}
} else {
panic(fmt.Sprintf("No data paths specified in %s", dataPathsEnv))
}
//revive:enable:early-return
return hosts, reportPath, dataPaths
}

func defaultPaths(cfg *Config) (hosts []string, reportPath string, dataPaths map[string]string) {
hosts = []string{defaultetcd0, defaultetcd1, defaultetcd2}[:cfg.NodeCount]
reportPath = defaultReportPath
dataPaths = etcdDataPaths(defaultetcdDataPath, cfg.NodeCount)
return hosts, reportPath, dataPaths
}

func etcdDataPaths(dir string, amount int) map[string]string {
dataPaths := make(map[string]string)
for i := range amount {
dataPaths[fmt.Sprintf("etcd%d", i)] = fmt.Sprintf(dir, i)
}
return dataPaths
}
3 changes: 1 addition & 2 deletions tests/antithesis/test-template/robustness/finally/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ const (
var NodeCount = "3"

func main() {
cfg := common.MakeConfig(NodeCount)
_, reportPath, dirs := common.GetPaths(cfg)
_, reportPath, dirs := common.GetPaths()

lg, err := zap.NewProduction()
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions tests/antithesis/test-template/robustness/traffic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ var (
)

func main() {
cfg := common.MakeConfig(NodeCount)
hosts, reportPath, etcdetcdDataPaths := common.GetPaths(cfg)
hosts, reportPath, etcdetcdDataPaths := common.GetPaths()

ctx := context.Background()
baseTime := time.Now()
Expand Down