Fix Flaky Test: should handle FTAggregate with Unstable RESP3 Search Module and without stability

This commit is contained in:
ofekshenawa 2024-09-26 12:54:32 +03:00
parent e99abe4546
commit f5792c7921
2 changed files with 7 additions and 5 deletions

2
go.mod
View File

@ -10,6 +10,6 @@ require (
) )
retract ( retract (
v9.5.3 // This version was accidentally released. Please use version 9.6.0 instead.
v9.5.4 // This version was accidentally released. Please use version 9.6.0 instead. v9.5.4 // This version was accidentally released. Please use version 9.6.0 instead.
v9.5.3 // This version was accidentally released. Please use version 9.6.0 instead.
) )

View File

@ -1446,16 +1446,18 @@ var _ = Describe("RediSearch commands Resp 3", Label("search"), func() {
options := &redis.FTAggregateOptions{Apply: []redis.FTAggregateApply{{Field: "@CreatedDateTimeUTC * 10", As: "CreatedDateTimeUTC"}}} options := &redis.FTAggregateOptions{Apply: []redis.FTAggregateApply{{Field: "@CreatedDateTimeUTC * 10", As: "CreatedDateTimeUTC"}}}
res, err := client.FTAggregateWithArgs(ctx, "idx1", "*", options).RawResult() res, err := client.FTAggregateWithArgs(ctx, "idx1", "*", options).RawResult()
rawVal := client.FTAggregateWithArgs(ctx, "idx1", "*", options).RawVal()
Expect(err).NotTo(HaveOccurred())
Expect(rawVal).To(BeEquivalentTo(res))
results := res.(map[interface{}]interface{})["results"].([]interface{}) results := res.(map[interface{}]interface{})["results"].([]interface{})
Expect(results[0].(map[interface{}]interface{})["extra_attributes"].(map[interface{}]interface{})["CreatedDateTimeUTC"]). Expect(results[0].(map[interface{}]interface{})["extra_attributes"].(map[interface{}]interface{})["CreatedDateTimeUTC"]).
To(Or(BeEquivalentTo("6373878785249699840"), BeEquivalentTo("6373878758592700416"))) To(Or(BeEquivalentTo("6373878785249699840"), BeEquivalentTo("6373878758592700416")))
Expect(results[1].(map[interface{}]interface{})["extra_attributes"].(map[interface{}]interface{})["CreatedDateTimeUTC"]). Expect(results[1].(map[interface{}]interface{})["extra_attributes"].(map[interface{}]interface{})["CreatedDateTimeUTC"]).
To(Or(BeEquivalentTo("6373878785249699840"), BeEquivalentTo("6373878758592700416"))) To(Or(BeEquivalentTo("6373878785249699840"), BeEquivalentTo("6373878758592700416")))
rawVal := client.FTAggregateWithArgs(ctx, "idx1", "*", options).RawVal()
rawValResults := rawVal.(map[interface{}]interface{})["results"].([]interface{})
Expect(err).NotTo(HaveOccurred())
Expect(rawValResults[0]).To(Or(BeEquivalentTo(results[0]), BeEquivalentTo(results[1])))
Expect(rawValResults[1]).To(Or(BeEquivalentTo(results[0]), BeEquivalentTo(results[1])))
// Test with UnstableResp3 false // Test with UnstableResp3 false
Expect(func() { Expect(func() {
options = &redis.FTAggregateOptions{Apply: []redis.FTAggregateApply{{Field: "@CreatedDateTimeUTC * 10", As: "CreatedDateTimeUTC"}}} options = &redis.FTAggregateOptions{Apply: []redis.FTAggregateApply{{Field: "@CreatedDateTimeUTC * 10", As: "CreatedDateTimeUTC"}}}