Skip to content

Commit

Permalink
Properly detect scenario where highstate would create changes and tes…
Browse files Browse the repository at this point in the history
…t=True. This causes the minion result key = "null" instead of a boolean. Closes JENKINS-34535
  • Loading branch information
Christian McHugh committed May 6, 2016
1 parent 48d5fe0 commit 9d93e17
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/com/waytta/Utils.java
Expand Up @@ -160,7 +160,7 @@ public static boolean validateFunctionCall(JSONArray returnArray) {
}
}

// test if normla minion results are a JSONArray which indicates
// test if normal minion results are a JSONArray which indicates
// failure
// detect errors like
// "return":[{"data":{"minionname":["Rendering SLS...
Expand Down Expand Up @@ -212,6 +212,12 @@ private static boolean validateInnerJsonObject(JSONObject minion) {

// test if result is false
if (jsonObject.has("result")) {
//detect where test=True and results key is "null"
//See test testHighStateChangesTest
if (jsonObject.get("result").equals("null")) {
//deteced null result, skipping
break;
}
result = jsonObject.getBoolean("result");

if (!result) {
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/com/waytta/UtilsTest.java
Expand Up @@ -264,6 +264,25 @@ public void testValidateFunctionCallForMultiPillar() {

Assert.assertTrue(Utils.validateFunctionCall(jsonArray));
}

@Test
public void testHighStateChangesTest() {
JSONArray jsonArray = JSONArray.fromObject("[{" +
"\"web1\": {" +
"\"file_|-manage ssh_known_hosts file_|-/etc/ssh/ssh_known_hosts_|-managed\": {" +
"\"comment\": \"The file /etc/ssh/ssh_known_hosts is set to be changed\"," +
"\"name\": \"/etc/ssh/ssh_known_hosts\"," +
"\"start_time\": \"12:32:39.060016\"," +
"\"result\": null," +
"\"duration\": 277.921," +
"\"__run_num__\": 9," +
"\"changes\": {" +
"\"diff\": \"diff output\"" +
"}" +
"}}}]");

Assert.assertTrue(Utils.validateFunctionCall(jsonArray));
}

@Mock
BuildListener listenerMock;
Expand Down

0 comments on commit 9d93e17

Please sign in to comment.