Fix spec tests using the deprecated pacemaker_restart_resource? function

Currently we get the following error:

  1) pcmk_common functions pcmk_restart_resource? stonith resource
     Failure/Error: expect(pcmk_restart_resource?('stonith-fence_ipmilan-stonith-fence-1', "cib-resource.xml")).to eq true

       expected: true
            got: false

       (compared using ==)

       Diff:
       @@ -1 +1 @@
       -true
       +false

     # ./spec/unit/puppet/provider/pcmk_common_spec.rb:41:in `block (2 levels) in <top (required)>'

Reason for this is that there are two functions to detect a change in a
pcmk resource:
- pacemaker_restart_resource? -> which parses crm_simulate and was
  necessary due to https://bugzilla.redhat.com/show_bug.cgi?id=1561617
  (Fixed in pacemaker-1.1.18-12)
- pacemaker_restart_resource_ng? -> which is the preferred one and uses
  crm_diff xml output.

The problem in CI is that crm_simulate output slightly changed and so
one test is failing. Since it makes no sense to call
pacemaker_restart_resource? with a working crm_diff (i.e. any pacemaker
> 1.1.18-12), we just make sure we do not run these tests on a working
crm_diff.

We plan to remove pacemaker_restart_resource? fully now that newton (and
el7) is unsupported, so this change is a minimal non-invasive fix for
the time being.

Closes-Bug: #1921118

Change-Id: Ic8a8e127004220bb8b6735b6cf8b4b52c03fa825
This commit is contained in:
Michele Baldessari 2021-07-30 14:47:28 +02:00
parent b0ea31ae9a
commit 531283ecea
1 changed files with 15 additions and 11 deletions

View File

@ -23,22 +23,26 @@ describe "pcmk_common functions" do
expect(pcs_offline('resource update ip-172.16.11.97 cidr_netmask=32', 'cib-noop.xml')).to eq ""
expect(pcs_offline('resource update stonith-fence_ipmilan-stonith-fence-1 passwd=renVamyep3!', 'cib-noop.xml')).to eq ""
end
it "pcmk_restart_resource? noop" do
expect(pcmk_restart_resource?('foo', "cib-noop.xml")).to eq false
expect(pcmk_restart_resource?('ip-172.16.11.97', "cib-noop.xml")).to eq false
expect(pcmk_restart_resource?('stonith-fence_ipmilan-stonith-fence-1', "cib-noop.xml")).to eq false
context 'when crm_diff is not buggy', if: is_crm_diff_buggy?() == true do
it "pcmk_restart_resource? noop" do
expect(pcmk_restart_resource?('foo', "cib-noop.xml")).to eq false
expect(pcmk_restart_resource?('ip-172.16.11.97', "cib-noop.xml")).to eq false
expect(pcmk_restart_resource?('stonith-fence_ipmilan-stonith-fence-1', "cib-noop.xml")).to eq false
end
end
it "pcs_offline update to resource definition" do
expect(pcs_offline('resource update ip-172.16.11.97 cidr_netmask=31', 'cib-resource.xml')).to eq ""
expect(pcs_offline('resource update stonith-fence_ipmilan-stonith-fence-1 passwd=NewPassword', 'cib-resource.xml')).to eq ""
end
it "pcmk_restart_resource? vip resource" do
expect(pcmk_restart_resource?('foo', "cib-resource.xml")).to eq false
expect(pcmk_restart_resource?('ip-172.16.11.97', "cib-resource.xml")).to eq true
end
it "pcmk_restart_resource? stonith resource" do
expect(pcmk_restart_resource?('foo', "cib-resource.xml")).to eq false
expect(pcmk_restart_resource?('stonith-fence_ipmilan-stonith-fence-1', "cib-resource.xml")).to eq true
context 'when crm_diff is not buggy', if: is_crm_diff_buggy?() == true do
it "pcmk_restart_resource? vip resource" do
expect(pcmk_restart_resource?('foo', "cib-resource.xml")).to eq false
expect(pcmk_restart_resource?('ip-172.16.11.97', "cib-resource.xml")).to eq true
end
it "pcmk_restart_resource? stonith resource" do
expect(pcmk_restart_resource?('foo', "cib-resource.xml")).to eq false
expect(pcmk_restart_resource?('stonith-fence_ipmilan-stonith-fence-1', "cib-resource.xml")).to eq true
end
end
it "pcs_offline update to bundle definition" do