-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathmixedversion_test.go
50 lines (40 loc) · 1.33 KB
/
mixedversion_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2023 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package mixedversion
import (
"testing"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/option"
"github.com/stretchr/testify/require"
)
func Test_assertValidTest(t *testing.T) {
var fatalErr error
fatalFunc := func() func(...interface{}) {
fatalErr = nil
return func(args ...interface{}) {
require.Len(t, args, 1)
err, isErr := args[0].(error)
require.True(t, isErr)
fatalErr = err
}
}
notEnoughNodes := option.NodeListOption{1, 2, 3}
tooManyNodes := option.NodeListOption{1, 2, 3, 5, 6}
for _, crdbNodes := range []option.NodeListOption{notEnoughNodes, tooManyNodes} {
mvt := newTest()
mvt.crdbNodes = crdbNodes
assertValidTest(mvt, fatalFunc())
require.Error(t, fatalErr)
require.Contains(t, fatalErr.Error(), "mixedversion.NewTest: invalid cluster: use of fixtures requires 4 cockroach nodes")
mvt = newTest(NeverUseFixtures)
mvt.crdbNodes = crdbNodes
assertValidTest(mvt, fatalFunc())
require.NoError(t, fatalErr)
}
}