# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. use Test::More; use strict; use warnings; BEGIN { use_ok( 'Yahoo::Vespa::Bin::SetNodeState' ); } require_ok( 'Yahoo::Vespa::Bin::SetNodeState' ); use TestUtils::VespaTest; use Yahoo::Vespa::Mocks::ClusterControllerMock; use Yahoo::Vespa::Mocks::VespaModelMock; # Set which application is called on assertRun / assertRunMatches calls setApplication( \&setNodeState ); &testSimple(); &testSyntaxPage(); &testHelp(); &testDownState(); &testDownFailure(); &testDefaultMaintenanceFails(); &testForcedMaintenanceSucceeds(); done_testing(); exit(0); sub testSimple { my $stdout = < [Description] Arguments: Wanted State : User state to set. This must be one of up, down, maintenance or retired. Description : Give a reason for why you are altering the user state, which will show up in various admin tools. (Use double quotes to give a reason with whitespace in it) Options: -h --help : Show this help page. -v : Create more verbose output. -s : Create less verbose output. --show-hidden : Also show hidden undocumented debug options. Node selection options. By default, nodes running locally will be selected: -c --cluster : Cluster name of cluster to query. If unspecified, and vespa is installed on current node, information will be attempted auto-extracted -f --force : Force the execution of a dangerous command. -t --type : Node type to query. This can either be 'storage' or 'distributor'. If not specified, the operation will show state for all types. -i --index : The node index to show state for. If not specified, all nodes found running on this host will be shown. Config retrieval options: --config-server : Host name of config server to query --config-server-port : Port to connect to config server on --config-request-timeout : Timeout of config request EOS assertRun("Help text", "-h", 1, $stdout, ""); } sub testDownState { my $stdout = <