Skip to content

Commit

Permalink
fix(gemini): make tests parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Kropachev committed Jul 3, 2023
1 parent 3e6d9a4 commit 0fe2312
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/auth/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
)

func TestSetAuthenticator(t *testing.T) {
t.Parallel()
username := "username"
password := "password"
expectedAuthenticator := gocql.PasswordAuthenticator{
Expand Down Expand Up @@ -60,6 +61,7 @@ func TestSetAuthenticator(t *testing.T) {
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
t.Parallel()
authenticator, err := auth.BuildAuthenticator(
test.input.username,
test.input.password,
Expand Down
1 change: 1 addition & 0 deletions pkg/generators/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
)

func TestGenerator(t *testing.T) {
t.Parallel()
table := &typedef.Table{
Name: "tbl",
PartitionKeys: generators.CreatePkColumns(1, "pk"),
Expand Down
2 changes: 2 additions & 0 deletions pkg/generators/statement_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func options(cql string) []string {
}

func TestGetCreateSchema(t *testing.T) {
t.Parallel()
ks := typedef.Keyspace{Name: "ks1"}
tests := map[string]struct {
table *typedef.Table
Expand Down Expand Up @@ -169,6 +170,7 @@ func TestGetCreateSchema(t *testing.T) {

for name, test := range tests {
t.Run(name, func(t *testing.T) {
t.Parallel()
got := generators.GetCreateTable(test.table, ks)
if diff := cmp.Diff(got, test.want); diff != "" {
t.Fatalf(diff)
Expand Down
3 changes: 3 additions & 0 deletions pkg/joberror/joberror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
)

func TestParallel(t *testing.T) {
t.Parallel()
wg := sync.WaitGroup{}
resultList := joberror.NewErrorList(1000)
expectedList := joberror.NewErrorList(1000)
Expand Down Expand Up @@ -69,6 +70,7 @@ func TestParallel(t *testing.T) {
}

func TestErrorSerialization(t *testing.T) {
t.Parallel()
expected := []byte(`{"timestamp":"2020-02-01T00:00:00Z","message":"Some Message","query":"Some Query","stmt-type":"Some Type"}`)
result, err := json.Marshal(joberror.JobError{
Timestamp: time.Date(2020, 02, 01, 0, 0, 0, 0, time.UTC),
Expand All @@ -86,6 +88,7 @@ func TestErrorSerialization(t *testing.T) {
}

func TestErrorListSerialization(t *testing.T) {
t.Parallel()
//nolint:lll
expected := []byte(`[{"timestamp":"2020-02-01T00:00:00Z","message":"Some Message 0","query":"Some Query 0","stmt-type":"Some Stmt Type 0"},{"timestamp":"2020-02-02T00:00:00Z","message":"Some Message 1","query":"Some Query 1","stmt-type":"Some Stmt Type 1"},{"timestamp":"2020-02-03T00:00:00Z","message":"Some Message 2","query":"Some Query 2","stmt-type":"Some Stmt Type 2"},{"timestamp":"2020-02-04T00:00:00Z","message":"Some Message 3","query":"Some Query 3","stmt-type":"Some Stmt Type 3"},{"timestamp":"2020-02-05T00:00:00Z","message":"Some Message 4","query":"Some Query 4","stmt-type":"Some Stmt Type 4"},{"timestamp":"2020-02-06T00:00:00Z","message":"Some Message 5","query":"Some Query 5","stmt-type":"Some Stmt Type 5"},{"timestamp":"2020-02-07T00:00:00Z","message":"Some Message 6","query":"Some Query 6","stmt-type":"Some Stmt Type 6"},{"timestamp":"2020-02-08T00:00:00Z","message":"Some Message 7","query":"Some Query 7","stmt-type":"Some Stmt Type 7"},{"timestamp":"2020-02-09T00:00:00Z","message":"Some Message 8","query":"Some Query 8","stmt-type":"Some Stmt Type 8"},{"timestamp":"2020-02-10T00:00:00Z","message":"Some Message 9","query":"Some Query 9","stmt-type":"Some Stmt Type 9"}]`)
lst := joberror.NewErrorList(1000)
Expand Down
7 changes: 7 additions & 0 deletions pkg/murmur/murmur_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

func TestRotl(t *testing.T) {
t.Parallel()
tests := []struct {
in, rotate, exp int64
}{
Expand All @@ -38,6 +39,7 @@ func TestRotl(t *testing.T) {

for _, test := range tests {
t.Run(fmt.Sprintf("%d >> %d", test.in, test.rotate), func(t *testing.T) {
t.Parallel()
if v := rotl(test.in, uint8(test.rotate)); v != test.exp {
t.Fatalf("expected %d got %d", test.exp, v)
}
Expand All @@ -46,6 +48,7 @@ func TestRotl(t *testing.T) {
}

func TestFmix(t *testing.T) {
t.Parallel()
tests := []struct {
in, exp int64
}{
Expand All @@ -58,6 +61,7 @@ func TestFmix(t *testing.T) {

for _, test := range tests {
t.Run(strconv.Itoa(int(test.in)), func(t *testing.T) {
t.Parallel()
if v := fmix(test.in); v != test.exp {
t.Fatalf("expected %d got %d", test.exp, v)
}
Expand All @@ -66,6 +70,7 @@ func TestFmix(t *testing.T) {
}

func TestMurmur3H1_CassandraSign(t *testing.T) {
t.Parallel()
key, err := hex.DecodeString("00104327529fb645dd00b883ec39ae448bb800000400066a6b00")
if err != nil {
t.Fatal(err)
Expand All @@ -80,6 +85,8 @@ func TestMurmur3H1_CassandraSign(t *testing.T) {

// Test the implementation of murmur3
func TestMurmur3H1(t *testing.T) {
t.Parallel()

// these examples are based on adding a index number to a sample string in
// a loop. The expected values were generated by the java datastax murmur3
// implementation. The number of examples here of increasing lengths ensure
Expand Down
2 changes: 2 additions & 0 deletions pkg/replication/replication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

func TestToCQL(t *testing.T) {
t.Parallel()
tests := map[string]struct {
rs *replication.Replication
want string
Expand All @@ -36,6 +37,7 @@ func TestToCQL(t *testing.T) {
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
t.Parallel()
got := test.rs.ToCQL()
if got != test.want {
t.Fatalf("expected '%s', got '%s'", test.want, got)
Expand Down
5 changes: 4 additions & 1 deletion pkg/routingkey/routing_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
)

func TestRoutingKey(t *testing.T) {
t.Parallel()
type data struct {
values typedef.Values
want []byte
Expand Down Expand Up @@ -462,8 +463,10 @@ func TestRoutingKey(t *testing.T) {
},
}

for name, test := range tests {
for name := range tests {
test := tests[name]
t.Run(name, func(t *testing.T) {
t.Parallel()
for _, d := range test.data {
result, err := rkc.CreateRoutingKey(test.table, d.values)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/stop/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
)

func TestHardStop(t *testing.T) {
t.Parallel()
testFlag, ctx, workersDone := initVars()
workers := 30

Expand All @@ -39,6 +40,7 @@ func TestHardStop(t *testing.T) {
}

func TestSoftStop(t *testing.T) {
t.Parallel()
testFlag, ctx, workersDone := initVars()
workers := 30

Expand All @@ -49,6 +51,7 @@ func TestSoftStop(t *testing.T) {
}

func TestSoftOrHardStop(t *testing.T) {
t.Parallel()
testFlag, ctx, workersDone := initVars()
workers := 30

Expand Down
3 changes: 3 additions & 0 deletions pkg/tableopts/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
)

func TestToCQL(t *testing.T) {
t.Parallel()

tests := map[string]struct {
rs string
want string
Expand Down Expand Up @@ -60,6 +62,7 @@ func TestToCQL(t *testing.T) {
}
for name, test := range tests {
t.Run(name, func(t *testing.T) {
t.Parallel()
if o, err := tableopts.FromCQL(test.rs); err != nil {
t.Error(err)
} else {
Expand Down
6 changes: 6 additions & 0 deletions pkg/typedef/columns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func TestColumnMarshalUnmarshal(t *testing.T) {
}

func TestMarshalUnmarshal(t *testing.T) {
t.Parallel()

s1 := getTestSchema()

opts := cmp.Options{
Expand All @@ -132,6 +134,8 @@ func TestMarshalUnmarshal(t *testing.T) {
}

func TestPrimitives(t *testing.T) {
t.Parallel()

sc := &typedef.SchemaConfig{
MaxPartitionKeys: 3,
MinPartitionKeys: 2,
Expand Down Expand Up @@ -201,6 +205,8 @@ func TestPrimitives(t *testing.T) {
}

func TestValidColumnsForDelete(t *testing.T) {
t.Parallel()

s1 := getTestSchema()
expected := typedef.Columns{
s1.Tables[0].Columns[2],
Expand Down
3 changes: 3 additions & 0 deletions pkg/typedef/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
)

func TestSchemaConfigValidate(t *testing.T) {
t.Parallel()

tests := map[string]struct {
config *SchemaConfig
want error
Expand Down Expand Up @@ -88,6 +90,7 @@ func TestSchemaConfigValidate(t *testing.T) {
cmp.AllowUnexported()
for name, test := range tests {
t.Run(name, func(t *testing.T) {
t.Parallel()
got := test.config.Valid()
//nolint:errorlint
if got != test.want {
Expand Down
2 changes: 2 additions & 0 deletions pkg/typedef/typedef_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
)

func TestValues(t *testing.T) {
t.Parallel()

tmp := make(Values, 0, 10)
expected := Values{1, 2, 3, 4, 5, 6, 7}
expected2 := Values{1, 2, 3, 4, 5, 6, 7, 8, 9}
Expand Down
2 changes: 2 additions & 0 deletions pkg/typedef/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ var prettytests = []struct {
}

func TestCQLPretty(t *testing.T) {
t.Parallel()

for _, p := range prettytests {
result, _ := p.typ.CQLPretty(p.query, p.values)
if result != p.expected {
Expand Down
2 changes: 2 additions & 0 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func BenchmarkUtilsRandString1000(t *testing.B) {
}

func TestRandString(t *testing.T) {
t.Parallel()

for _, ln := range []int{1, 3, 5, 16, 45, 100, 1000} {
out := utils.RandString(rnd, ln)
if len(out) != ln {
Expand Down

0 comments on commit 0fe2312

Please sign in to comment.