summary refs log tree commit diff
path: root/nixos/tests/gocd-agent.nix
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2016-08-10 15:47:29 -0400
committerGraham Christensen <graham@grahamc.com>2016-08-10 15:47:29 -0400
commitd969f3fa5110b458bbfe5d12774024a6329a6580 (patch)
tree9937ff6cc379cec2341c57b925b52bf70140938b /nixos/tests/gocd-agent.nix
parent26d25774fae5b60c0c5ddbf37bae163c9569e4ff (diff)
downloadnixpkgs-d969f3fa5110b458bbfe5d12774024a6329a6580.tar
nixpkgs-d969f3fa5110b458bbfe5d12774024a6329a6580.tar.gz
nixpkgs-d969f3fa5110b458bbfe5d12774024a6329a6580.tar.bz2
nixpkgs-d969f3fa5110b458bbfe5d12774024a6329a6580.tar.lz
nixpkgs-d969f3fa5110b458bbfe5d12774024a6329a6580.tar.xz
nixpkgs-d969f3fa5110b458bbfe5d12774024a6329a6580.tar.zst
nixpkgs-d969f3fa5110b458bbfe5d12774024a6329a6580.zip
gocd-agent: 16.7.0 startup fixes + test improvements
 - Agent now takes a full URL to the Go.CD server
 - Instruct the agent to attempt restart every 30s upon failure
 - Test's Accept header did not match the server's expectation
 - Replace the tests' complex Awk matches with calls to `jq`
Diffstat (limited to 'nixos/tests/gocd-agent.nix')
-rw-r--r--nixos/tests/gocd-agent.nix30
1 files changed, 15 insertions, 15 deletions
diff --git a/nixos/tests/gocd-agent.nix b/nixos/tests/gocd-agent.nix
index 34d0a800d09..b1282acdb04 100644
--- a/nixos/tests/gocd-agent.nix
+++ b/nixos/tests/gocd-agent.nix
@@ -6,7 +6,7 @@
 
 let
   serverUrl = "localhost:8153/go/api/agents";
-  header = "Accept: application/vnd./go.cd/v2+json";
+  header = "Accept: application/vnd.go.cd.v2+json";
 in
 
 import ./make-test.nix ({ pkgs, ...} : {
@@ -15,26 +15,26 @@ import ./make-test.nix ({ pkgs, ...} : {
     maintainers = [ grahamc swarren83 ];
   };
 
-nodes = {
-  gocd_agent =
-    { config, pkgs, ... }:
-    { 
-      virtualisation.memorySize = 2048;
-      services.gocd-agent = {
-        enable = true;
+  nodes = {
+    gocd_agent =
+      { config, pkgs, ... }:
+      {
+        virtualisation.memorySize = 2048;
+        services.gocd-agent = {
+          enable = true;
+        };
+        services.gocd-server = {
+          enable = true;
+        };
       };
-      services.gocd-server = {
-        enable = true;
-      };
-    };
-};
+  };
 
   testScript = ''
     startAll;
     $gocd_agent->waitForUnit("gocd-server");
     $gocd_agent->waitForOpenPort("8153");
     $gocd_agent->waitForUnit("gocd-agent");
-    $gocd_agent->waitUntilSucceeds("curl -s -f ${serverUrl} -H '${header}' | awk -F \" '/\"uuid\":\s\"[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}/ {print $4}'");
-    $gocd_agent->waitUntilSucceeds("curl -s -f ${serverUrl} -H '${header}' | awk -F \" '/\"agent_state\":\s\"Idle\"/'");
+    $gocd_agent->waitUntilSucceeds("curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].uuid");
+    $gocd_agent->succeed("curl ${serverUrl} -H '${header}' | ${pkgs.jq}/bin/jq -e ._embedded.agents[0].agent_state | grep -q Idle");
   '';
 })