Skip to content

Commit 8bb6fc3

Browse files
author
Tim Middleton
committed
Address test failure
1 parent 8e823ce commit 8bb6fc3

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

coherence/named_cache_client.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ func getNamedCache[K comparable, V any](session *Session, name string, sOpts *Se
638638
f(cacheOptions)
639639
}
640640

641-
err := validateNearCacheOptions(cacheOptions.NearCacheOptions)
641+
err := ensureNearCacheOptions(cacheOptions.NearCacheOptions)
642642
if err != nil {
643643
return nil, err
644644
}
@@ -819,7 +819,7 @@ func convertNamedCacheClient[K comparable, V any](client *NamedCacheClient[K, V]
819819
return client
820820
}
821821

822-
func validateNearCacheOptions(options *NearCacheOptions) error {
822+
func ensureNearCacheOptions(options *NearCacheOptions) error {
823823
if options == nil {
824824
return nil
825825
}
@@ -855,6 +855,11 @@ func validateNearCacheOptions(options *NearCacheOptions) error {
855855
return ErrInvalidNearCacheWithNoTTL
856856
}
857857

858+
// ensure the default prune factor is set if it is zero
859+
if options.PruneFactor == 0 {
860+
options.PruneFactor = defaultPruneFactor
861+
}
862+
858863
return nil
859864
}
860865

coherence/named_cache_client_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ func TestInvalidNearCacheOptions(t *testing.T) {
5252
nearCacheOptions5 = NearCacheOptions{}
5353
)
5454

55-
err := validateNearCacheOptions(&nearCacheOptions1)
55+
err := ensureNearCacheOptions(&nearCacheOptions1)
5656
g.Expect(err).To(gomega.Equal(ErrNegativeNearCacheOptions))
5757

58-
err = validateNearCacheOptions(&nearCacheOptions2)
58+
err = ensureNearCacheOptions(&nearCacheOptions2)
5959
g.Expect(err).To(gomega.Equal(ErrNegativeNearCacheOptions))
6060

61-
err = validateNearCacheOptions(&nearCacheOptions3)
61+
err = ensureNearCacheOptions(&nearCacheOptions3)
6262
g.Expect(err).To(gomega.Equal(ErrInvalidNearCacheWithNoTTL))
6363

64-
err = validateNearCacheOptions(&nearCacheOptions4)
64+
err = ensureNearCacheOptions(&nearCacheOptions4)
6565
g.Expect(err).To(gomega.Equal(ErrInvalidNearCacheWithTTL))
6666

67-
err = validateNearCacheOptions(&nearCacheOptions5)
67+
err = ensureNearCacheOptions(&nearCacheOptions5)
6868
g.Expect(err).To(gomega.Equal(ErrInvalidNearCache))
6969
}

coherence/named_map_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ func getNamedMap[K comparable, V any](session *Session, name string, sOpts *Sess
902902
f(cacheOptions)
903903
}
904904

905-
err := validateNearCacheOptions(cacheOptions.NearCacheOptions)
905+
err := ensureNearCacheOptions(cacheOptions.NearCacheOptions)
906906
if err != nil {
907907
return nil, err
908908
}

test/e2e/standalone/event_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func TestEventDisconnectWithReadyTimeoutDelay(t *testing.T) {
169169
fmt.Println("Issue stop of $GRPC:GrpcProxy")
170170
_, err := utils.IssuePostRequest("http://127.0.0.1:30000/management/coherence/cluster/services/$GRPC:GrpcProxy/members/1/stop")
171171
if err != nil {
172-
t.Error("Unable to issue post request to stop gRPC proxy")
172+
t.Error("Unable to issue post request to stop gRPC proxy", err)
173173
}
174174

175175
utils.Sleep(5)

test/e2e/standalone/near_cache_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ func TestNearCacheOperationsAgainstMapAndCache(t *testing.T) {
5757
{"RunTestNearCacheGetAllNamedCache2", GetNearCacheNamedCache[int, utils.Person](g, session, "near-cache-get-all-cache2", coherence.WithNearCache(&nearCacheOptions120Seconds)), RunTestNearCacheGetAll2},
5858
{"RunTestNearCacheWithHighUnitsNamedMap", GetNearCacheNamedMap[int, utils.Person](g, session, "near-cache-high-units-map", coherence.WithNearCache(&nearCacheOptionsHighUnits1)), RunTestNearCacheWithHighUnits},
5959
{"RunTestNearCacheWithHighUnitsNamedCache", GetNearCacheNamedCache[int, utils.Person](g, session, "near-cache-high-units-cache", coherence.WithNearCache(&nearCacheOptionsHighUnits1)), RunTestNearCacheWithHighUnits},
60-
{"RunTestNearCacheWithHighUnitsNamedMapPruneFactor", GetNearCacheNamedMap[int, utils.Person](g, session, "near-cache-high-units-map", coherence.WithNearCache(&nearCacheOptionsHighUnits3)), RunTestNearCacheWithHighUnits},
61-
{"RunTestNearCacheWithHighUnitsNamedCachePruneFactor", GetNearCacheNamedCache[int, utils.Person](g, session, "near-cache-high-units-cache", coherence.WithNearCache(&nearCacheOptionsHighUnits3)), RunTestNearCacheWithHighUnits},
60+
{"RunTestNearCacheWithHighUnitsNamedMapPruneFactor", GetNearCacheNamedMap[int, utils.Person](g, session, "near-cache-high-units-prune-map", coherence.WithNearCache(&nearCacheOptionsHighUnits3)), RunTestNearCacheWithHighUnits},
61+
{"RunTestNearCacheWithHighUnitsNamedCachePruneFactor", GetNearCacheNamedCache[int, utils.Person](g, session, "near-cache-high-units-prune-cache", coherence.WithNearCache(&nearCacheOptionsHighUnits3)), RunTestNearCacheWithHighUnits},
6262
{"RunTestNearCacheWithHighUnitsMemoryNamedMap", GetNearCacheNamedMap[int, utils.Person](g, session, "near-cache-high-units-mem-map", coherence.WithNearCache(&nearCacheOptionsHighUnits2)), RunTestNearCacheWithHighUnitsMemory},
6363
{"RunTestNearCacheWithHighUnitsMemoryNamedCache", GetNearCacheNamedCache[int, utils.Person](g, session, "near-cache-high-units-mem-cache", coherence.WithNearCache(&nearCacheOptionsHighUnits2)), RunTestNearCacheWithHighUnitsMemory},
6464
{"RunTestNearCacheWithHighUnitsAccessNamedMap", GetNearCacheNamedMap[int, utils.Person](g, session, "near-cache-high-units-access-mem-map", coherence.WithNearCache(&nearCacheOptionsHighUnits1)), RunTestNearCacheWithHighUnitsAccess},

0 commit comments

Comments
 (0)