Skip to content

Commit

Permalink
Merge pull request cockroachdb#7500 from cuongdo/allocator_test_tweaks
Browse files Browse the repository at this point in the history
acceptance: allocator test tweaks
  • Loading branch information
cuongdo authored Jun 28, 2016
2 parents 08d0ffa + 1ea18a9 commit d4fa844
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
25 changes: 8 additions & 17 deletions acceptance/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ type allocatorTest struct {
// Prefix is the prefix that will be prepended to all resources created by
// Terraform.
Prefix string
// RebalanceTimeout is the max time we'll wait for the cluster to finish
// rebalancing.
RebalanceTimeout time.Duration
// CockroachDiskSizeGB is the size, in gigabytes, of the disks allocated
// for CockroachDB nodes. Leaving this as 0 accepts the default in the
// Terraform configs. This must be in GB, because Terraform only accepts
Expand Down Expand Up @@ -285,7 +282,6 @@ func (at *allocatorTest) WaitForRebalance() error {
_ = db.Close()
}()

timeoutTimer := time.After(at.RebalanceTimeout)
var timer timeutil.Timer
defer timer.Stop()
timer.Reset(0)
Expand All @@ -304,8 +300,6 @@ func (at *allocatorTest) WaitForRebalance() error {
}
return nil
}
case <-timeoutTimer:
return errors.New("timeout expired")
case <-stopper:
return errors.New("interrupted")
}
Expand All @@ -318,11 +312,10 @@ func (at *allocatorTest) WaitForRebalance() error {
// containing 10 GiB of data and growing to 3 nodes.
func TestUpreplicate1to3Small(t *testing.T) {
at := allocatorTest{
StartNodes: 1,
EndNodes: 3,
StoreURL: archivedStoreURL + "/1node-10g-262ranges",
Prefix: "uprep-1to3-small",
RebalanceTimeout: time.Hour,
StartNodes: 1,
EndNodes: 3,
StoreURL: archivedStoreURL + "/1node-10g-262ranges",
Prefix: "uprep-1to3-small",
}
at.Run(t)
}
Expand All @@ -331,11 +324,10 @@ func TestUpreplicate1to3Small(t *testing.T) {
// containing 10 GiB of data) and growing to 5 nodes.
func TestRebalance3to5Small(t *testing.T) {
at := allocatorTest{
StartNodes: 3,
EndNodes: 5,
StoreURL: archivedStoreURL + "/3nodes-10g-262ranges",
Prefix: "rebal-3to5-small",
RebalanceTimeout: time.Hour,
StartNodes: 3,
EndNodes: 5,
StoreURL: archivedStoreURL + "/3nodes-10g-262ranges",
Prefix: "rebal-3to5-small",
}
at.Run(t)
}
Expand All @@ -348,7 +340,6 @@ func TestUpreplicate1To3Medium(t *testing.T) {
EndNodes: 3,
StoreURL: archivedStoreURL + "/1node-2065replicas-108G",
Prefix: "uprep-1to3-med",
RebalanceTimeout: 4 * time.Hour,
CockroachDiskSizeGB: 250, // GB
}
at.Run(t)
Expand Down
11 changes: 7 additions & 4 deletions acceptance/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,19 @@ func farmer(t *testing.T, prefix string) *terrafarm.Farmer {
if !prefixRE.MatchString(prefix) {
t.Fatalf("farmer prefix must match regex %s", prefixRE)
}
dt := timeutil.Now().Format("20060102-1504")
f := &terrafarm.Farmer{
Output: os.Stderr,
Cwd: *flagCwd,
LogDir: logDir,
KeyName: *flagKeyName,
Stores: stores,
Prefix: prefix,
// Prepend Terraform resource names and state file name with date/time to
// allow concurrent runs of the same test.
StateFile: timeutil.Now().Format("20060102-150405-") + prefix + ".tfstate",
// We concatenate the current date/time to the prefix (for Terraform
// resource names) to allow multiple instances of the same test to run
// concurrently. The prefix is also used as the name of the Terraform state
// file.
Prefix: prefix + "-" + dt,
StateFile: prefix + "-" + dt + ".tfstate",
AddVars: make(map[string]string),
KeepClusterAfterTest: *flagTFKeepCluster,
}
Expand Down

0 comments on commit d4fa844

Please sign in to comment.