[ 
https://issues.apache.org/jira/browse/BEAM-3667?focusedWorklogId=191789&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-191789
 ]

ASF GitHub Bot logged work on BEAM-3667:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 29/Jan/19 16:40
            Start Date: 29/Jan/19 16:40
    Worklog Time Spent: 10m 
      Work Description: iemejia commented on pull request #7649: [BEAM-3667] 
Make embedded MongoDB instance per class and test code more robust
URL: https://github.com/apache/beam/pull/7649#discussion_r251914883
 
 

 ##########
 File path: 
sdks/java/io/mongodb/src/test/java/org/apache/beam/sdk/io/mongodb/MongoDbIOTest.java
 ##########
 @@ -316,61 +266,27 @@ public void testReadWithProjection() throws Exception {
   }
 
   @Test
-  public void testWrite() throws Exception {
+  public void testWrite() {
+    final String collectionName = "testWrite";
+    final int numElements = 1000;
 
-    ArrayList<Document> data = new ArrayList<>();
-    for (int i = 0; i < 10000; i++) {
-      data.add(Document.parse(String.format("{\"scientist\":\"Test %s\"}", 
i)));
-    }
     pipeline
-        .apply(Create.of(data))
+        .apply(Create.of(createDocuments(numElements)))
         .apply(
             MongoDbIO.write()
                 .withUri("mongodb://localhost:" + port)
-                .withDatabase("test")
-                .withCollection("test"));
+                .withDatabase(DATABASE)
+                .withCollection(collectionName));
 
     pipeline.run();
 
-    MongoClient client = new MongoClient("localhost", port);
-    MongoDatabase database = client.getDatabase("test");
-    MongoCollection collection = database.getCollection("test");
-
-    MongoCursor cursor = collection.find().iterator();
-
-    int count = 0;
-    while (cursor.hasNext()) {
-      count = count + 1;
-      cursor.next();
-    }
-
-    assertEquals(10000, count);
+    assertEquals(numElements, countElements(collectionName));
   }
 
   @Test
-  public void testWriteEmptyCollection() throws Exception {
 
 Review comment:
   Because it is useless. A collecation created this way will never get into 
the part that is supposed to be tested here. No other IO test (or should be 
testing for the empty case).
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 191789)
    Time Spent: 1h 10m  (was: 1h)

> Failure in MongoDbIOTest.testReadWithCustomConnectionOptions
> ------------------------------------------------------------
>
>                 Key: BEAM-3667
>                 URL: https://issues.apache.org/jira/browse/BEAM-3667
>             Project: Beam
>          Issue Type: Bug
>          Components: io-java-mongodb
>            Reporter: Kenneth Knowles
>            Assignee: Ismaël Mejía
>            Priority: Major
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/org.apache.beam$beam-sdks-java-io-mongodb/17675/console
> There's an NPE and a text file contention error.
> {code}
> 2018-02-08T18:40:34.453 [ERROR] 
> testReadWithCustomConnectionOptions(org.apache.beam.sdk.io.mongodb.MongoDbIOTest)
>   Time elapsed: 0.163 s  <<< ERROR!
> java.io.IOException: Cannot run program 
> "/tmp/extract-1753d5fc-31f4-4a30-bca0-58578c50e525extractmongod": error=26, 
> Text file busy
>       at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
>       at 
> de.flapdoodle.embed.process.runtime.ProcessControl.start(ProcessControl.java:205)
>       at 
> de.flapdoodle.embed.process.runtime.AbstractProcess.<init>(AbstractProcess.java:98)
>       at 
> de.flapdoodle.embed.mongo.AbstractMongoProcess.<init>(AbstractMongoProcess.java:53)
>       at de.flapdoodle.embed.mongo.MongodProcess.<init>(MongodProcess.java:50)
>       at 
> de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:44)
>       at 
> de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:34)
>       at 
> de.flapdoodle.embed.process.runtime.Executable.start(Executable.java:101)
>       at 
> org.apache.beam.sdk.io.mongodb.MongoDbIOTest.setup(MongoDbIOTest.java:115)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>       at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
>       at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>       at 
> org.apache.beam.sdk.testing.TestPipeline$1.evaluate(TestPipeline.java:324)
>       at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at org.junit.runners.Suite.runChild(Suite.java:128)
>       at org.junit.runners.Suite.runChild(Suite.java:27)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at org.apache.maven.surefire.junitcore.JUnitCore.run(JUnitCore.java:55)
>       at
>         ...
> Caused by: java.io.IOException: error=26, Text file busy
>       at java.lang.UNIXProcess.forkAndExec(Native Method)
>       at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
>       at java.lang.ProcessImpl.start(ProcessImpl.java:134)
>       at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
>       ... 47 more
> 2018-02-08T18:40:34.453 [ERROR] 
> testReadWithCustomConnectionOptions(org.apache.beam.sdk.io.mongodb.MongoDbIOTest)
>   Time elapsed: 0.163 s  <<< ERROR!
> java.lang.NullPointerException
>       at 
> org.apache.beam.sdk.io.mongodb.MongoDbIOTest.stop(MongoDbIOTest.java:139)
>         ...
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to