From 993498df91ada0c5b21b11f374eb959e36e1424c Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Wed, 24 Jul 2024 17:00:28 +0200 Subject: [PATCH] Use make_host better in perf_spce Rather than updating it after the fact, this calls make_host once with the correct parameters. --- spec/beaker/perf_spec.rb | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/spec/beaker/perf_spec.rb b/spec/beaker/perf_spec.rb index efe71ccea..1d8bb1d02 100644 --- a/spec/beaker/perf_spec.rb +++ b/spec/beaker/perf_spec.rb @@ -25,8 +25,7 @@ module Beaker end it 'creates a new Perf object with a single host' do - hosts = [make_host("myHost", @options)] - hosts.each { |host| host['platform'] = "centos-6-x86_64" } + hosts = [make_host("myHost", @options.merge('platform' => 'centos-6-64'))] @my_logger.remove_destination(STDOUT) perf = described_class.new(hosts, @options) expect(perf).to be_a described_class @@ -34,8 +33,10 @@ module Beaker end it 'creates a new Perf object with multiple hosts' do - hosts = [make_host("myHost", @options), make_host("myOtherHost", @options)] - hosts.each { |host| host['platform'] = "centos-6-x86_64" } + hosts = [ + make_host("myHost", @options.merge('platform' => 'centos-6-64')), + make_host("myOtherHost", @options.merge('platform' => 'centos-6-64')), + ] @my_logger.remove_destination(STDOUT) perf = described_class.new(hosts, @options) expect(perf).to be_a described_class @@ -43,10 +44,11 @@ module Beaker end it 'creates a new Perf object with multiple hosts, SLES' do - hosts = [make_host("myHost", @options), make_host("myOtherHost", @options), make_host("myThirdHost", @options)] - hosts[0]['platform'] = "centos-6-x86_64" - hosts[1]['platform'] = "sles-11-x86_64" - hosts[2]['platform'] = "opensuse-15-x86_64" + hosts = [ + make_host("myHost", @options.merge('platform' => 'centos-6-64')), + make_host("myOtherHost", @options.merge('platform' => 'sles-11-64')), + make_host("myThirdHost", @options.merge('platform' => 'opensuse-15-64')), + ] @my_logger.remove_destination(STDOUT) perf = described_class.new(hosts, @options) expect(perf).to be_a described_class @@ -60,7 +62,6 @@ module Beaker @options[:collect_perf_data] = 'normal' @options[:log_level] = :debug @options[:color] = false - @hosts = [make_host("myHost", @options), make_host("myOtherHost", @options)] @my_io = StringIO.new @my_logger = Beaker::Logger.new(@options) @my_logger.add_destination(@my_io) @@ -68,18 +69,21 @@ module Beaker end it "Does the Right Thing on Linux hosts" do - @hosts[0]['platform'] = "centos-6-x86_64" + hosts = [make_host("myHost", @options.merge('platform' => 'centos-6-64'))] @my_logger.remove_destination(STDOUT) - perf = described_class.new(@hosts, @options) + perf = described_class.new(hosts, @options) expect(perf).to be_a described_class perf.print_perf_info - expect(@my_io.string).to eq("Setup perf on host: myHost\nSetup perf on host: myOtherHost\nPerf (sysstat) not supported on host: myOtherHost\nGetting perf data for host: myHost\nGetting perf data for host: myOtherHost\nPerf (sysstat) not supported on host: myOtherHost\n") + expect(@my_io.string).to eq("Setup perf on host: myHost\nGetting perf data for host: myHost\n") end it "Does the Right Thing on non-Linux hosts" do - @hosts[0]['platform'] = "windows" + hosts = [ + make_host("myHost", @options.merge('platform' => 'windows-11-64')), + make_host("myOtherHost", @options), + ] @my_logger.remove_destination(STDOUT) - perf = described_class.new(@hosts, @options) + perf = described_class.new(hosts, @options) expect(perf).to be_a described_class perf.print_perf_info expect(@my_io.string).to eq("Setup perf on host: myHost\nPerf (sysstat) not supported on host: myHost\nSetup perf on host: myOtherHost\nPerf (sysstat) not supported on host: myOtherHost\nGetting perf data for host: myHost\nPerf (sysstat) not supported on host: myHost\nGetting perf data for host: myOtherHost\nPerf (sysstat) not supported on host: myOtherHost\n")