Skip to content

Commit

Permalink
Add delays to all e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aalda committed Feb 25, 2019
1 parent 98e69b0 commit d79c9c9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion tests/e2e/add_verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package e2e
import (
"fmt"
"testing"
"time"

"github.com/bbva/qed/hashing"
"github.com/bbva/qed/protocol"
Expand All @@ -29,7 +30,7 @@ import (

func TestAddVerify(t *testing.T) {
before, after := setupServer(0, "", false, t)
scenario, let := scope.Scope(t, before, after)
scenario, let := scope.Scope(t, before, merge(after, delay(2*time.Second)))

event := rand.RandomString(10)

Expand Down
5 changes: 1 addition & 4 deletions tests/e2e/agents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,10 @@ func TestAgents(t *testing.T) {
bAuditor, aAuditor := setupAuditor(0, t)
bMonitor, aMonitor := setupMonitor(0, t)
bPublisher, aPublisher := setupPublisher(0, t)
delay := func(t *testing.T) {
time.Sleep(2 * time.Second)
}

scenario, let := scope.Scope(t,
merge(bServer, bStore, bPublisher, bAuditor, bMonitor),
merge(aServer, aPublisher, aAuditor, aMonitor, aStore, delay),
merge(aServer, aPublisher, aAuditor, aMonitor, aStore, delay(2*time.Second)),
)

event := rand.RandomString(10)
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

func Test_Client_To_Single_Server(t *testing.T) {
before, after := setupServer(0, "", true, t)
scenario, let := scope.Scope(t, before, merge(after))
scenario, let := scope.Scope(t, before, merge(after, delay(2*time.Second)))

scenario("Add one event through cli and verify it", func() {

Expand Down Expand Up @@ -110,7 +110,7 @@ func Test_Client_To_Cluster_With_Leader_Change(t *testing.T) {

serversHttpAddr := "http://127.0.0.1:8800"

scenario, let := scope.Scope(t, merge(before0, before1, before2), merge(after1, after2))
scenario, let := scope.Scope(t, merge(before0, before1, before2), merge(after1, after2, delay(2*time.Second)))

scenario("Add one event through cli and verify it", func() {
let("Add event", func(t *testing.T) {
Expand Down Expand Up @@ -212,7 +212,7 @@ func Test_Client_To_Cluster_With_Bad_Endpoint(t *testing.T) {

serversHttpAddr := "badendpoint,http://127.0.0.1:8800"

scenario, let := scope.Scope(t, merge(before0, before1), merge(after0, after1))
scenario, let := scope.Scope(t, merge(before0, before1), merge(after0, after1, delay(2*time.Second)))

scenario("Success by extracting topology from right endpoint", func() {
let("Add event", func(t *testing.T) {
Expand Down Expand Up @@ -264,7 +264,7 @@ func Test_Client_To_Cluster_Continuous_Load_Node_Fails(t *testing.T) {

serversHttpAddr := "http://127.0.0.1:8800,http://127.0.0.1:8801"

scenario, let := scope.Scope(t, merge(before0, before1), merge(after1))
scenario, let := scope.Scope(t, merge(before0, before1), merge(after1, delay(2*time.Second)))

scenario("Success by extracting topology from right endpoint", func() {
let("Add event", func(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/incremental_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package e2e

import (
"testing"
"time"

"github.com/bbva/qed/hashing"
"github.com/bbva/qed/protocol"
Expand All @@ -29,7 +30,7 @@ import (

func TestIncrementalConsistency(t *testing.T) {
before, after := setupServer(0, "", false, t)
scenario, let := scope.Scope(t, before, after)
scenario, let := scope.Scope(t, before, merge(after, delay(2*time.Second)))

scenario("Add multiple events and verify consistency between two of them", func() {

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"os/exec"
"testing"
"time"

"github.com/bbva/qed/testutils/scope"
assert "github.com/stretchr/testify/require"
Expand All @@ -37,7 +38,7 @@ func TestStart(t *testing.T) {

scenario, let := scope.Scope(t,
merge(bServer),
merge(aServer),
merge(aServer, delay(2*time.Second)),
)

scenario("Test availability of profiling server", func() {
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ func merge(list ...scope.TestF) scope.TestF {
}
}

func delay(duration time.Duration) scope.TestF {
return func(t *testing.T) {
time.Sleep(duration)
}
}

func newAgent(id int, name string, role member.Type, p gossip.Processor, t *testing.T) *gossip.Agent {
agentConf := gossip.DefaultConfig()
agentConf.NodeName = fmt.Sprintf("%s%d", name, id)
Expand Down

0 comments on commit d79c9c9

Please sign in to comment.