Skip to content

Commit

Permalink
add test for uniform workload
Browse files Browse the repository at this point in the history
  • Loading branch information
pdziepak committed May 22, 2017
1 parent 3ac9251 commit 1acb21b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions workloads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,45 @@ func TestSequentialWorkload(t *testing.T) {
})
}
}

func TestUniformWorkload(t *testing.T) {
generator := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
testCases := []struct {
partitionCount int
clusteringRowCount int
}{
{20, 30},
{1, 1},
{generator.Intn(100) + 100, generator.Intn(99) + 1},
{generator.Intn(100), generator.Intn(100)},
{generator.Intn(100) + 100, 1},
{generator.Intn(100) + 100, generator.Intn(99) + 1},
{generator.Intn(100) + 100, generator.Intn(99) + 1},
}

for i, tc := range testCases {
t.Run(fmt.Sprintf("rand%d", i), func(t *testing.T) {
wrkld := NewRandomUniform(i, tc.partitionCount, tc.clusteringRowCount)

for i := 0; i < 1000; i++ {
if wrkld.IsDone() {
t.Error("got end of stream")
}

pk := wrkld.NextPartitionKey()
if pk < 0 || pk >= tc.partitionCount {
t.Errorf("PK %d out of range: [0-%d)", pk, tc.partitionCount)
}

ck := wrkld.NextClusteringKey()
if ck < 0 || ck >= tc.clusteringRowCount {
t.Errorf("CK %d out of range: [0-%d)", pk, tc.clusteringRowCount)
}

if wrkld.IsPartitionDone() {
t.Error("got end of partition")
}
}
})
}
}

0 comments on commit 1acb21b

Please sign in to comment.