Skip to content

Commit

Permalink
skip TestSchemaReset on cassandra < 2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Zariel committed Feb 6, 2016
1 parent 1ea72c1 commit 2e7c4f2
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions host_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
}
Expand Down
21 changes: 21 additions & 0 deletions host_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

}

0 comments on commit 2e7c4f2

Please sign in to comment.