|
59 | 59 | }
|
60 | 60 | include_examples "the correct method", changeset, true
|
61 | 61 | end
|
| 62 | + |
| 63 | + describe "aws-parallelcluster-slurm:libraries:are_queues_updated" do |
| 64 | + CLUSTER_CONFIG_PATH = "/CLUSTER_CONFIG_PATH".freeze |
| 65 | + PREVIOUS_CLUSTER_CONFIG_PATH = "/PREVIOUS_CLUSTER_CONFIG_PATH".freeze |
| 66 | + |
| 67 | + let(:node) do |
| 68 | + { |
| 69 | + "cluster" => { |
| 70 | + "cluster_config_path" => CLUSTER_CONFIG_PATH, |
| 71 | + "previous_cluster_config_path" => PREVIOUS_CLUSTER_CONFIG_PATH, |
| 72 | + }, |
| 73 | + } |
| 74 | + end |
| 75 | + |
| 76 | + shared_examples "the correct result" do |config, previous_config, file_exists, expected_result| |
| 77 | + it "returns #{expected_result}" do |
| 78 | + allow(File).to receive(:exist?).with(PREVIOUS_CLUSTER_CONFIG_PATH).and_return(file_exists) |
| 79 | + allow(File).to receive(:read).with(CLUSTER_CONFIG_PATH).and_return(YAML.dump(config)) |
| 80 | + if file_exists |
| 81 | + allow(File).to receive(:read).with(PREVIOUS_CLUSTER_CONFIG_PATH).and_return(YAML.dump(previous_config)) |
| 82 | + end |
| 83 | + result = are_queues_updated? |
| 84 | + expect(result).to eq(expected_result) |
| 85 | + end |
| 86 | + end |
| 87 | + |
| 88 | + context "when previous cluster config file does not exist" do |
| 89 | + config = { |
| 90 | + "Scheduling" => { "SlurmQueues" => [] } |
| 91 | + } |
| 92 | + previous_config = nil |
| 93 | + include_examples "the correct result", config, previous_config, false, false |
| 94 | + end |
| 95 | + |
| 96 | + context "when Scheduling sections are identical and bootstrap timeout unchanged" do |
| 97 | + config = { |
| 98 | + "Scheduling" => { "SlurmQueues" => [{ "Name" => "queue1" }] } |
| 99 | + } |
| 100 | + previous_config = { |
| 101 | + "Scheduling" => { "SlurmQueues" => [{ "Name" => "queue1" }] } |
| 102 | + } |
| 103 | + include_examples "the correct result", config, previous_config, true, false |
| 104 | + end |
| 105 | + |
| 106 | + context "when Scheduling sections are identical and bootstrap timeout is updated" do |
| 107 | + config = { |
| 108 | + "Scheduling" => { "SlurmQueues" => [{ "Name" => "queue1" }] }, |
| 109 | + "DevSettings" => { "Timeouts" => { "ComputeNodeBootstrapTimeout" => 3600 } } |
| 110 | + } |
| 111 | + previous_config = { |
| 112 | + "Scheduling" => { "SlurmQueues" => [{ "Name" => "queue1" }] }, |
| 113 | + "DevSettings" => { "Timeouts" => { "ComputeNodeBootstrapTimeout" => 1800 } } |
| 114 | + } |
| 115 | + include_examples "the correct result", config, previous_config, true, true |
| 116 | + end |
| 117 | + |
| 118 | + context "when Scheduling sections are identical and bootstrap timeout changes from default to explicit value" do |
| 119 | + config = { |
| 120 | + "Scheduling" => { "SlurmQueues" => [{ "Name" => "queue1" }] }, |
| 121 | + "DevSettings" => { "Timeouts" => { "ComputeNodeBootstrapTimeout" => 3600 } } |
| 122 | + } |
| 123 | + previous_config = { |
| 124 | + "Scheduling" => { "SlurmQueues" => [{ "Name" => "queue1" }] } |
| 125 | + } |
| 126 | + include_examples "the correct result", config, previous_config, true, true |
| 127 | + end |
| 128 | + |
| 129 | + context "when Scheduling sections are different" do |
| 130 | + config = { |
| 131 | + "Scheduling" => { "SlurmQueues" => [{ "Name" => "queue2" }] } |
| 132 | + } |
| 133 | + previous_config = { |
| 134 | + "Scheduling" => { "SlurmQueues" => [{ "Name" => "queue1" }] } |
| 135 | + } |
| 136 | + include_examples "the correct result", config, previous_config, true, true |
| 137 | + end |
| 138 | + end |
62 | 139 | end
|
0 commit comments