Skip to content

Commit

Permalink
Merge branch 'v0.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
farodin91 committed Sep 12, 2019
2 parents 224f80f + 25e8d48 commit eb275f9
Show file tree
Hide file tree
Showing 25 changed files with 368 additions and 270 deletions.
17 changes: 15 additions & 2 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ All of JanusGraph's tests are written for JUnit. JanusGraph's JUnit tests are a
| ------------- | ------------------- |:------------:| ------- |
| MEMORY_TESTS | test.skip.mem | true (disabled) | Tests intended to exert memory pressure |
| PERFORMANCE_TESTS | test.skip.perf | true (disabled) | Tests written as simple speed tests using JUnitBenchmarks|
| ORDERED_KEY_STORE_TESTS | test.skip.ordered | false (enabled) | Tests written for a storage backend that stores data in key order |
| UNORDERED_KEY_STORE_TESTS | test.skip.unordered | false (enabled) | Tests written for a storage backend that doesn't store data in key order |
| (No tag) | test.skip.default | false (enabled) | Tests without any Tag annotations |

**Tag Name** above is a Java interface defined in the package [org.janusgraph.testcategory](janusgraph-test/src/main/org/janusgraph/testcategory). These interfaces appear as arguments to the JUnit `@Tag(...)` annotation, e.g. `@Tag(TestCategory.MEMORY_TESTS)`.
Expand All @@ -46,6 +44,21 @@ If a test should be marked as flaky add following annotation to the test and ope
public void testFlakyFailsSometimes(){}
```

### Marking tests to require certain Features from StoreManager

A test can be annotated that a test is only execute, if the StoreManager support this feature.

```java
@FeatureFlag(feature = JanusGraphFeature.UnorderedScan)
public void testRequiresUnorderedScanOnDatabase(){}
```

| Feature flag | Required feature |
| ------------- | ---------------------------------- |
| UnorderedScan | `StoreFeatures.hasUnorderedScan()` |
| OrderedScan | `StoreFeatures.hasOrderedScan()` |
| CellTtl | `StoreFeatures.hasCellTtl()` |

### Running a Single Test via Maven

The standard maven-surefire-plugin option applies for most tests:
Expand Down
2 changes: 1 addition & 1 deletion janusgraph-berkeleyje/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>${test.excluded.groups},CELL_TTL_TESTS</excludedGroups>
<excludedGroups>${test.excluded.groups}</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand Down
4 changes: 2 additions & 2 deletions janusgraph-cassandra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
<phase>test</phase>
<configuration>
<argLine>${default.test.jvm.opts} -Dtest.cassandra.confdir=${project.build.directory}/cassandra/conf/localhost-bop -Dtest.cassandra.datadir=${project.build.directory}/cassandra/data/localhost-bop</argLine>
<excludedGroups>${test.excluded.groups},UNORDERED_KEY_STORE_TESTS,SERIAL_TESTS,CASSANDRA_SSL_TESTS</excludedGroups>
<excludedGroups>${test.excluded.groups},SERIAL_TESTS,CASSANDRA_SSL_TESTS</excludedGroups>
<groups />
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
Expand All @@ -323,7 +323,7 @@
<phase>test</phase>
<configuration>
<argLine>${default.test.jvm.opts} -Dtest.cassandra.confdir=${project.build.directory}/cassandra/conf/localhost-murmur -Dtest.cassandra.datadir=${project.build.directory}/cassandra/data/localhost-murmur</argLine>
<excludedGroups>${test.excluded.groups},ORDERED_KEY_STORE_TESTS,SERIAL_TESTS,CASSANDRA_SSL_TESTS</excludedGroups>
<excludedGroups>${test.excluded.groups},SERIAL_TESTS,CASSANDRA_SSL_TESTS</excludedGroups>
<groups />
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,25 @@

package org.janusgraph.diskstorage.cassandra;

import java.util.Collections;
import java.util.Map;

import org.janusgraph.TestCategory;
import com.google.common.collect.ImmutableMap;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.KeyColumnValueStoreTest;
import org.janusgraph.diskstorage.configuration.Configuration;
import org.janusgraph.diskstorage.configuration.ModifiableConfiguration;
import org.janusgraph.diskstorage.keycolumnvalue.StoreFeatures;
import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration;
import org.junit.jupiter.api.Tag;
import org.janusgraph.testutil.FeatureFlag;
import org.janusgraph.testutil.JanusGraphFeature;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.ImmutableMap;
import org.janusgraph.diskstorage.KeyColumnValueStoreTest;
import org.janusgraph.diskstorage.keycolumnvalue.StoreFeatures;
import java.util.Collections;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;

public abstract class AbstractCassandraStoreTest extends KeyColumnValueStoreTest {

private static final Logger log =
LoggerFactory.getLogger(AbstractCassandraStoreTest.class);
private static final String TEST_CF_NAME = "testcf";
private static final String DEFAULT_COMPRESSOR_PACKAGE = "org.apache.cassandra.io.compress";

Expand All @@ -49,34 +42,16 @@ public abstract class AbstractCassandraStoreTest extends KeyColumnValueStoreTest
public abstract AbstractCassandraStoreManager openStorageManager(Configuration c) throws BackendException;

@Test
@Tag(TestCategory.UNORDERED_KEY_STORE_TESTS)
public void testUnorderedConfiguration(TestInfo testInfo) {
if (!manager.getFeatures().hasUnorderedScan()) {
log.warn(
"Can't test key-unordered features on incompatible store. "
+ "This warning could indicate reduced test coverage and "
+ "a broken JUnit configuration. Skipping test {}.",
testInfo.getTestMethod().toString());
return;
}

@FeatureFlag(feature = JanusGraphFeature.UnorderedScan)
public void testUnorderedConfiguration() {
StoreFeatures features = manager.getFeatures();
assertFalse(features.isKeyOrdered());
assertFalse(features.hasLocalKeyPartition());
}

@Test
@Tag(TestCategory.ORDERED_KEY_STORE_TESTS)
public void testOrderedConfiguration(TestInfo testInfo) {
if (!manager.getFeatures().hasOrderedScan()) {
log.warn(
"Can't test key-ordered features on incompatible store. "
+ "This warning could indicate reduced test coverage and "
+ "a broken JUnit configuration. Skipping test {}.",
testInfo.getTestMethod().toString());
return;
}

@FeatureFlag(feature = JanusGraphFeature.OrderedScan)
public void testOrderedConfiguration() {
StoreFeatures features = manager.getFeatures();
assertTrue(features.isKeyOrdered());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

package org.janusgraph.diskstorage.cassandra.embedded;

import org.janusgraph.TestCategory;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.configuration.Configuration;
import org.janusgraph.diskstorage.configuration.ModifiableConfiguration;
import org.janusgraph.testutil.FeatureFlag;
import org.janusgraph.testutil.JanusGraphFeature;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import org.janusgraph.CassandraStorageSetup;
Expand Down Expand Up @@ -51,7 +51,7 @@ public AbstractCassandraStoreManager openStorageManager(Configuration c) throws
}

@Test
@Tag(TestCategory.ORDERED_KEY_STORE_TESTS)
@FeatureFlag(feature = JanusGraphFeature.OrderedScan)
public void testConfiguration() {
StoreFeatures features = manager.getFeatures();
assertTrue(features.isKeyOrdered());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
package org.janusgraph.diskstorage.cassandra.thrift;

import org.janusgraph.CassandraStorageSetup;
import org.janusgraph.TestCategory;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.DistributedStoreManagerTest;
import org.janusgraph.diskstorage.common.DistributedStoreManager.Deployment;
import org.janusgraph.testutil.FeatureFlag;
import org.janusgraph.testutil.JanusGraphFeature;
import org.junit.jupiter.api.*;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -45,7 +46,7 @@ public void tearDown() throws BackendException {

@Override
@Test
@Tag(TestCategory.ORDERED_KEY_STORE_TESTS)
@FeatureFlag(feature = JanusGraphFeature.OrderedScan)
public void testGetDeployment() {
final Deployment deployment = CassandraStorageSetup.HOSTNAME == null ? Deployment.LOCAL : Deployment.REMOTE;
assertEquals(deployment, manager.getDeployment());
Expand Down
12 changes: 6 additions & 6 deletions janusgraph-cql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
<cassandra.docker.version>${test.docker.version.cassandra2}</cassandra.docker.version>
<cassandra.docker.partitioner>${test.byteordered}</cassandra.docker.partitioner>
<test.skip.murmur-serial>true</test.skip.murmur-serial>
<test.cql.excludes>${test.excluded.groups},UNORDERED_KEY_STORE_TESTS,SERIAL_TESTS</test.cql.excludes>
<test.cql.excludes>${test.excluded.groups},SERIAL_TESTS</test.cql.excludes>
</properties>
</profile>
<profile>
Expand All @@ -204,7 +204,7 @@
<cassandra.docker.version>${test.docker.version.cassandra2}</cassandra.docker.version>
<cassandra.docker.partitioner>${test.murmur}</cassandra.docker.partitioner>
<test.skip.murmur-serial>false</test.skip.murmur-serial>
<test.cql.excludes>${test.excluded.groups},ORDERED_KEY_STORE_TESTS,SERIAL_TESTS</test.cql.excludes>
<test.cql.excludes>${test.excluded.groups},SERIAL_TESTS</test.cql.excludes>
</properties>
</profile>
<profile>
Expand All @@ -217,7 +217,7 @@
<cassandra.docker.partitioner>${test.murmur}</cassandra.docker.partitioner>
<cassandra.docker.useSSL>true</cassandra.docker.useSSL>
<test.skip.murmur-serial>false</test.skip.murmur-serial>
<test.cql.excludes>${test.excluded.groups},ORDERED_KEY_STORE_TESTS,SERIAL_TESTS</test.cql.excludes>
<test.cql.excludes>${test.excluded.groups},SERIAL_TESTS</test.cql.excludes>
</properties>
</profile>

Expand All @@ -230,7 +230,7 @@
<cassandra.docker.version>${test.docker.version.cassandra2}</cassandra.docker.version>
<cassandra.docker.partitioner>${test.byteordered}</cassandra.docker.partitioner>
<test.skip.murmur-serial>true</test.skip.murmur-serial>
<test.cql.excludes>${test.excluded.groups},UNORDERED_KEY_STORE_TESTS,SERIAL_TESTS</test.cql.excludes>
<test.cql.excludes>${test.excluded.groups},SERIAL_TESTS</test.cql.excludes>
</properties>
</profile>
<profile>
Expand All @@ -242,7 +242,7 @@
<cassandra.docker.version>${test.docker.version.cassandra3}</cassandra.docker.version>
<cassandra.docker.partitioner>${test.murmur}</cassandra.docker.partitioner>
<test.skip.murmur-serial>false</test.skip.murmur-serial>
<test.cql.excludes>${test.excluded.groups},ORDERED_KEY_STORE_TESTS,SERIAL_TESTS</test.cql.excludes>
<test.cql.excludes>${test.excluded.groups},SERIAL_TESTS</test.cql.excludes>
</properties>
</profile>
<profile>
Expand All @@ -255,7 +255,7 @@
<cassandra.docker.partitioner>${test.murmur}</cassandra.docker.partitioner>
<cassandra.docker.useSSL>true</cassandra.docker.useSSL>
<test.skip.murmur-serial>false</test.skip.murmur-serial>
<test.cql.excludes>${test.excluded.groups},ORDERED_KEY_STORE_TESTS,SERIAL_TESTS</test.cql.excludes>
<test.cql.excludes>${test.excluded.groups},SERIAL_TESTS</test.cql.excludes>
</properties>
</profile>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
package org.janusgraph.diskstorage.cql;

import org.janusgraph.JanusGraphCassandraContainer;
import org.janusgraph.TestCategory;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.DistributedStoreManagerTest;
import org.janusgraph.diskstorage.common.DistributedStoreManager.Deployment;
import org.janusgraph.diskstorage.configuration.ModifiableConfiguration;
import org.junit.jupiter.api.*;
import org.janusgraph.testutil.FeatureFlag;
import org.janusgraph.testutil.JanusGraphFeature;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

Expand Down Expand Up @@ -50,7 +53,7 @@ public void tearDown() throws BackendException {

@Override
@Test
@Tag(TestCategory.ORDERED_KEY_STORE_TESTS)
@FeatureFlag(feature = JanusGraphFeature.OrderedScan)
public void testGetDeployment() {
final Deployment deployment = Deployment.LOCAL;
assertEquals(deployment, manager.getDeployment());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

import com.datastax.driver.core.*;
import org.janusgraph.JanusGraphCassandraContainer;
import org.janusgraph.TestCategory;
import org.janusgraph.diskstorage.BackendException;
import org.janusgraph.diskstorage.KeyColumnValueStoreTest;
import org.janusgraph.diskstorage.configuration.Configuration;
import org.janusgraph.diskstorage.configuration.ModifiableConfiguration;
import org.janusgraph.diskstorage.keycolumnvalue.StoreFeatures;
import org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration;
import org.junit.jupiter.api.Tag;
import org.janusgraph.testutil.FeatureFlag;
import org.janusgraph.testutil.JanusGraphFeature;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.condition.EnabledIf;
Expand Down Expand Up @@ -74,34 +74,16 @@ public CQLStoreManager openStorageManager() throws BackendException {
}

@Test
@Tag(TestCategory.UNORDERED_KEY_STORE_TESTS)
@FeatureFlag(feature = JanusGraphFeature.UnorderedScan)
public void testUnorderedConfiguration(TestInfo testInfo) {
if (!this.manager.getFeatures().hasUnorderedScan()) {
LOGGER.warn(
"Can't test key-unordered features on incompatible store. "
+ "This warning could indicate reduced test coverage and "
+ "a broken JUnit configuration. Skipping test {}.",
testInfo.getDisplayName());
return;
}

final StoreFeatures features = this.manager.getFeatures();
assertFalse(features.isKeyOrdered());
assertFalse(features.hasLocalKeyPartition());
}

@Test
@Tag(TestCategory.ORDERED_KEY_STORE_TESTS)
@FeatureFlag(feature = JanusGraphFeature.OrderedScan)
public void testOrderedConfiguration(TestInfo testInfo) {
if (!this.manager.getFeatures().hasOrderedScan()) {
LOGGER.warn(
"Can't test key-ordered features on incompatible store. "
+ "This warning could indicate reduced test coverage and "
+ "a broken JUnit configuration. Skipping test {}.",
testInfo.getDisplayName());
return;
}

final StoreFeatures features = this.manager.getFeatures();
assertTrue(features.isKeyOrdered());
}
Expand Down
3 changes: 0 additions & 3 deletions janusgraph-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@
<goal>integration-test</goal>
</goals>
<configuration>
<excludedGroups>ORDERED_KEY_STORE_TESTS,UNORDERED_KEY_STORE_TESTS</excludedGroups>
<skip>${skipDefaultDistroIT}</skip>
<failIfNoTests>false</failIfNoTests>
<excludes>
Expand All @@ -615,7 +614,6 @@
</goals>
<configuration>
<argLine>-Dtest.cassandra.confdir=${project.build.directory}/cassandra/conf/localhost-murmur -Dtest.cassandra.datadir=${project.build.directory}/cassandra/data/localhost-murmur</argLine>
<excludedGroups>ORDERED_KEY_STORE_TESTS</excludedGroups>
<reportNameSuffix>murmur</reportNameSuffix>
<failIfNoTests>false</failIfNoTests>
<includes>
Expand All @@ -631,7 +629,6 @@
</goals>
<configuration>
<argLine>-Dtest.cassandra.confdir=${project.build.directory}/cassandra/conf/localhost-bop -Dtest.cassandra.datadir=${project.build.directory}/cassandra/data/localhost-bop</argLine>
<excludedGroups>UNORDERED_KEY_STORE_TESTS</excludedGroups>
<reportNameSuffix>bop</reportNameSuffix>
<failIfNoTests>false</failIfNoTests>
<includes>
Expand Down
2 changes: 1 addition & 1 deletion janusgraph-hbase-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<systemPropertyVariables>
<test.hbase.parentdir>${top.level.basedir}/janusgraph-hbase-parent</test.hbase.parentdir>
</systemPropertyVariables>
<excludedGroups>${test.excluded.groups},UNORDERED_KEY_STORE_TESTS</excludedGroups>
<excludedGroups>${test.excluded.groups}</excludedGroups>
</configuration>
</plugin>
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion janusgraph-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>${test.excluded.groups},CELL_TTL_TESTS</excludedGroups>
<excludedGroups>${test.excluded.groups}</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2019 JanusGraph 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.janusgraph;

import org.janusgraph.diskstorage.keycolumnvalue.StoreFeatures;

public interface JanusGraphBaseStoreFeaturesTest {
StoreFeatures getStoreFeatures();
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
public final class TestCategory {
public static final String BRITTLE_TESTS = "BRITTLE_TESTS";
public static final String SERIAL_TESTS = "SERIAL_TESTS";
public static final String ORDERED_KEY_STORE_TESTS = "ORDERED_KEY_STORE_TESTS";
public static final String UNORDERED_KEY_STORE_TESTS = "UNORDERED_KEY_STORE_TESTS";
public static final String MEMORY_TESTS = "MEMORY_TESTS";
public static final String PERFORMANCE_TESTS = "PERFORMANCE_TESTS";
public static final String CELL_TTL_TESTS = "CELL_TTL_TESTS";
}
Loading

0 comments on commit eb275f9

Please sign in to comment.