diff options
author | Thom May <thom@chef.io> | 2018-03-20 18:32:26 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2018-03-21 10:45:52 +0000 |
commit | 38f11a01425445c161f1dfd2c17ceacbaabf6341 (patch) | |
tree | f82f1fda08a5a7e5ba3ab90624a0433377153a06 /spec/unit | |
parent | e2eaa3fdcd9a5e2f46d90f799eedcd86cc41eb6a (diff) | |
download | chef-38f11a01425445c161f1dfd2c17ceacbaabf6341.tar.gz |
Save the node's UUID as an attributetm/chef_guid
We generate the UUID as part of the data collector report, but we didn't
make that available to the node or the chef server otherwise.
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/client_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/data_collector/messages/helpers_spec.rb | 9 | ||||
-rw-r--r-- | spec/unit/node_spec.rb | 8 |
3 files changed, 17 insertions, 1 deletions
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index 2aff7b2a71..3b974e7b2a 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -560,7 +560,6 @@ EOM expect { client.node_name }.to raise_error(Chef::Exceptions::CannotDetermineNodeName) end end - end describe "always attempt to run handlers" do diff --git a/spec/unit/data_collector/messages/helpers_spec.rb b/spec/unit/data_collector/messages/helpers_spec.rb index a241bda699..a2c6753003 100644 --- a/spec/unit/data_collector/messages/helpers_spec.rb +++ b/spec/unit/data_collector/messages/helpers_spec.rb @@ -124,8 +124,16 @@ describe Chef::DataCollector::Messages::Helpers do end describe "#node_uuid" do + context "when the node UUID is available in Chef::Config" do + it "returns the configured value" do + Chef::Config[:chef_guid] = "configured_uuid" + expect(TestMessage.node_uuid).to eq("configured_uuid") + end + end + context "when the node UUID can be read" do it "returns the read-in node UUID" do + Chef::Config[:chef_guid] = nil allow(TestMessage).to receive(:read_node_uuid).and_return("read_uuid") expect(TestMessage.node_uuid).to eq("read_uuid") end @@ -133,6 +141,7 @@ describe Chef::DataCollector::Messages::Helpers do context "when the node UUID cannot be read" do it "generated a new node UUID" do + Chef::Config[:chef_guid] = nil allow(TestMessage).to receive(:read_node_uuid).and_return(nil) allow(TestMessage).to receive(:generate_node_uuid).and_return("generated_uuid") expect(TestMessage.node_uuid).to eq("generated_uuid") diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index df85b79fc5..c9f3d7d1d2 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -953,6 +953,14 @@ describe Chef::Node do expect(node.automatic_attrs[:platform_version]).to eq("23.42") end + it "sets the chef guid attribute correctly" do + guid = Chef::Config[:chef_guid] + Chef::Config[:chef_guid] = "test-guid-guid" + node.consume_external_attrs(@ohai_data, {}) + expect(node.automatic_attrs[:chef_guid]).to eq("test-guid-guid") + Chef::Config[:chef_guid] = guid + end + it "consumes the run list from provided json attributes" do node.consume_external_attrs(@ohai_data, { "run_list" => ["recipe[unicorn]"] }) expect(node.run_list).to eq(["recipe[unicorn]"]) |