2016-07-22 22:29:18 +00: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 15:10:13 +00:00
|
|
|
let
|
|
|
|
serverUrl = "localhost:8153/go/api/agents";
|
2016-08-10 19:47:29 +00:00
|
|
|
header = "Accept: application/vnd.go.cd.v2+json";
|
2016-08-10 15:10:13 +00:00
|
|
|
in
|
|
|
|
|
2016-07-22 22:29:18 +00:00
|
|
|
import ./make-test.nix ({ pkgs, ...} : {
|
|
|
|
name = "gocd-agent";
|
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
2016-08-10 15:10:13 +00:00
|
|
|
maintainers = [ grahamc swarren83 ];
|
2016-07-22 22:29:18 +00:00
|
|
|
};
|
|
|
|
|
2016-08-10 19:47:29 +00:00
|
|
|
nodes = {
|
|
|
|
gocd_agent =
|
2018-07-20 20:56:59 +00:00
|
|
|
{ ... }:
|
2016-08-10 19:47:29 +00:00
|
|
|
{
|
2016-08-10 20:21:35 +00:00
|
|
|
virtualisation.memorySize = 2046;
|
2016-08-10 19:47:29 +00:00
|
|
|
services.gocd-agent = {
|
|
|
|
enable = true;
|
|
|
|
};
|
|
|
|
services.gocd-server = {
|
|
|
|
enable = true;
|
|
|
|
};
|
2016-07-22 22:29:18 +00:00
|
|
|
};
|
2016-08-10 19:47:29 +00:00
|
|
|
};
|
2016-07-22 22:29:18 +00:00
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
startAll;
|
|
|
|
$gocd_agent->waitForUnit("gocd-server");
|
|
|
|
$gocd_agent->waitForOpenPort("8153");
|
|
|
|
$gocd_agent->waitForUnit("gocd-agent");
|
2016-08-10 19:47:29 +00:00
|
|
|
$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");
|
2016-07-22 22:29:18 +00:00
|
|
|
'';
|
|
|
|
})
|