[ 
https://issues.apache.org/jira/browse/CASSANDRA-18066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Miklosovic updated CASSANDRA-18066:
------------------------------------------
    Test and Documentation Plan: run CI
                         Status: Patch Available  (was: Open)

List of classes which extend CQLTester, contain BeforeClass and prepareServer is

{code}
for i in $(find . -type f -name '*.java' | xargs grep  'extends CQLTester' | 
cut -d":" -f1 ); do if [ $(grep '@BeforeClass' $i | wc -l) != "0" -a $(grep 
'prepareServer' $i | wc -l) != "0" ]; then echo $i; fi ; done
{code}

which yields

{code}
./unit/org/apache/cassandra/db/rows/ThrottledUnfilteredIteratorTest.java
./unit/org/apache/cassandra/db/memtable/MemtableQuickTest.java
./unit/org/apache/cassandra/tools/nodetool/VerifyTest.java
./unit/org/apache/cassandra/cql3/selection/SelectionColumnMappingTest.java
./unit/org/apache/cassandra/cql3/CustomNowInSecondsTest.java
./unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java
./unit/org/apache/cassandra/cql3/validation/entities/JsonTest.java
./unit/org/apache/cassandra/cql3/validation/entities/FrozenCollectionsTest.java
./unit/org/apache/cassandra/cql3/validation/entities/UserTypesTest.java
{code}

I fixed these classes here:

https://github.com/apache/cassandra/pull/2148

[~jlewandowski] would you mind to take a look?

> Server should be started in @Before rather than @BeforeClass in CQLTester
> -------------------------------------------------------------------------
>
>                 Key: CASSANDRA-18066
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-18066
>             Project: Cassandra
>          Issue Type: Bug
>          Components: Test/unit
>            Reporter: Jacek Lewandowski
>            Assignee: Stefan Miklosovic
>            Priority: Normal
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> I can see that there is some misunderstanding in the project of 
> {{@BeforeClass}} annotated methods. 
> Given we have a static method {{@BeforeClass static void initA()}} in 
> {{CQLTester}} and {{@BeforeClass static void initB()}} in {{SomeTestClass 
> extends CQLTester}}, it will run like the following:
> 1. static initializer of {{CQLTester}}
> 2. {{initA()}}
> 3. static initializer of {{SomeTestClass}}
> 4. {{initB()}}
> Since the server is started in (2), there is essentially no way to 
> consistently set startup properties or configuration of 
> {{DatabaseDescriptor}} in {{SomeTestClass}} so that the starting server can 
> pick it consistently. That is, if something works, it is just because some 
> server class has not been used yet, but this actually cannot be guaranteed.
> When I look in the code, it seems like the understanding of JUnit was that if 
> {{initB()}} is defined, then {{initA()}} is not called, but this is not true.
> Therefore, I propose to move the server initialization from {{initA()}} (call 
> to {{SchemaLoader.prepareServer()}} to a method annotated with {{@Before}} in 
> {{CQLTester}} so that the server is started with the first test case. Then, 
> we will be sure that call to {{initB()}} will happen before the server is 
> initialized and we will be able to set configuration consistently.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to