diff --git a/grid-proxy/tests/load_testing/load.go b/grid-proxy/tests/load_testing/load.go index 4efab862..db656bf0 100644 --- a/grid-proxy/tests/load_testing/load.go +++ b/grid-proxy/tests/load_testing/load.go @@ -5,6 +5,8 @@ import ( "log" "net/http" "os" + "path/filepath" + "slices" "time" prometheus_integration "github.com/threefoldtech/tfgrid-sdk-go/grid-proxy/tests/load_testing/prometheus" @@ -14,9 +16,12 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -func PerformLoadTesting() error { - - data, err := os.ReadFile("test.yml") +func PerformLoadTesting(path string) error { + extension := filepath.Ext(path) + if !slices.Contains([]string{".yml", ".yaml"}, extension) { + return fmt.Errorf("Unsupported file extension") + } + data, err := os.ReadFile(path) if err != nil { return fmt.Errorf("Failed to read YAML file: %v", err) } diff --git a/grid-proxy/tests/load_testing/load_test.go b/grid-proxy/tests/load_testing/load_test.go index 8426bbbd..4dde1a70 100644 --- a/grid-proxy/tests/load_testing/load_test.go +++ b/grid-proxy/tests/load_testing/load_test.go @@ -3,7 +3,7 @@ package load_test import "testing" func TestLoad(t *testing.T) { - err := PerformLoadTesting() + err := PerformLoadTesting("test.yml") if err != nil { t.Fatalf("Load test failed: %v", err) }