Skip to content

Commit

Permalink
refactor: get config file path as a parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmaElsoly committed Nov 20, 2024
1 parent 65ea3f3 commit 4e57be0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions grid-proxy/tests/load_testing/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion grid-proxy/tests/load_testing/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 4e57be0

Please # to comment.