Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Fix flaky test due to collection comparisons #1563

Merged
merged 2 commits into from
Dec 21, 2023
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
7 changes: 3 additions & 4 deletions go/coordinator/internal/coordinator/apis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ func TestCreateGetDeleteCollections(t *testing.T) {

assert.NotContains(t, results, c1)
assert.Len(t, results, len(sampleCollections)-1)
assert.Equal(t, sampleCollections[1:], results)

assert.ElementsMatch(t, results, sampleCollections[1:])
byIDResult, err := c.GetCollections(ctx, c1.ID, nil, nil, common.DefaultTenant, common.DefaultDatabase)
assert.NoError(t, err)
assert.Empty(t, byIDResult)
Expand Down Expand Up @@ -788,7 +787,7 @@ func TestCreateGetDeleteSegments(t *testing.T) {
testTypeB := "test_type_b"
result, err = c.GetSegments(ctx, types.NilUniqueID(), &testTypeB, nil, nil, types.NilUniqueID())
assert.NoError(t, err)
assert.Equal(t, sampleSegments[1:], result)
assert.ElementsMatch(t, result, sampleSegments[1:])

// Find by collection ID
result, err = c.GetSegments(ctx, types.NilUniqueID(), nil, nil, nil, sampleCollections[0].ID)
Expand All @@ -814,7 +813,7 @@ func TestCreateGetDeleteSegments(t *testing.T) {
assert.NoError(t, err)
assert.NotContains(t, results, s1)
assert.Len(t, results, len(sampleSegments)-1)
assert.Equal(t, sampleSegments[1:], results)
assert.ElementsMatch(t, results, sampleSegments[1:])

// Duplicate delete throws an exception
err = c.DeleteSegment(ctx, s1.ID)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package coordinator

import (
"sort"
"testing"

"github.com/chroma/chroma-coordinator/internal/metastore/db/dbmodel"
Expand Down Expand Up @@ -42,6 +43,9 @@ func TestConvertCollectionMetadataToDB(t *testing.T) {
},
}
dbCollectionMetadataList = convertCollectionMetadataToDB("collectionID", metadata)
sort.Slice(dbCollectionMetadataList, func(i, j int) bool {
return *dbCollectionMetadataList[i].Key < *dbCollectionMetadataList[j].Key
})
assert.NotNil(t, dbCollectionMetadataList)
assert.Len(t, dbCollectionMetadataList, 3)
assert.Equal(t, "collectionID", dbCollectionMetadataList[0].CollectionID)
Expand Down