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

ASF GitHub Bot commented on GEODE-8637:
---------------------------------------

demery-pivotal commented on a change in pull request #5649:
URL: https://github.com/apache/geode/pull/5649#discussion_r510390095



##########
File path: 
buildSrc/src/main/java/org/apache/geode/gradle/RunInSubdirectoryTestFramework.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.geode.gradle;
+
+import static java.nio.file.StandardCopyOption.COPY_ATTRIBUTES;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.gradle.api.Action;
+import org.gradle.api.internal.tasks.testing.TestFramework;
+import org.gradle.api.internal.tasks.testing.WorkerTestClassProcessorFactory;
+import org.gradle.api.internal.tasks.testing.detection.TestFrameworkDetector;
+import org.gradle.api.tasks.testing.TestFrameworkOptions;
+import org.gradle.process.internal.JavaExecHandleBuilder;
+import org.gradle.process.internal.worker.WorkerProcessBuilder;
+
+/**
+ * Wraps a test framework to run each test worker in a separate working 
directory.
+ */
+public class RunInSubdirectoryTestFramework implements TestFramework {
+  private static final String GEMFIRE_PROPERTIES = "gemfire.properties";
+  private final AtomicLong workerId = new AtomicLong();
+  private final TestFramework delegate;
+
+  public RunInSubdirectoryTestFramework(TestFramework delegate) {
+    this.delegate = delegate;
+  }
+
+  @Override
+  public TestFrameworkDetector getDetector() {
+    return delegate.getDetector();
+  }
+
+  @Override
+  public TestFrameworkOptions getOptions() {
+    return delegate.getOptions();
+  }
+
+  @Override
+  public WorkerTestClassProcessorFactory getProcessorFactory() {
+    return delegate.getProcessorFactory();
+  }
+
+  /**
+   * Return an action that configures the test worker builder to run the test 
worker in a unique
+   * subdirectory of the task's working directory.
+   */
+  @Override
+  public Action<WorkerProcessBuilder> getWorkerConfigurationAction() {
+    return workerProcessBuilder -> {
+      delegate.getWorkerConfigurationAction().execute(workerProcessBuilder);
+      JavaExecHandleBuilder javaCommand = 
workerProcessBuilder.getJavaCommand();
+
+      Path taskWorkingDir = javaCommand.getWorkingDir().toPath();
+      String workerWorkingDirName = String.format("test-worker-%06d", 
workerId.incrementAndGet());
+      Path workerWorkingDir = taskWorkingDir.resolve(workerWorkingDirName);
+
+      createWorkingDir(workerWorkingDir);
+      copyGemFirePropertiesFile(taskWorkingDir, workerWorkingDir);
+
+      javaCommand.setWorkingDir(workerWorkingDir);
+    };
+  }
+
+  private void copyGemFirePropertiesFile(Path taskWorkingDir, Path 
workerWorkingDir) {
+    Path taskPropertiesFile = taskWorkingDir.resolve(GEMFIRE_PROPERTIES);
+    if (!Files.exists(taskPropertiesFile)) {
+      return;

Review comment:
       If the file is missing, that doesn't indicate a problem. It's 
deliberate. Our Gradle build puts that file there for some test tasks (e.g. 
distributedTest) but not for others (e.g. repeatDistributedTest). I don't know 
why our Gradle build writes the file for some tasks and not others, but that's 
the current behavior.
   
   The if statement accounts for Gradle writing the file for some tasks and not 
for others.
   
   The effect is that if the file was in the test JVM's common working 
directory _before_ this PR, it will be in the JVM's unique working directory 
_after._ And if the file was absent from the test JVM's working directory 
before the PR, it will be absent after.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


> Configure Gradle to run each test worker in a unique working directory
> ----------------------------------------------------------------------
>
>                 Key: GEODE-8637
>                 URL: https://issues.apache.org/jira/browse/GEODE-8637
>             Project: Geode
>          Issue Type: Test
>          Components: build, tests
>    Affects Versions: 1.14.0
>            Reporter: Dale Emery
>            Assignee: Dale Emery
>            Priority: Major
>              Labels: GeodeOperationAPI, pull-request-available
>
> For these test tasks, configure Gradle to run each test worker in a unique 
> working dir:
>  * acceptanceTest
>  * distributedTest
>  * integrationTest
>  * uiTest
>  * upgradeTest
>  * All repeat*Test tasks
> These tasks run tests that might write files to disk. Giving each test worker 
> a unique directory allows these tests to run concurrently without interfering 
> with each other's files and directories.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to