Skip to content

Commit 481d3c3

Browse files
committed
Finally fixed nasty integration test bugs due to refactoring efforts.
1 parent 7e6991b commit 481d3c3

File tree

6 files changed

+36
-152
lines changed

6 files changed

+36
-152
lines changed

comm/receiver.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,10 @@ func (recv *Receiver) ApplyStoredMsgs() {
507507
// Calculate size of needed buffer.
508508
bufferSize := logSize - curOffset
509509

510-
// Account for case when offset reached end of log file.
511-
if logSize == curOffset {
510+
// Account for case when offset reached end of log file
511+
// or accidentally the current offset is bigger than the
512+
// log file's size.
513+
if logSize <= curOffset {
512514

513515
// Reset position to beginning of file.
514516
_, err = recv.updLog.Seek(0, os.SEEK_SET)
@@ -562,7 +564,6 @@ func (recv *Receiver) ApplyStoredMsgs() {
562564
// If not, set indicator to false.
563565
if (msg.VClock[msg.Sender] != recv.vclock[msg.Sender]) &&
564566
(msg.VClock[msg.Sender] != (recv.vclock[msg.Sender] + 1)) {
565-
log.Printf("[comm.ApplyStoredMsgs] %s: not applying message because leap in causality and messages missing.\n", recv.name)
566567
applyMsg = false
567568
}
568569

@@ -574,7 +575,6 @@ func (recv *Receiver) ApplyStoredMsgs() {
574575
// and check if they do not exceed the locally stored
575576
// values for these nodes.
576577
if value > recv.vclock[node] {
577-
log.Printf("[comm.ApplyStoredMsgs] %s: not applying message because other elements exceeded.\n", recv.name)
578578
applyMsg = false
579579
break
580580
}
@@ -597,8 +597,6 @@ func (recv *Receiver) ApplyStoredMsgs() {
597597

598598
// Wait for done signal from node.
599599
<-recv.doneCRDTUpdChan
600-
} else {
601-
log.Printf("[comm.ApplyStoredMsgs] %s: message was a duplicate, already seen.\n", recv.name)
602600
}
603601

604602
for node, value := range msg.VClock {

distributor-commands_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"bufio"
55
"fmt"
66
"log"
7-
"os"
87
"testing"
98

109
"crypto/tls"
@@ -67,29 +66,6 @@ var loginTests = []struct {
6766

6867
// Functions
6968

70-
func TestMain(m *testing.M) {
71-
72-
var err error
73-
74-
// Create needed test environment.
75-
testEnv, err = utils.CreateTestEnv("./test-config.toml")
76-
if err != nil {
77-
log.Fatal(err)
78-
}
79-
80-
// Run all nodes in background.
81-
RunAllNodes(testEnv, "worker-1")
82-
83-
// Run all tests of this package.
84-
success := m.Run()
85-
86-
// Tear down test setup.
87-
TearDownNormalSetup(testEnv)
88-
89-
// Return with test return value.
90-
os.Exit(success)
91-
}
92-
9369
// TestCapability executes a black-box table test on the
9470
// implemented Capability() function.
9571
func TestCapability(t *testing.T) {

distributor_test.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

main_test.go

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,44 @@ package main
22

33
import (
44
"log"
5+
"os"
6+
"testing"
57
"time"
68

79
"github.com/numbleroot/pluto/imap"
810
"github.com/numbleroot/pluto/utils"
911
)
1012

11-
// Structs
13+
// Functions
14+
15+
// TestMain executes initilization and teardown
16+
// code needed for all tests in package main.
17+
func TestMain(m *testing.M) {
18+
19+
var err error
20+
21+
// Create needed test environment.
22+
testEnv, err = utils.CreateTestEnv("./test-config.toml")
23+
if err != nil {
24+
log.Fatal(err)
25+
}
26+
27+
// Run all nodes in background.
28+
RunAllNodes(testEnv, "worker-1")
29+
30+
// Run all tests of this package.
31+
success := m.Run()
32+
33+
// Give background synchronization enough
34+
// time to finish communication.
35+
time.Sleep(15 * time.Second)
36+
37+
// Tear down test setup.
38+
TearDownNormalSetup(testEnv)
39+
40+
// Return with test return value.
41+
os.Exit(success)
42+
}
1243

1344
// RunAllNodes runs all needed nodes for a proper multi-node
1445
// test setup in background. It also handles shutdown of these

storage_test.go

Lines changed: 0 additions & 39 deletions
This file was deleted.

worker_test.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)