[ https://issues.apache.org/jira/browse/CASSANDRA-18066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Stefan Miklosovic updated CASSANDRA-18066: ------------------------------------------ Bug Category: Parent values: Code(13163) Complexity: Normal Discovered By: Code Inspection Severity: Normal Assignee: Stefan Miklosovic Status: Open (was: Triage Needed) > 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