Skip to content

Commit

Permalink
CNDB-11480: Split tests extending AbstractQueryTester (#1382)
Browse files Browse the repository at this point in the history
Split all the tests extending AbstractQueryTester so they are less prone to timeouts and better for CI parallelization. 
Each test class is split into a class per data model, and each class is still parameterized by index version. 
Also, move these tests and their utilities into their own package, and rename the two versions of AbstractQueryTester to SingleNodeQueryTester and MultiNodeQueryTester.
  • Loading branch information
adelapena authored Oct 30, 2024
1 parent a4a622e commit 5ae9066
Show file tree
Hide file tree
Showing 51 changed files with 1,046 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.cassandra.distributed.test.sai;
package org.apache.cassandra.distributed.test.sai.datamodels;

import java.util.ArrayList;
import java.util.Iterator;
Expand All @@ -25,8 +25,9 @@
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.distributed.Cluster;
import org.apache.cassandra.distributed.api.ConsistencyLevel;
import org.apache.cassandra.distributed.test.sai.SAIUtil;
import org.apache.cassandra.distributed.util.ColumnTypeUtil;
import org.apache.cassandra.index.sai.cql.DataModel;
import org.apache.cassandra.index.sai.cql.datamodels.DataModel;

public class MultiNodeExecutor implements DataModel.Executor
{
Expand Down Expand Up @@ -89,12 +90,12 @@ public List<Object> executeRemote(String query, int fetchSize, Object... values)
@Override
public void counterReset()
{
AbstractQueryTester.Counter.reset();
MultiNodeQueryTester.Counter.reset();
}

@Override
public long getCounter()
{
return AbstractQueryTester.Counter.get();
return MultiNodeQueryTester.Counter.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* limitations under the License.
*/

package org.apache.cassandra.distributed.test.sai;
package org.apache.cassandra.distributed.test.sai.datamodels;

import java.util.LinkedList;
import java.util.List;
Expand All @@ -33,20 +33,20 @@
import org.apache.cassandra.distributed.api.Feature;
import org.apache.cassandra.distributed.shared.Byteman;
import org.apache.cassandra.distributed.test.TestBaseImpl;
import org.apache.cassandra.index.sai.cql.DataModel;
import org.apache.cassandra.index.sai.cql.IndexQuerySupport;
import org.apache.cassandra.index.sai.cql.datamodels.DataModel;
import org.apache.cassandra.index.sai.cql.datamodels.IndexQuerySupport;
import org.apache.cassandra.utils.Shared;

@RunWith(Parameterized.class)
public class AbstractQueryTester extends TestBaseImpl
abstract class MultiNodeQueryTester extends TestBaseImpl
{
protected static final String INJECTION_SCRIPT = "RULE count searches\n" +
"CLASS org.apache.cassandra.index.sai.plan.StorageAttachedIndexSearcher\n" +
"METHOD search\n" +
"AT ENTRY\n" +
"IF TRUE\n" +
"DO\n" +
" org.apache.cassandra.distributed.test.sai.AbstractQueryTester$Counter.increment()\n" +
" org.apache.cassandra.distributed.test.sai.datamodels.MultiNodeQueryTester$Counter.increment()\n" +
"ENDRULE\n";

@Parameterized.Parameter(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* limitations under the License.
*/

package org.apache.cassandra.distributed.test.sai;
package org.apache.cassandra.distributed.test.sai.datamodels;

import org.junit.Test;

import org.apache.cassandra.index.sai.cql.IndexQuerySupport;
import org.apache.cassandra.index.sai.cql.datamodels.IndexQuerySupport;

public class QueryCellDeletionsTest extends AbstractQueryTester
public class QueryCellDeletionsTest extends MultiNodeQueryTester
{
@Test
public void testCellDeletions() throws Throwable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* limitations under the License.
*/

package org.apache.cassandra.distributed.test.sai;
package org.apache.cassandra.distributed.test.sai.datamodels;

import org.junit.Test;

import org.apache.cassandra.index.sai.cql.IndexQuerySupport;
import org.apache.cassandra.index.sai.cql.datamodels.IndexQuerySupport;

public class QueryRowDeletionsTest extends AbstractQueryTester
public class QueryRowDeletionsTest extends MultiNodeQueryTester
{
@Test
public void testRowDeletions() throws Throwable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* limitations under the License.
*/

package org.apache.cassandra.distributed.test.sai;
package org.apache.cassandra.distributed.test.sai.datamodels;

import org.junit.Test;

import org.apache.cassandra.index.sai.cql.IndexQuerySupport;
import org.apache.cassandra.index.sai.cql.datamodels.IndexQuerySupport;

public class QueryTimeToLiveTest extends AbstractQueryTester
public class QueryTimeToLiveTest extends MultiNodeQueryTester
{
@Test
public void testTimeToLive() throws Throwable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* limitations under the License.
*/

package org.apache.cassandra.distributed.test.sai;
package org.apache.cassandra.distributed.test.sai.datamodels;

import org.junit.Test;

import org.apache.cassandra.index.sai.cql.IndexQuerySupport;
import org.apache.cassandra.index.sai.cql.datamodels.IndexQuerySupport;

public class QueryWriteLifecycleTest extends AbstractQueryTester
public class QueryWriteLifecycleTest extends MultiNodeQueryTester
{
@Test
public void testWriteLifecycle() throws Throwable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.dht.RandomPartitioner.BigIntegerToken;
import org.apache.cassandra.index.sai.cql.DataModel;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand All @@ -16,9 +15,8 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.cassandra.index.sai.cql;
package org.apache.cassandra.index.sai.cql.datamodels;

import java.util.Collections;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand All @@ -8,17 +7,15 @@
* "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.
* 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.apache.cassandra.index.sai.cql;
package org.apache.cassandra.index.sai.cql.datamodels;

import java.util.Arrays;
import java.util.List;
Expand All @@ -41,7 +38,7 @@
import org.hamcrest.Matchers;

import static org.apache.cassandra.distributed.test.TestBaseImpl.list;
import static org.apache.cassandra.index.sai.cql.DataModel.INET_COLUMN;
import static org.apache.cassandra.index.sai.cql.datamodels.DataModel.INET_COLUMN;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cassandra.index.sai.cql;
package org.apache.cassandra.index.sai.cql.datamodels;

import org.junit.Ignore;
import org.junit.Test;

public class QueryCellDeletionsTest extends AbstractQueryTester
@Ignore
abstract class QueryCellDeletionsTester extends SingleNodeQueryTester
{
@Test
public void testCellDeletions() throws Throwable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright DataStax, Inc.
*
* 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.apache.cassandra.index.sai.cql.datamodels;

import java.util.List;

import org.junit.runners.Parameterized;

public class QueryCellDeletionsWithBaseDataModelTest extends QueryCellDeletionsTester
{
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> params()
{
return allIndexVersionsParams(SingleNodeQueryTester::baseDataModelParams);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright DataStax, Inc.
*
* 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.apache.cassandra.index.sai.cql.datamodels;

import java.util.List;

import org.junit.runners.Parameterized;

public class QueryCellDeletionsWithCompositePartitionKeyTest extends QueryCellDeletionsTester
{
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> params()
{
return allIndexVersionsParams(SingleNodeQueryTester::compositePartitionKeyParams);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright DataStax, Inc.
*
* 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.apache.cassandra.index.sai.cql.datamodels;

import java.util.List;

import org.junit.runners.Parameterized;

public class QueryCellDeletionsWithCompoundKeyTest extends QueryCellDeletionsTester
{
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> params()
{
return allIndexVersionsParams(SingleNodeQueryTester::compoundKeyParams);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright DataStax, Inc.
*
* 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.apache.cassandra.index.sai.cql.datamodels;

import java.util.List;

import org.junit.runners.Parameterized;

public class QueryCellDeletionsWithCompoundKeyWithStaticsTest extends QueryCellDeletionsTester
{
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> params()
{
return allIndexVersionsParams(SingleNodeQueryTester::compoundKeyWithStaticsParams);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.cassandra.index.sai.cql;
package org.apache.cassandra.index.sai.cql.datamodels;

import org.junit.Ignore;
import org.junit.Test;

public class QueryRowDeletionsTest extends AbstractQueryTester
@Ignore
abstract class QueryRowDeletionsTester extends SingleNodeQueryTester
{
@Test
public void testRowDeletions() throws Throwable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright DataStax, Inc.
*
* 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.apache.cassandra.index.sai.cql.datamodels;

import java.util.List;

import org.junit.runners.Parameterized;

public class QueryRowDeletionsWithBaseModelTest extends QueryRowDeletionsTester
{
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> params()
{
return allIndexVersionsParams(SingleNodeQueryTester::baseDataModelParams);
}
}
Loading

0 comments on commit 5ae9066

Please sign in to comment.