Pārlūkot izejas kodu

skip TestSchemaReset on cassandra < 2.1.3

Chris Bannister 9 gadi atpakaļ
vecāks
revīzija
2e7c4f27fa
4 mainītis faili ar 49 papildinājumiem un 1 dzēšanām
  1. 4 0
      cassandra_test.go
  2. 5 1
      common_test.go
  3. 19 0
      host_source.go
  4. 21 0
      host_source_test.go

+ 4 - 0
cassandra_test.go

@@ -2285,6 +2285,10 @@ func TestUnmarshallNestedTypes(t *testing.T) {
 }
 
 func TestSchemaReset(t *testing.T) {
+	if flagCassVersion.Major == 0 || (flagCassVersion.Before(2, 1, 3)) {
+		t.Skipf("skipping TestSchemaReset due to CASSANDRA-7910 in Cassandra <2.1.3 version=%v", flagCassVersion)
+	}
+
 	cluster := createCluster()
 	cluster.NumConns = 1
 

+ 5 - 1
common_test.go

@@ -22,10 +22,14 @@ var (
 	flagRunAuthTest  = flag.Bool("runauth", false, "Set to true to run authentication test")
 	flagCompressTest = flag.String("compressor", "", "compressor to use")
 	flagTimeout      = flag.Duration("gocql.timeout", 5*time.Second, "sets the connection `timeout` for all operations")
-	clusterHosts     []string
+
+	flagCassVersion cassVersion
+	clusterHosts    []string
 )
 
 func init() {
+	flag.Var(&flagCassVersion, "gocql.cversion", "the cassandra version being tested against")
+
 	flag.Parse()
 	clusterHosts = strings.Split(*flagCluster, ",")
 	log.SetFlags(log.Lshortfile | log.LstdFlags)

+ 19 - 0
host_source.go

@@ -29,6 +29,14 @@ type cassVersion struct {
 	Major, Minor, Patch int
 }
 
+func (c *cassVersion) Set(v string) error {
+	if v == "" {
+		return nil
+	}
+
+	return c.UnmarshalCQL(nil, []byte(v))
+}
+
 func (c *cassVersion) UnmarshalCQL(info TypeInfo, data []byte) error {
 	version := strings.TrimSuffix(string(data), "-SNAPSHOT")
 	version = strings.TrimPrefix(version, "v")
@@ -55,6 +63,17 @@ func (c *cassVersion) UnmarshalCQL(info TypeInfo, data []byte) error {
 	return nil
 }
 
+func (c cassVersion) Before(major, minor, patch int) bool {
+	if c.Major > major {
+		return true
+	} else if c.Minor > minor {
+		return true
+	} else if c.Patch > patch {
+		return true
+	}
+	return false
+}
+
 func (c cassVersion) String() string {
 	return fmt.Sprintf("v%d.%d.%d", c.Major, c.Minor, c.Patch)
 }

+ 21 - 0
host_source_test.go

@@ -21,3 +21,24 @@ func TestUnmarshalCassVersion(t *testing.T) {
 		}
 	}
 }
+
+func TestCassVersionBefore(t *testing.T) {
+	tests := [...]struct {
+		version             cassVersion
+		major, minor, patch int
+	}{
+		{cassVersion{1, 0, 0}, 0, 0, 0},
+		{cassVersion{0, 1, 0}, 0, 0, 0},
+		{cassVersion{0, 0, 1}, 0, 0, 0},
+
+		{cassVersion{1, 0, 0}, 0, 1, 0},
+		{cassVersion{0, 1, 0}, 0, 0, 1},
+	}
+
+	for i, test := range tests {
+		if !test.version.Before(test.major, test.minor, test.patch) {
+			t.Errorf("%d: expected v%d.%d.%d to be before %v", i, test.major, test.minor, test.patch, test.version)
+		}
+	}
+
+}