Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance slow-propose test configuration #109

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions mir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import (
"path/filepath"
"time"

"github.com/filecoin-project/mir/pkg/iss"
t "github.com/filecoin-project/mir/pkg/types"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

Expand Down Expand Up @@ -147,15 +144,6 @@ var _ = Describe("Basic test", func() {
}
})

// Create an alternative ISS configuration for a 4-node deployment with a long batch timeout.
// It will be used to simulate one node being slow.
membership := make([]t.NodeID, 4)
for i := 0; i < len(membership); i++ {
membership[i] = t.NewNodeIDFromInt(i)
}
slowProposeConfig := iss.DefaultConfig(membership)
slowProposeConfig.MaxProposeDelay = 2 * time.Second

DescribeTable("Simple tests", testFunc,
Entry("Does nothing with 1 node", &deploytest.TestConfig{
NumReplicas: 1,
Expand All @@ -164,11 +152,11 @@ var _ = Describe("Basic test", func() {
Duration: 4 * time.Second,
}),
Entry("Does nothing with 4 nodes", &deploytest.TestConfig{
NumReplicas: 4,
Transport: "fake",
Directory: "",
Duration: 20 * time.Second,
FirstReplicaISSConfig: slowProposeConfig,
NumReplicas: 4,
Transport: "fake",
Directory: "",
Duration: 20 * time.Second,
SlowProposeReplicas: map[int]bool{0: true},
}),
Entry("Submits 10 fake requests with 1 node", &deploytest.TestConfig{
NumReplicas: 1,
Expand All @@ -186,13 +174,13 @@ var _ = Describe("Basic test", func() {
Duration: 4 * time.Second,
}),
Entry("Submits 100 fake requests with 4 nodes", &deploytest.TestConfig{
NumReplicas: 4,
NumClients: 0,
Transport: "fake",
NumFakeRequests: 100,
Directory: "",
Duration: 10 * time.Second,
FirstReplicaISSConfig: slowProposeConfig,
NumReplicas: 4,
NumClients: 0,
Transport: "fake",
NumFakeRequests: 100,
Directory: "",
Duration: 10 * time.Second,
SlowProposeReplicas: map[int]bool{0: true},
}),
Entry("Submits 10 fake requests with 4 nodes and actual networking", &deploytest.TestConfig{
NumReplicas: 4,
Expand Down
19 changes: 11 additions & 8 deletions pkg/deploytest/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ type TestConfig struct {
// Duration after which the test deployment will be asked to shut down.
Duration time.Duration

// If not nil, the TestReplica with ID 0 will use this ISS configuration instead of the default one.
FirstReplicaISSConfig *iss.Config
// A set of replicas that are slow in proposing batches that is likely to trigger view change.
SlowProposeReplicas map[int]bool

// Logger to use for producing diagnostic messages.
Logger logging.Logger
Expand Down Expand Up @@ -128,13 +128,16 @@ func NewDeployment(testConfig *TestConfig) (*Deployment, error) {
)
}

// Create instance of TestReplica.
// The first TestReplica might get a special ISS configuration.
// This is useful if one replica should do something else than the others during the test (e.g., fail).
var issConfig *iss.Config
if i == 0 {
issConfig = testConfig.FirstReplicaISSConfig
// ISS configuration
issConfig := iss.DefaultConfig(membership)
if testConfig.SlowProposeReplicas[i] {
// Increase MaxProposeDelay such that it is likely to trigger view change by the batch timeout.
// Since a sensible value for the segment timeout needs to be stricter than the batch timeout,
// in the worst case, it will trigger view change by the segment timeout.
issConfig.MaxProposeDelay = issConfig.PBFTViewChangeBatchTimeout
}

// Create instance of TestReplica.
replicas[i] = &TestReplica{
ID: t.NewNodeIDFromInt(i),
Config: config,
Expand Down