Skip to content

Commit

Permalink
Add backward-compatibility between old/new testgrid yaml file. (#768)
Browse files Browse the repository at this point in the history
* Add backward compatibility with old testgrid yaml file.

* Change contant TestGrid yaml.

* Fix review suggestions.
  • Loading branch information
pasindujw authored and lasanthaDLPDS committed May 24, 2018
1 parent a199c83 commit 084b112
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
*/
public class TestGridConstants {

public static final String TESTGRID_YAML = ".testgrid.yaml";
public static final String TESTGRID_YAML = "testgrid.yaml";
public static final String TEST_PLAN_YAML_PREFIX = "test-plan";

public static final String TESTGRID_LOG_FILE_NAME = "testgrid.log";
public static final String TESTGRID_LOGS_DIR = "logs";
public static final String PRODUCT_TEST_PLANS_DIR = "test-plans";
public static final String FILE_SEPARATOR = "/";
public static final String HIDDEN_FILE_INDICATOR = ".";
public static final String LOG_FILE_EXTENSION = ".log";

public static final String WORKSPACE = "workspace";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,19 +349,17 @@ private TestgridYaml buildTestgridYamlContent(JobConfigFile jobConfigFile) {
StringBuilder testgridYamlBuilder = new StringBuilder();
String ls = System.lineSeparator();
testgridYamlBuilder
.append(getTestgridYamlFor(Paths.get(infraRepositoryLocation, TestGridConstants.TESTGRID_YAML)))
.append(getTestgridYamlFor(getTestGridYamlLocation(infraRepositoryLocation)))
.append(ls);
String testgridYamlContent = testgridYamlBuilder.toString().trim();
if (!testgridYamlContent.isEmpty()) {
if (!testgridYamlContent.contains("deploymentConfig")) {
testgridYamlBuilder
.append(getTestgridYamlFor(
Paths.get(deployRepositoryLocation, TestGridConstants.TESTGRID_YAML)))
.append(getTestgridYamlFor(getTestGridYamlLocation(deployRepositoryLocation)))
.append(ls);
}
testgridYamlBuilder
.append(getTestgridYamlFor(
Paths.get(scenarioTestsRepositoryLocation, TestGridConstants.TESTGRID_YAML)))
.append(getTestgridYamlFor(getTestGridYamlLocation(scenarioTestsRepositoryLocation)))
.append(ls);
} else {
logger.warn(StringUtil.concatStrings(
Expand Down Expand Up @@ -630,4 +628,20 @@ protected NodeTuple representJavaBeanProperty(Object javaBean, Property property
}
}
}

/**
* If the testgrid yaml file is hidden in the directory, change the URI as to refer the hidden file.
* @param directory directory where the testgrid yaml file exists
* @return testgrid yaml file path
*/
private Path getTestGridYamlLocation(String directory) {
Path hiddenYamlPath = Paths.get(
directory, TestGridConstants.HIDDEN_FILE_INDICATOR + TestGridConstants.TESTGRID_YAML);
Path defaultYamlPath = Paths.get(directory, TestGridConstants.TESTGRID_YAML);
if (Files.exists(hiddenYamlPath)) {
return hiddenYamlPath;
} else {
return defaultYamlPath;
}
}
}

0 comments on commit 084b112

Please sign in to comment.