[ 
https://issues.apache.org/jira/browse/CASSANDRA-6968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14012746#comment-14012746
 ] 

Tyler Hobbs commented on CASSANDRA-6968:
----------------------------------------

Nice speedup so far!

One thing I would do to cut down repetition in the setups is define a 
SchemaLoader.createKeyspace() method, something like this:

{code}
public void createKeyspace(String keyspaceName, Class<? extends 
AbstractReplicationStrategy> strategy,
                           Map<String, String> options, CFMetadata... cfmetas)
{
    if (!Gossiper.instance.isEnabled())
    {
        startGossiper();
        initSchema();
    }
    KSMetaData ksm = KSMetaData.testMetadata(keyspaceName, strategy, options, 
cfmetas);
    MigrationManager.announceNewKeyspace(ksm);
}
{code}

Then the tests could just do something like:

{code:java}
createKeyspace(KEYSPACE, SimpleStrategy.class, KSMetaData.optsWithRF(1),
               SchemaLoader.standardCFMD(KEYSPACE, CF1),
               SchemaLoader.standardCFMD(KEYSPACE, CF2);
{code}

for each keyspace they need to create.

Besides that, watch your whitespace.  Some of the indentation is off in the 
defineSchema() methods.

> Reduce Unit Test Times Due to Schema Loading
> --------------------------------------------
>
>                 Key: CASSANDRA-6968
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-6968
>             Project: Cassandra
>          Issue Type: Test
>          Components: Tests
>            Reporter: Tyler Hobbs
>            Assignee: Lyuben Todorov
>            Priority: Minor
>             Fix For: 2.1.1
>
>
> Unit tests which extend SchemaLoader take about 6s longer to run than the 
> others, on average.  We could greatly reduce the time it takes to run the 
> tests by improving this.
> None of the tests require everything that SchemaLoader does.  We should 
> change SchemaLoader into a set of test utilities that are run as needed in 
> {{\@BeforeClass}} and {{\@AfterClass}} methods.  Additionally, instead of 
> running a full cleanup, most tests could simply use a keyspace or column 
> family with a unique name (class/method name or perhaps class/method name + 
> timestamp).



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to