-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic support for managing supported cluster configuration parameters. This command provides the following sub-commands: ``` ❯ cb config-param --help Usage: cb config-param <command> Commands: get display one or all configuration parameters for a cluster list-supported display supported configuration parameters reset reset one or more configuration parameter values to default set set one or more configuration parameter values Options: -h, --help Show this help ```
- Loading branch information
1 parent
4a09f3a
commit 0074916
Showing
15 changed files
with
742 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
require "../spec_helper" | ||
|
||
Spectator.describe ConfigurationParameterGet do | ||
subject(action) { described_class.new client: client, output: IO::Memory.new } | ||
|
||
let(client) { Client.new TEST_TOKEN } | ||
let(cluster) { Factory.cluster } | ||
|
||
mock_client | ||
|
||
describe "#validate" do | ||
it "validates that required arguments are present" do | ||
expect(&.validate).to raise_error Program::Error, /Missing required argument/ | ||
|
||
action.cluster_id = cluster.id | ||
|
||
expect(&.validate).to be_true | ||
end | ||
end | ||
|
||
describe "#call" do | ||
before_each { | ||
action.cluster_id = cluster.id | ||
} | ||
|
||
it "gets by name" do | ||
action.args = ["postgres:max_connections"] | ||
|
||
expect(client).to receive(:get_configuration_parameter).and_return(Factory.configuration_parameter) | ||
|
||
action.call | ||
|
||
expected = <<-EXPECTED | ||
Component Name Value | ||
postgres max_connections 100 \n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
|
||
it "lists no parameters when none are set" do | ||
expect(client).to receive(:list_configuration_parameters).and_return([] of CB::Model::ConfigurationParameter) | ||
|
||
action.call | ||
|
||
expected = <<-EXPECTED | ||
Component Name Value \n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
|
||
it "outputs default format" do | ||
expect(client).to receive(:list_configuration_parameters).and_return([Factory.configuration_parameter, Factory.configuration_parameter]) | ||
|
||
action.call | ||
|
||
expected = <<-EXPECTED | ||
Component Name Value | ||
postgres max_connections 100 | ||
postgres max_connections 100 \n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
|
||
it "outputs json format" do | ||
action.format = Format::JSON | ||
|
||
expect(client).to receive(:list_configuration_parameters).and_return([Factory.configuration_parameter]) | ||
|
||
action.call | ||
|
||
expected = <<-EXPECTED | ||
{ | ||
"parameters": [ | ||
{ | ||
"component": "postgres", | ||
"name": "postgres:max_connections", | ||
"parameter_name": "max_connections", | ||
"requires_restart": false, | ||
"value": "100" | ||
} | ||
] | ||
}\n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
end | ||
end | ||
|
||
Spectator.describe ConfigurationParameterListSupported do | ||
subject(action) { described_class.new client: client, output: IO::Memory.new } | ||
|
||
let(client) { Client.new TEST_TOKEN } | ||
let(cluster) { Factory.cluster } | ||
|
||
mock_client | ||
|
||
describe "#call" do | ||
before_each { | ||
expect(client).to receive(:list_supported_configuration_parameters).and_return [ | ||
Factory.configuration_parameter(value: nil), | ||
Factory.configuration_parameter( | ||
component: "pgbouncer", | ||
name: "pgbouncer:default_pool_size", | ||
parameter_name: "default_pool_size", | ||
value: nil | ||
), | ||
] | ||
} | ||
|
||
it "outputs all" do | ||
action.call | ||
|
||
expected = <<-EXPECTED | ||
Component Name Requires Restart | ||
postgres max_connections no | ||
pgbouncer default_pool_size no \n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
|
||
it "outputs specific component" do | ||
action.args = ["postgres"] | ||
action.call | ||
|
||
expected = <<-EXPECTED | ||
Component Name Requires Restart | ||
postgres max_connections no \n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
end | ||
end | ||
|
||
Spectator.describe ConfigurationParameterSet do | ||
subject(action) { described_class.new client: client, output: IO::Memory.new } | ||
|
||
let(client) { Client.new TEST_TOKEN } | ||
let(cluster) { Factory.cluster } | ||
|
||
mock_client | ||
|
||
describe "#call" do | ||
before_each { | ||
action.args = ["postgres:max_connections=100"] | ||
action.cluster_id = cluster.id | ||
} | ||
|
||
it "outputs default" do | ||
expect(client).to receive(:update_configuration_parameters).and_return [Factory.configuration_parameter] | ||
|
||
action.call | ||
|
||
expected = <<-EXPECTED | ||
Component Name Value | ||
postgres max_connections 100 \n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
|
||
it "outputs json format" do | ||
action.format = Format::JSON | ||
|
||
expect(client).to receive(:update_configuration_parameters).and_return([Factory.configuration_parameter]) | ||
|
||
action.call | ||
|
||
expected = <<-EXPECTED | ||
{ | ||
"parameters": [ | ||
{ | ||
"component": "postgres", | ||
"name": "postgres:max_connections", | ||
"parameter_name": "max_connections", | ||
"requires_restart": false, | ||
"value": "100" | ||
} | ||
] | ||
}\n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
end | ||
end | ||
|
||
Spectator.describe ConfigurationParameterReset do | ||
subject(action) { described_class.new client: client, output: IO::Memory.new } | ||
|
||
let(client) { Client.new TEST_TOKEN } | ||
let(cluster) { Factory.cluster } | ||
|
||
mock_client | ||
|
||
describe "#call" do | ||
before_each { | ||
action.cluster_id = cluster.id | ||
|
||
expect(client).to receive(:update_configuration_parameters).and_return [Factory.configuration_parameter] | ||
} | ||
|
||
it "resets parameters" do | ||
action.args = ["postgres:max_connections"] | ||
|
||
action.call | ||
|
||
expected = <<-EXPECTED | ||
Component Name Value | ||
postgres max_connections 100 \n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
|
||
it "outputs default" do | ||
action.call | ||
|
||
expected = <<-EXPECTED | ||
Component Name Value | ||
postgres max_connections 100 \n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
|
||
it "outputs json format" do | ||
action.format = Format::JSON | ||
|
||
action.call | ||
|
||
expected = <<-EXPECTED | ||
{ | ||
"parameters": [ | ||
{ | ||
"component": "postgres", | ||
"name": "postgres:max_connections", | ||
"parameter_name": "max_connections", | ||
"requires_restart": false, | ||
"value": "100" | ||
} | ||
] | ||
}\n | ||
EXPECTED | ||
|
||
expect(&.output.to_s).to eq expected | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.