Skip to content

Commit

Permalink
Fix integration test
Browse files Browse the repository at this point in the history
Signed-off-by: clyang82 <[email protected]>
  • Loading branch information
clyang82 committed Jan 3, 2025
1 parent d21b267 commit e27323a
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions test/integration/db_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package integration

import (
"context"
"fmt"
"testing"
"time"

. "github.com/onsi/gomega"

"github.com/openshift-online/maestro/test"
)

Expand Down Expand Up @@ -34,18 +37,20 @@ func TestWaitForNotification(t *testing.T) {

// Simulate an errListenerClosed and wait for the listener to be recreated
listener.Close()
time.Sleep(2 * time.Second)

var newListenerId string
g2.Raw("SELECT pid FROM pg_stat_activity WHERE query LIKE 'LISTEN%'").Scan(&newListenerId)
if newListenerId == "" {
t.Errorf("the new Listener was not created")
}
Eventually(func() error {
var newListenerId string
g2.Raw("SELECT pid FROM pg_stat_activity WHERE query LIKE 'LISTEN%'").Scan(&newListenerId)
if newListenerId == "" {
return fmt.Errorf("the new Listener was not created")
}
// Validate the listener was recreated
if originalListenerId == newListenerId {
return fmt.Errorf("Listener was not recreated")
}
return nil
}, 10*time.Second, 1*time.Second).Should(Succeed())

// Validate the listener was recreated
if originalListenerId == newListenerId {
t.Errorf("Listener was not recreated")
}
// send a notification to the new listener
g2.Exec("NOTIFY events, 'test'")

Expand Down

0 comments on commit e27323a

Please sign in to comment.