File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
cookbooks/aws-parallelcluster-slurm Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,12 @@ def are_bulk_custom_slurm_settings_updated?
3636
3737def are_mount_or_unmount_required?
3838 require 'json'
39- change_set = JSON . load_file ( "#{ node [ 'cluster' ] [ 'shared_dir' ] } /change-set.json" )
39+
40+ change_set_path = node [ "cluster" ] [ "change_set_path" ]
41+
42+ return false unless ::File . exist? ( change_set_path )
43+
44+ change_set = JSON . load_file ( change_set_path )
4045 change_set [ "changeSet" ] . each do |change |
4146 next unless change [ "updatePolicy" ] == "SHARED_STORAGE_UPDATE_POLICY"
4247
Original file line number Diff line number Diff line change 11require 'spec_helper'
22
33describe "aws-parallelcluster-slurm:libraries:are_mount_unmount_required" do
4+ CHANGE_SET_PATH = "/CHANGE_SET_PATH"
5+
46 let ( :node ) do
57 {
6- "cluster" => { "shared_dir " => "/SHARED_DIR" } ,
8+ "cluster" => { "change_set_path " => CHANGE_SET_PATH } ,
79 }
810 end
911
1012 shared_examples "the correct method" do |changeset , expected_result |
1113 it "returns #{ expected_result } " do
12- allow ( File ) . to receive ( :read ) . with ( "/SHARED_DIR/change-set.json" ) . and_return ( JSON . dump ( changeset ) )
14+ if changeset . nil?
15+ allow ( File ) . to receive ( :exist? ) . with ( CHANGE_SET_PATH ) . and_return ( false )
16+ allow ( File ) . to receive ( :read ) . with ( CHANGE_SET_PATH ) . and_call_original
17+ else
18+ allow ( File ) . to receive ( :exist? ) . with ( CHANGE_SET_PATH ) . and_return ( true )
19+ allow ( File ) . to receive ( :read ) . with ( CHANGE_SET_PATH ) . and_return ( JSON . dump ( changeset ) )
20+ end
1321 result = are_mount_or_unmount_required?
1422 expect ( result ) . to eq ( expected_result )
1523 end
1624 end
1725
26+ context "when changeset does not exist" do
27+ changeset = nil
28+ include_examples "the correct method" , changeset , false
29+ end
30+
1831 context "when changeset is empty" do
1932 changeset = {
2033 "changeSet" => [ ] ,
You can’t perform that action at this time.
0 commit comments