@@ -50,7 +50,8 @@ public static void afterTesting() {
5050 process .waitFor ();
5151
5252 // remove config.yaml file
53- pb = new ProcessBuilder ("rm" , "config.yaml" );
53+ String workerId = System .getProperty ("org.gradle.test.worker" );
54+ pb = new ProcessBuilder ("rm" , "config" + workerId + ".yaml" );
5455 pb .directory (new File (installDir ));
5556 process = pb .start ();
5657 process .waitFor ();
@@ -63,7 +64,7 @@ public static void afterTesting() {
6364 }
6465
6566 // remove .started folder created by processes
66- final File dotStartedFolder = new File (installDir + ".started" );
67+ final File dotStartedFolder = new File (installDir + ".started" + workerId );
6768 try {
6869 FileUtils .deleteDirectory (dotStartedFolder );
6970 } catch (Exception ignored ) {
@@ -82,11 +83,12 @@ public static void reset() {
8283 MultitenancyQueries .simulateErrorInAddingTenantIdInTargetStorage_forTesting = false ;
8384
8485 String installDir = "../" ;
86+ String workerId = System .getProperty ("org.gradle.test.worker" );
8587 try {
8688 // if the default config is not the same as the current config, we must reset
8789 // the storage layer
8890 File ogConfig = new File ("../temp/config.yaml" );
89- File currentConfig = new File ("../config.yaml" );
91+ File currentConfig = new File ("../config" + workerId + " .yaml" );
9092 if (currentConfig .isFile ()) {
9193 byte [] ogConfigContent = Files .readAllBytes (ogConfig .toPath ());
9294 byte [] currentConfigContent = Files .readAllBytes (currentConfig .toPath ());
@@ -95,7 +97,7 @@ public static void reset() {
9597 }
9698 }
9799
98- ProcessBuilder pb = new ProcessBuilder ("cp" , "temp/config.yaml" , "./config.yaml" );
100+ ProcessBuilder pb = new ProcessBuilder ("cp" , "temp/config.yaml" , "./config" + workerId + " .yaml" );
99101 pb .directory (new File (installDir ));
100102 Process process = pb .start ();
101103 process .waitFor ();
@@ -140,14 +142,15 @@ public static void setValueInConfig(String key, String value) throws FileNotFoun
140142 String oldStr = "\n ((#\\ s)?)" + key + "(:|((:\\ s).+))\n " ;
141143 String newStr = "\n " + key + ": " + value + "\n " ;
142144 StringBuilder originalFileContent = new StringBuilder ();
143- try (BufferedReader reader = new BufferedReader (new FileReader ("../config.yaml" ))) {
145+ String workerId = System .getProperty ("org.gradle.test.worker" );
146+ try (BufferedReader reader = new BufferedReader (new FileReader ("../config" + workerId + ".yaml" ))) {
144147 String currentReadingLine = reader .readLine ();
145148 while (currentReadingLine != null ) {
146149 originalFileContent .append (currentReadingLine ).append (System .lineSeparator ());
147150 currentReadingLine = reader .readLine ();
148151 }
149152 String modifiedFileContent = originalFileContent .toString ().replaceAll (oldStr , newStr );
150- try (BufferedWriter writer = new BufferedWriter (new FileWriter ("../config.yaml" ))) {
153+ try (BufferedWriter writer = new BufferedWriter (new FileWriter ("../config" + workerId + " .yaml" ))) {
151154 writer .write (modifiedFileContent );
152155 }
153156 }
@@ -162,14 +165,15 @@ public static void commentConfigValue(String key) throws IOException {
162165 String newStr = "\n # " + key + ":" ;
163166
164167 StringBuilder originalFileContent = new StringBuilder ();
165- try (BufferedReader reader = new BufferedReader (new FileReader ("../config.yaml" ))) {
168+ String workerId = System .getProperty ("org.gradle.test.worker" );
169+ try (BufferedReader reader = new BufferedReader (new FileReader ("../config" + workerId + ".yaml" ))) {
166170 String currentReadingLine = reader .readLine ();
167171 while (currentReadingLine != null ) {
168172 originalFileContent .append (currentReadingLine ).append (System .lineSeparator ());
169173 currentReadingLine = reader .readLine ();
170174 }
171175 String modifiedFileContent = originalFileContent .toString ().replaceAll (oldStr , newStr );
172- try (BufferedWriter writer = new BufferedWriter (new FileWriter ("../config.yaml" ))) {
176+ try (BufferedWriter writer = new BufferedWriter (new FileWriter ("../config" + workerId + " .yaml" ))) {
173177 writer .write (modifiedFileContent );
174178 }
175179 }
0 commit comments