Skip to content

Commit

Permalink
chore: integration test improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
erayarslan committed Dec 6, 2023
1 parent cf76bb4 commit 57ea96f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
14 changes: 1 addition & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,4 @@ services:
test: [ "CMD", "curl", "-f", "http://user:123456@localhost:8091/pools/default/buckets/dcp-test" ]
interval: 2s
timeout: 3s
retries: 60
environment:
- USERNAME=admin
- PASSWORD=password


# test:
# build:
# context: "test/integration"
# depends_on:
# - couchbase
# links:
# - couchbase
retries: 60
20 changes: 11 additions & 9 deletions test/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ package integration

import (
"context"
"github.com/Trendyol/go-dcp"
"github.com/Trendyol/go-dcp/models"
"log"
"sync"
"testing"
"time"

"github.com/Trendyol/go-dcp"
"github.com/Trendyol/go-dcp/models"
)

var mutationCount = 0
var deletionCount = 0
var expirationCount = 0
var (
mutationCount = 0
deletionCount = 0
expirationCount = 0
)

func listener(ctx *models.ListenerContext) {
switch ctx.Event.(type) {
Expand All @@ -27,6 +30,7 @@ func listener(ctx *models.ListenerContext) {
}

func TestCouchbase(t *testing.T) {
time.Sleep(10 * time.Second)
newDcp, err := dcp.NewDcp("config.yml", listener)
if err != nil {
log.Fatalf("couldn't create dcp err: %v", err)
Expand All @@ -40,7 +44,6 @@ func TestCouchbase(t *testing.T) {
}()

go func() {
time.Sleep(5 * time.Second)
ctx, _ := context.WithTimeout(context.Background(), 20*time.Second)
for {
select {
Expand All @@ -51,13 +54,12 @@ func TestCouchbase(t *testing.T) {
newDcp.Close()
return
}
time.Sleep(1 * time.Second)
time.Sleep(time.Second)
}
}
}()

time.Sleep(500 * time.Second)
time.Sleep(time.Second)

wg.Wait()
t.Log("done")
}

0 comments on commit 57ea96f

Please sign in to comment.