Skip to content

Commit

Permalink
fix auditor test in MacOS (#379)
Browse files Browse the repository at this point in the history
Signed-off-by: Fansong Zeng <fanster.z@gmail.com>
  • Loading branch information
hormes committed Jul 18, 2022
1 parent 91cacc4 commit b54bb0c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion hack/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function run_test() {
go test -timeout 30s "github.com/koordinator-sh/koordinator/$pkg" -v
done <<< "$pkgs"
else
pkgs=`grep "$pattern" -r ./pkg | cut -d: -f1 | grep -E ".go$" | xargs -i dirname {}`
pkgs=`grep "$pattern" -r ./pkg | cut -d: -f1 | grep -E ".go$" | xargs -i dirname {} | sort -u`
while read -r line
do
pkg=${line#".//"}
Expand Down
5 changes: 4 additions & 1 deletion pkg/koordlet/audit/auditor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (t *TestServer) Shutdown() error {
}

func (t *TestServer) URL(size int, pageToken string) string {
url := fmt.Sprintf("http://:%d?size=%d", t.l.Addr().(*net.TCPAddr).Port, size)
url := fmt.Sprintf("http://127.0.0.1:%d?size=%d", t.l.Addr().(*net.TCPAddr).Port, size)
if pageToken != "" {
url += fmt.Sprintf("&pageToken=%s", pageToken)
}
Expand Down Expand Up @@ -86,15 +86,18 @@ func TestAuditorLogger(t *testing.T) {
req, _ := http.NewRequest("GET", server.URL(10, ""), nil)
req.Header.Add("Accept", "application/json")
resp, err := client.Do(req)

if err != nil {
t.Fatalf("failed to get events: %v", err)
}

defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
response := &JsonResponse{}
if err := json.Unmarshal(body, response); err != nil {
t.Fatal(err)
}

if len(response.Events) != 10 {
t.Errorf("failed to load events, expected %d actual %d", 10, len(response.Events))
}
Expand Down

0 comments on commit b54bb0c

Please sign in to comment.