Skip to content

Commit

Permalink
Use make_host better in perf_spce
Browse files Browse the repository at this point in the history
Rather than updating it after the fact, this calls make_host once with
the correct parameters.
  • Loading branch information
ekohl committed Jul 24, 2024
1 parent 07fa172 commit 993498d
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions spec/beaker/perf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,30 @@ 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
expect(@my_io.string).to eq("Setup perf on host: myHost\n")
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
expect(@my_io.string).to eq("Setup perf on host: myHost\nSetup perf on host: myOtherHost\n")
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
Expand All @@ -60,26 +62,28 @@ 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)
@options[:logger] = @my_logger
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")
Expand Down

0 comments on commit 993498d

Please sign in to comment.