You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2019/06/18 10:27:12 UTC

[tinkerpop] branch TINKERPOP-2238 updated (5935b8f -> cba5081)

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a change to branch TINKERPOP-2238
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


    from 5935b8f  TINKERPOP-2238 Fixed iterator leaks in  generator tests
     new ac22cf9  TINKERPOP-2238 Removed the temporary IgnoreIteratorLeak
     new cba5081  TINKERPOP-2238 Updates to dev docs around iterator leaks.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../dev/developer/development-environment.asciidoc |  1 +
 docs/src/dev/provider/index.asciidoc               |  8 +++--
 .../tinkerpop/gremlin/AbstractGremlinTest.java     |  8 ++---
 .../tinkerpop/gremlin/IgnoreIteratorLeak.java      | 41 ----------------------
 .../generator/CommunityGeneratorTest.java          |  5 +--
 5 files changed, 12 insertions(+), 51 deletions(-)
 delete mode 100644 gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/IgnoreIteratorLeak.java


[tinkerpop] 02/02: TINKERPOP-2238 Updates to dev docs around iterator leaks.

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2238
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit cba5081c6d619cb304daf5f3aa0381648f939503
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Tue Jun 18 06:26:31 2019 -0400

    TINKERPOP-2238 Updates to dev docs around iterator leaks.
---
 docs/src/dev/developer/development-environment.asciidoc | 1 +
 docs/src/dev/provider/index.asciidoc                    | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/docs/src/dev/developer/development-environment.asciidoc b/docs/src/dev/developer/development-environment.asciidoc
index ec1c8d3..1aadd2f 100644
--- a/docs/src/dev/developer/development-environment.asciidoc
+++ b/docs/src/dev/developer/development-environment.asciidoc
@@ -219,6 +219,7 @@ The following commands are a mix of Maven flags and shell scripts that handle di
 
 * Build project: `mvn clean install`
 ** Build a specific module (e.g. `gremlin-server`) within the project: `mvn clean install -pl gremlin-server`
+** Build without assertions for "iterator leaks" which are enabled by default: `mvn clean install -DtestIteratorLeaks=false`
 ** Specify specific tests in a TinkerPop Suite to run with the `GREMLIN_TESTS` environment variable, along with the
 Maven project list argument, e.g.:
 +
diff --git a/docs/src/dev/provider/index.asciidoc b/docs/src/dev/provider/index.asciidoc
index b0b5459..1185d0c 100644
--- a/docs/src/dev/provider/index.asciidoc
+++ b/docs/src/dev/provider/index.asciidoc
@@ -806,15 +806,19 @@ creating temporary files. The value is typically set to the project build direct
 SureFire Plugin, this is done via the configuration argLine with `-Dbuild.dir=${project.build.directory}`.
 
 ==== Checking resource leak
-TinkerPop query engine retrieves data by interfacing with the provider using iterators. These iterators (depending
+
+The TinkerPop query engine retrieves data by interfacing with the provider using iterators. These iterators (depending
 on the provider) may hold up resources in the underlying storage layer and hence, it is critical to close them after
 the query is finished.
 
 TinkerPop provides you with the ability to test for such resource leaks by checking for leaks when you run the
 Gremlin-Test suites against your implementation. To enable this leak detection, providers should increment the
-`StoreIteratorCounter` whenever a reource is opened and decrement it when it is closed. A reference implementation
+`StoreIteratorCounter` whenever a resource is opened and decrement it when it is closed. A reference implementation
 is provided with TinkerGraph as `TinkerGraphIterator.java`.
 
+Assertions for leak detection are enabled by default when running the test suite. They can be temporarily disabled
+by way of a system property - simply set `-DtestIteratorLeaks=false".
+
 === Accessibility via GremlinPlugin
 
 image:gremlin-plugin.png[width=100,float=left] The applications distributed with TinkerPop3 do not distribute with


[tinkerpop] 01/02: TINKERPOP-2238 Removed the temporary IgnoreIteratorLeak

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2238
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit ac22cf91121cb5b78ad89335146c2dc0d3d045f6
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Tue Jun 18 06:25:54 2019 -0400

    TINKERPOP-2238 Removed the temporary IgnoreIteratorLeak
    
    All leaks have been fixed at this point, so the annotation is no longer necessary.
---
 .../tinkerpop/gremlin/AbstractGremlinTest.java     |  8 ++---
 .../tinkerpop/gremlin/IgnoreIteratorLeak.java      | 41 ----------------------
 .../generator/CommunityGeneratorTest.java          |  5 +--
 3 files changed, 5 insertions(+), 49 deletions(-)

diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
index c874ae8..5c53663 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/AbstractGremlinTest.java
@@ -38,13 +38,11 @@ import org.junit.rules.TestName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Optional;
 import java.util.Set;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
@@ -63,11 +61,11 @@ import static org.junit.Assume.assumeThat;
  */
 public abstract class AbstractGremlinTest {
     private static final Logger logger = LoggerFactory.getLogger(AbstractGremlinTest.class);
+    protected static final boolean shouldTestIteratorLeak = Boolean.valueOf(System.getProperty("testIteratorLeaks", "true"));
     protected Graph graph;
     protected GraphTraversalSource g;
     protected Configuration config;
     protected GraphProvider graphProvider;
-    protected boolean shouldTestIteratorLeak;
 
     @Rule
     public TestName name = new TestName();
@@ -79,8 +77,6 @@ public abstract class AbstractGremlinTest {
         final LoadGraphWith loadGraphWith = loadGraphWiths.length == 0 ? null : loadGraphWiths[0];
         final LoadGraphWith.GraphData loadGraphWithData = null == loadGraphWith ? null : loadGraphWith.value();
 
-        this.shouldTestIteratorLeak =  !this.getClass().isAnnotationPresent(IgnoreIteratorLeak.class);
-
         graphProvider = GraphManager.getGraphProvider();
         graphProvider.getTestListener().ifPresent(l -> l.onTestStart(this.getClass(), name.getMethodName()));
 
@@ -143,7 +139,7 @@ public abstract class AbstractGremlinTest {
         if (null != graphProvider) {
             if (shouldTestIteratorLeak) {
                 long openItrCount = StoreIteratorCounter.INSTANCE.getOpenIteratorCount();
-                Assert.assertEquals("Iterator leak detected. Open iterator count=" + openItrCount, 0, openItrCount);
+                assertEquals("Iterator leak detected. Open iterator count=" + openItrCount, 0, openItrCount);
             }
 
             graphProvider.getTestListener().ifPresent(l -> l.onTestEnd(this.getClass(), name.getMethodName()));
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/IgnoreIteratorLeak.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/IgnoreIteratorLeak.java
deleted file mode 100644
index ebc4646..0000000
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/IgnoreIteratorLeak.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.tinkerpop.gremlin;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Any test class annotated with this annotation does not test for graceful close
- * of any underlying storage iterators (aka iterator leak).
- *
- * This annotation has been temporarily added to allow for iterative fixing of all the
- * iterator leaks in the code base.
- *
- * TODO: This annotation should be deleted after all the code places with an iterator
- *       leak are fixed.
- */
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface IgnoreIteratorLeak {
-}
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/algorithm/generator/CommunityGeneratorTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/algorithm/generator/CommunityGeneratorTest.java
index 5aacc9e..f8e5cad 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/algorithm/generator/CommunityGeneratorTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/algorithm/generator/CommunityGeneratorTest.java
@@ -22,7 +22,6 @@ import org.apache.commons.configuration.Configuration;
 import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
 import org.apache.tinkerpop.gremlin.FeatureRequirement;
 import org.apache.tinkerpop.gremlin.FeatureRequirementSet;
-import org.apache.tinkerpop.gremlin.IgnoreIteratorLeak;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -41,7 +40,9 @@ import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Supplier;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  * @author Stephen Mallette (http://stephen.genoprime.com)