2016-07-22 23:29:18 +01:00
|
|
|
# verifies:
|
|
|
|
# 1. GoCD agent starts
|
|
|
|
# 2. GoCD agent responds
|
|
|
|
# 3. GoCD agent is available on GoCD server using GoCD API
|
|
|
|
# 3.1. https://api.go.cd/current/#get-all-agents
|
|
|
|
|
2016-08-10 16:10:13 +01:00
|
|
|
let
|
|
|
|
serverUrl = "localhost:8153/go/api/agents";
|
|
|
|
header = "Accept: application/vnd./go.cd/v2+json";
|
|
|
|
in
|
|
|
|
|
2016-07-22 23:29:18 +01:00
|
|
|
import ./make-test.nix ({ pkgs, ...} : {
|
|
|
|
name = "gocd-agent";
|
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
2016-08-10 16:10:13 +01:00
|
|
|
maintainers = [ grahamc swarren83 ];
|
2016-07-22 23:29:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
gocd_agent =
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
|
|
|
virtualisation.memorySize = 2048;
|
|
|
|
services.gocd-agent = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
services.gocd-server = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
startAll;
|
|
|
|
$gocd_agent->waitForUnit("gocd-server");
|
|
|
|
$gocd_agent->waitForOpenPort("8153");
|
|
|
|
$gocd_agent->waitForUnit("gocd-agent");
|
2016-08-10 16:10:13 +01:00
|
|
|
$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\"/'");
|
2016-07-22 23:29:18 +01:00
|
|
|
'';
|
|
|
|
})
|