|
39 | 39 | }
|
40 | 40 | end
|
41 | 41 | let(:nodes_to_stop) { [nodes[0], nodes[2]] }
|
42 |
| - let(:plan_params) { { 'name' => cluster_name, 'clusters' => clusters } } |
43 |
| - let(:force) { false } |
| 42 | + let(:force) { nil } |
| 43 | + let(:start) { nil } |
| 44 | + let(:start_jobs) { nil } |
| 45 | + let(:plan_params) { { 'name' => cluster_name, 'clusters' => clusters, 'start' => start, 'start_jobs' => start_jobs, 'force' => force } } |
44 | 46 |
|
45 | 47 | context 'with non-existent cluster' do
|
46 | 48 | let(:cluster_name) { 'nonexistent' }
|
|
58 | 60 | expect_plan('lima::clusters').always_return(clusters[cluster_name])
|
59 | 61 | expect_task('lima::list').be_called_times(1).always_return(lima_list_res)
|
60 | 62 | nodes_to_stop.each do |node|
|
61 |
| - expect_task('lima::stop').be_called_times(1).with_params('name' => node, 'force' => force).always_return(stop: true) |
| 63 | + expect_task('lima::stop').be_called_times(1).with_params('name' => node, 'force' => force ? true : false).always_return(stop: true) |
62 | 64 | end
|
63 | 65 | expect_out_verbose.with_params("Defined nodes: [#{nodes.join(', ')}]")
|
64 | 66 | expect_out_verbose.with_params("Nodes to stop: [#{nodes_to_stop.join(', ')}]")
|
| 67 | + expect_plan('lima::cluster::start').be_called_times(0) |
65 | 68 | end
|
66 | 69 |
|
67 |
| - context 'with force unset' do |
| 70 | + context 'with default params' do |
68 | 71 | it 'stops all non-running nodes in the cluster' do
|
69 | 72 | result = run_plan(plan, plan_params)
|
70 | 73 |
|
|
78 | 81 |
|
79 | 82 | context 'with force => true' do
|
80 | 83 | let(:force) { true }
|
81 |
| - let(:plan_params) { super().merge('force' => force) } |
82 | 84 | let(:nodes_to_stop) { [nodes[0], nodes[1], nodes[2]] }
|
83 | 85 |
|
84 | 86 | it 'stops all non-running nodes in the cluster' do
|
|
91 | 93 | end
|
92 | 94 | end
|
93 | 95 | end
|
| 96 | + |
| 97 | + context 'with start => true' do |
| 98 | + let(:start) { true } |
| 99 | + let(:start_jobs) { 2 } |
| 100 | + let(:start_params) { { 'name' => cluster_name, 'jobs' => start_jobs, 'clusters' => clusters, 'target' => 'localhost' } } |
| 101 | + |
| 102 | + it 'stops the cluster and starts it again' do |
| 103 | + expect_plan('lima::cluster::start').be_called_times(1).with_params(start_params) |
| 104 | + |
| 105 | + result = run_plan(plan, plan_params) |
| 106 | + |
| 107 | + expect(result.ok?).to be(true) |
| 108 | + end |
| 109 | + end |
94 | 110 | end
|
95 | 111 | end
|
0 commit comments