DATACASS-431 - Disable tests for ALTER TYPE support on Apache Cassandra 3.10.

Apache Cassandra does not allow altering column/field types since version 3.10. We don't run these tests anymore for version 3.10 and later.
This commit is contained in:
Mark Paluch
2017-04-19 12:08:25 +02:00
parent 0ff0f2348b
commit 352dfd6879
5 changed files with 35 additions and 11 deletions

View File

@@ -16,6 +16,7 @@
package org.springframework.cassandra.core.cql.generator;
import static org.assertj.core.api.Assertions.*;
import static org.junit.Assume.*;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -27,6 +28,8 @@ import org.springframework.cassandra.core.keyspace.TableOption;
import org.springframework.cassandra.core.keyspace.TableOption.CachingOption;
import org.springframework.cassandra.core.keyspace.TableOption.KeyCachingOption;
import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.integration.support.CassandraVersion;
import org.springframework.data.util.Version;
import com.datastax.driver.core.ColumnMetadata;
import com.datastax.driver.core.DataType;
@@ -40,16 +43,24 @@ import com.datastax.driver.core.TableMetadata;
*/
public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
static final Version CASSANDRA_3_10 = Version.parse("3.10");
Version cassandraVersion;
@Before
public void setUp() throws Exception {
cassandraVersion = CassandraVersion.get(session);
session.execute("DROP TABLE IF EXISTS addamsFamily;");
session.execute("DROP TABLE IF EXISTS users;");
}
@Test // DATACASS-192
@Test // DATACASS-192, DATACASS-429
public void alterTableAlterColumnType() {
assumeTrue(cassandraVersion.isLessThan(CASSANDRA_3_10));
session.execute(
"CREATE TABLE addamsFamily (name varchar PRIMARY KEY, gender varchar,\n" + " lastknownlocation bigint);");
@@ -63,9 +74,11 @@ public class AlterTableCqlGeneratorIntegrationTests extends AbstractKeyspaceCrea
assertThat(column.getType()).isEqualTo(DataType.varint());
}
@Test // DATACASS-192
@Test // DATACASS-192, DATACASS-429
public void alterTableAlterListColumnType() {
assumeTrue(cassandraVersion.isLessThan(CASSANDRA_3_10));
session.execute(
"CREATE TABLE addamsFamily (name varchar PRIMARY KEY, gender varchar,\n" + " lastknownlocation list<ascii>);");

View File

@@ -15,25 +15,34 @@
*/
package org.springframework.cassandra.core.cql.generator;
import static org.junit.Assume.*;
import static org.springframework.cassandra.core.cql.generator.AlterUserTypeCqlGenerator.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.cassandra.core.keyspace.AlterUserTypeSpecification;
import org.springframework.cassandra.test.integration.AbstractKeyspaceCreatingIntegrationTest;
import org.springframework.cassandra.test.integration.support.CassandraVersion;
import org.springframework.data.util.Version;
import com.datastax.driver.core.DataType;
/**
* Integration tests for {@link AlterUserTypeCqlGenerator}.
*
*
* @author Mark Paluch
*/
public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceCreatingIntegrationTest {
static final Version CASSANDRA_3_10 = Version.parse("3.10");
Version cassandraVersion;
@Before
public void setUp() throws Exception {
cassandraVersion = CassandraVersion.get(session);
session.execute("DROP TYPE IF EXISTS address;");
session.execute("CREATE TYPE address (zip text, state text);");
}
@@ -47,9 +56,11 @@ public class AlterUserTypeCqlGeneratorIntegrationTests extends AbstractKeyspaceC
session.execute(toCql(spec));
}
@Test // DATACASS-172
@Test // DATACASS-172, DATACASS-429
public void alterTypeShouldAlterField() {
assumeTrue(cassandraVersion.isLessThan(CASSANDRA_3_10));
AlterUserTypeSpecification spec = AlterUserTypeSpecification.alterType("address")//
.alter("zip", DataType.varchar());

View File

@@ -0,0 +1,50 @@
/*
* Copyright 2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cassandra.test.integration.support;
import lombok.experimental.UtilityClass;
import org.springframework.data.util.Version;
import org.springframework.util.Assert;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
import com.datastax.driver.core.Session;
/**
* Utility to retrieve the Cassandra release version.
*
* @author Mark Paluch
*/
@UtilityClass
public class CassandraVersion {
/**
* Retrieve the Cassandra release version.
*
* @param session must not be {@literal null}.
* @return the release {@link Version}.
*/
public static Version get(Session session) {
Assert.notNull(session, "Session must not be null");
ResultSet resultSet = session.execute("SELECT release_version FROM system.local;");
Row row = resultSet.one();
return Version.parse(row.getString(0));
}
}