Skip to content

Commit

Permalink
fix flaky integ test for comparing SearchAttributes (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng authored Aug 17, 2023
1 parent edf8462 commit 577c59d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions integ/workflow/common/dummy_t.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package common

// DummyT uses assert.ElementsMatch for comparing slices, but with a bool result.
type DummyT struct{}

func (t DummyT) Errorf(string, ...interface{}) {}
5 changes: 4 additions & 1 deletion integ/workflow/persistence_loading_policy/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/indeedeng/iwf/integ/workflow/persistence"
"github.com/indeedeng/iwf/service"
"github.com/indeedeng/iwf/service/common/ptr"
"github.com/stretchr/testify/assert"
"log"
"net/http"
"reflect"
Expand Down Expand Up @@ -223,7 +224,9 @@ func verifyLoadedAttributes(
expectedDataAttributes = []iwfidl.KeyValue{}
}

if !reflect.DeepEqual(expectedSearchAttributes, searchAttributes) {
// use ElementsMatch so that the order won't be a problem.
// Internally the SAs are stored as a map and as a result, Golang return it without ordering guarantee
if !assert.ElementsMatch(common.DummyT{}, expectedSearchAttributes, searchAttributes) {
panic("Search attributes should be the same")
}

Expand Down

0 comments on commit 577c59d

Please sign in to comment.