Skip to content

Commit

Permalink
[BUG] Fix flaky test due to collection comparisons (#1563)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - Fix flaky test due to collection comparisons
 - New functionality
	 - ...

## Test plan
*How are these changes tested?*

- [ ] make test
- [ ] CI pass

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
Ishiihara authored Dec 21, 2023
1 parent 2202df8 commit 7dfadf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
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

0 comments on commit 7dfadf4

Please sign in to comment.