forked from mirrors/nixpkgs
Merge pull request #17645 from grahamc/gocd-improve
gocd-agent: 16.7.0 startup fixes + test improvements
This commit is contained in:
commit
f191b65820
|
@ -57,18 +57,10 @@ in {
|
|||
};
|
||||
|
||||
goServer = mkOption {
|
||||
default = "127.0.0.1";
|
||||
default = "https://127.0.0.1:8154/go";
|
||||
type = types.str;
|
||||
description = ''
|
||||
Address of GoCD Server to attach the Go.CD Agent to.
|
||||
'';
|
||||
};
|
||||
|
||||
goServerPort = mkOption {
|
||||
default = 8153;
|
||||
type = types.int;
|
||||
description = ''
|
||||
Port that Go.CD Server is Listening on.
|
||||
URL of the GoCD Server to attach the Go.CD Agent to.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -112,8 +104,8 @@ in {
|
|||
|
||||
extraOptions = mkOption {
|
||||
default = [ ];
|
||||
example = [
|
||||
"-X debug"
|
||||
example = [
|
||||
"-X debug"
|
||||
"-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006"
|
||||
"-verbose:gc"
|
||||
"-Xloggc:go-agent-gc.log"
|
||||
|
@ -170,7 +162,7 @@ in {
|
|||
config.environment.sessionVariables;
|
||||
in
|
||||
selectedSessionVars //
|
||||
{
|
||||
{
|
||||
NIX_REMOTE = "daemon";
|
||||
AGENT_WORK_DIR = cfg.workDir;
|
||||
AGENT_STARTUP_ARGS = ''${concatStringsSep " " cfg.startupOptions}'';
|
||||
|
@ -199,13 +191,14 @@ in {
|
|||
${pkgs.jre}/bin/java ${concatStringsSep " " cfg.startupOptions} \
|
||||
${concatStringsSep " " cfg.extraOptions} \
|
||||
-jar ${pkgs.gocd-agent}/go-agent/agent-bootstrapper.jar \
|
||||
${cfg.goServer} \
|
||||
${toString cfg.goServerPort}
|
||||
-serverUrl ${cfg.goServer}
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
User = cfg.user;
|
||||
WorkingDirectory = cfg.workDir;
|
||||
RestartSec = 30;
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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");
|
||||
'';
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue