From 7c2d6950a01c4496c7a89e05ebfe2ec1e172bb18 Mon Sep 17 00:00:00 2001 From: Tim Middleton Date: Fri, 8 Mar 2024 16:25:34 +0800 Subject: [PATCH] Fix failing test --- .github/workflows/test-coherence.yml | 2 +- coherence/coherence.go | 2 +- coherence/coherence_test.go | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-coherence.yml b/.github/workflows/test-coherence.yml index 158a1173..1e1a6b9f 100644 --- a/.github/workflows/test-coherence.yml +++ b/.github/workflows/test-coherence.yml @@ -24,7 +24,7 @@ jobs: uses: actions/checkout@v4 - name: Startup Coherence run: | - docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:22.06.5 + docker run -d -p 1408:1408 -p 30000:30000 ghcr.io/oracle/coherence-ce:23.09.2 sleep 30 - name: Install Go uses: actions/setup-go@v5 diff --git a/coherence/coherence.go b/coherence/coherence.go index 6c4fa328..36d51462 100644 --- a/coherence/coherence.go +++ b/coherence/coherence.go @@ -166,7 +166,7 @@ func (s *Storage) Delete(key string) error { } func (s *Storage) Reset() error { - return s.namedCache.Clear(s.ctx) + return s.namedCache.Truncate(s.ctx) } func (s *Storage) Close() error { diff --git a/coherence/coherence_test.go b/coherence/coherence_test.go index 96cfeb97..5c36b561 100644 --- a/coherence/coherence_test.go +++ b/coherence/coherence_test.go @@ -4,6 +4,7 @@ package coherence * Copyright © 2023, 2024 Oracle and/or its affiliates. */ import ( + "fmt" "github.com/stretchr/testify/require" "os" "testing" @@ -22,7 +23,8 @@ var testStore *Storage func TestMain(m *testing.M) { testStore, _ = New(Config{ - Reset: true, + Reset: true, + NearCacheTimeout: time.Duration(4) * time.Second, }) code := m.Run() @@ -34,9 +36,8 @@ func TestMain(m *testing.M) { // newTestStore returns a new Coherence Store and ensures it is reset. func newTestStore(t testing.TB, config ...Config) (*Storage, error) { t.Helper() - var err error - testStore, err = New(config...) + testStore, err := New(config...) require.NoError(t, err) err = testStore.Reset() @@ -98,7 +99,7 @@ func Test_Coherence_Set_With_Expiry(t *testing.T) { // set with an expiry of 5 seconds err := testStore.Set(key1, value1, time.Duration(5)*time.Second) require.NoError(t, err) - time.Sleep(time.Duration(10) * time.Second) + time.Sleep(time.Duration(6) * time.Second) val, err = testStore.Get(key1) require.NoError(t, err) @@ -137,6 +138,7 @@ func Test_Coherence_Reset(t *testing.T) { // check the keys have expired val, err = testStore.Get(key1) require.NoError(t, err) + fmt.Println("val=", string(val)) require.True(t, len(val) == 0) val, err = testStore.Get(key2)