Skip to content

Commit 084b112

Browse files
pasindujwlasanthaDLPDS
authored andcommitted
Add backward-compatibility between old/new testgrid yaml file. (#768)
* Add backward compatibility with old testgrid yaml file. * Change contant TestGrid yaml. * Fix review suggestions.
1 parent a199c83 commit 084b112

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

common/src/main/java/org/wso2/testgrid/common/TestGridConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
*/
2828
public class TestGridConstants {
2929

30-
public static final String TESTGRID_YAML = ".testgrid.yaml";
30+
public static final String TESTGRID_YAML = "testgrid.yaml";
3131
public static final String TEST_PLAN_YAML_PREFIX = "test-plan";
3232

3333
public static final String TESTGRID_LOG_FILE_NAME = "testgrid.log";
3434
public static final String TESTGRID_LOGS_DIR = "logs";
3535
public static final String PRODUCT_TEST_PLANS_DIR = "test-plans";
3636
public static final String FILE_SEPARATOR = "/";
37+
public static final String HIDDEN_FILE_INDICATOR = ".";
3738
public static final String LOG_FILE_EXTENSION = ".log";
3839

3940
public static final String WORKSPACE = "workspace";

core/src/main/java/org/wso2/testgrid/core/command/GenerateTestPlanCommand.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,19 +349,17 @@ private TestgridYaml buildTestgridYamlContent(JobConfigFile jobConfigFile) {
349349
StringBuilder testgridYamlBuilder = new StringBuilder();
350350
String ls = System.lineSeparator();
351351
testgridYamlBuilder
352-
.append(getTestgridYamlFor(Paths.get(infraRepositoryLocation, TestGridConstants.TESTGRID_YAML)))
352+
.append(getTestgridYamlFor(getTestGridYamlLocation(infraRepositoryLocation)))
353353
.append(ls);
354354
String testgridYamlContent = testgridYamlBuilder.toString().trim();
355355
if (!testgridYamlContent.isEmpty()) {
356356
if (!testgridYamlContent.contains("deploymentConfig")) {
357357
testgridYamlBuilder
358-
.append(getTestgridYamlFor(
359-
Paths.get(deployRepositoryLocation, TestGridConstants.TESTGRID_YAML)))
358+
.append(getTestgridYamlFor(getTestGridYamlLocation(deployRepositoryLocation)))
360359
.append(ls);
361360
}
362361
testgridYamlBuilder
363-
.append(getTestgridYamlFor(
364-
Paths.get(scenarioTestsRepositoryLocation, TestGridConstants.TESTGRID_YAML)))
362+
.append(getTestgridYamlFor(getTestGridYamlLocation(scenarioTestsRepositoryLocation)))
365363
.append(ls);
366364
} else {
367365
logger.warn(StringUtil.concatStrings(
@@ -630,4 +628,20 @@ protected NodeTuple representJavaBeanProperty(Object javaBean, Property property
630628
}
631629
}
632630
}
631+
632+
/**
633+
* If the testgrid yaml file is hidden in the directory, change the URI as to refer the hidden file.
634+
* @param directory directory where the testgrid yaml file exists
635+
* @return testgrid yaml file path
636+
*/
637+
private Path getTestGridYamlLocation(String directory) {
638+
Path hiddenYamlPath = Paths.get(
639+
directory, TestGridConstants.HIDDEN_FILE_INDICATOR + TestGridConstants.TESTGRID_YAML);
640+
Path defaultYamlPath = Paths.get(directory, TestGridConstants.TESTGRID_YAML);
641+
if (Files.exists(hiddenYamlPath)) {
642+
return hiddenYamlPath;
643+
} else {
644+
return defaultYamlPath;
645+
}
646+
}
633647
}

0 commit comments

Comments
 (0)