Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bundler.d/test.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
group :test do
gem 'benchmark-ips'
gem 'ci_reporter', '>= 1.6.3', "< 2.0.0", :require => false

# Technically this is a hard dependency of the facts module but that's only
# used in discovery. This at least allows us to run the tests on it
gem 'facter', :require => false
gem 'mocha', '~> 1.10', :require => false
gem 'minitest'
gem 'minitest-reporters', :require => false
gem 'mocha', '~> 3.1.0', :require => false
gem 'rack-test'
gem 'rake'
gem 'rubocop', '~> 1.56.0'
gem 'rubocop-performance', '~> 1.5.2'
gem 'rubocop-rake'
gem 'ruby-prof', '< 1.4'
gem 'test-unit'
gem 'webmock'
end
3 changes: 1 addition & 2 deletions tasks/jenkins.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "ci/reporter/rake/test_unit"
namespace :jenkins do
desc 'Sets up CI environment for testing and run tests'
task :unit => ['ci:setup:testunit', 'rake:test']
task :unit => :test
end
2 changes: 1 addition & 1 deletion test/bmc/bmc_api_shell_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

ENV['RACK_ENV'] = 'test'

class BmcApiShellTest < Test::Unit::TestCase
class BmcApiShellTest < Minitest::Test
include Rack::Test::Methods

def app
Expand Down
2 changes: 1 addition & 1 deletion test/bmc/bmc_api_ssh_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

ENV['RACK_ENV'] = 'test'

class BmcApiShellTest < Test::Unit::TestCase
class BmcApiShellTest < Minitest::Test
include Rack::Test::Methods

def app
Expand Down
37 changes: 19 additions & 18 deletions test/bmc/bmc_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# instead you must testing something like:
# put "/#{host}/chassis/power/on", body, "CONTENT_TYPE" => "application/json"

class BmcApiTest < Test::Unit::TestCase
class BmcApiTest < Minitest::Test
include Rack::Test::Methods
include RedfishTestHelper

Expand All @@ -26,6 +26,7 @@ def setup
pass ||= ENV["ipmipass"] || "pass"
@host ||= ENV["ipmihost"] || "host"
provider ||= ENV["ipmiprovider"] || "ipmitool"
Proxy::BMC::Plugin.load_test_settings(:bmc_default_provider => 'freeipmi')
@args = { 'bmc_provider' => provider, 'blah' => 'test' }
authorize user, pass
mask_redfish_acceess
Expand Down Expand Up @@ -114,9 +115,9 @@ def test_api_bmc_setup_returns_new_ipmi_proxy_given_ipmitool
Rubyipmi.stubs(:is_provider_installed?).returns(true)
Proxy::BMC::Plugin.settings.stubs(:bmc_default_provider).returns('freeipmi')
Proxy::BMC::IPMI.any_instance.stubs(:poweron).returns(true)
Proxy::BMC::IPMI.any_instance.expects(:connect).with(:host => 'host', :username => 'user', :password => 'pass',
:bmc_provider => 'ipmitool',
:options => {"privilege" => "OPERATOR"})
Proxy::BMC::IPMI.any_instance.expects(:connect).with({:host => 'host', :username => 'user', :password => 'pass',
:bmc_provider => 'ipmitool',
:options => {"privilege" => "OPERATOR"}})
body = {'bmc_provider' => 'ipmitool', :options => {'privilege' => 'OPERATOR'}}.to_json
put "/#{host}/chassis/power/on", body, "CONTENT_TYPE" => "application/json"
end
Expand All @@ -125,9 +126,9 @@ def test_api_bmc_setup_returns_new_ipmi_proxy_given_freeipmi
Rubyipmi.stubs(:is_provider_installed?).returns(true)
Proxy::BMC::Plugin.load_test_settings(:bmc_default_provider => 'freeipmi')
Proxy::BMC::IPMI.any_instance.stubs(:poweron).returns(true)
Proxy::BMC::IPMI.any_instance.expects(:connect).with(:host => 'host', :username => 'user', :password => 'pass',
:bmc_provider => 'freeipmi',
:options => {"privilege" => "OPERATOR"})
Proxy::BMC::IPMI.any_instance.expects(:connect).with({:host => 'host', :username => 'user', :password => 'pass',
:bmc_provider => 'freeipmi',
:options => {"privilege" => "OPERATOR"}})
body = {'bmc_provider' => 'freeipmi', :options => {'privilege' => 'OPERATOR'}}.to_json
put "/#{host}/chassis/power/on", body, "CONTENT_TYPE" => "application/json"
end
Expand All @@ -144,9 +145,9 @@ def test_api_uses_options_hash_from_body
Rubyipmi.stubs(:is_provider_installed?).returns(true)
Proxy::BMC::Plugin.load_test_settings(:bmc_default_provider => 'freeipmi')
Proxy::BMC::IPMI.any_instance.stubs(:poweron).returns(true)
Proxy::BMC::IPMI.any_instance.expects(:connect).with(:host => 'host', :username => 'user', :password => 'pass',
:bmc_provider => 'freeipmi',
:options => {"driver" => "lan20", "privilege" => "OPERATOR"})
Proxy::BMC::IPMI.any_instance.expects(:connect).with({:host => 'host', :username => 'user', :password => 'pass',
:bmc_provider => 'freeipmi',
:options => {"driver" => "lan20", "privilege" => "OPERATOR"}})
body = {'bmc_provider' => 'freeipmi', :options => {"driver" => "lan20", 'privilege' => 'OPERATOR'}}.to_json
put "/#{host}/chassis/power/on", body, "CONTENT_TYPE" => "application/json"
assert last_response.ok?, "Last response was not ok: #{last_response.body}"
Expand All @@ -158,9 +159,9 @@ def test_api_uses_options_hash_when_nil
Rubyipmi.stubs(:is_provider_installed?).returns(true)
Proxy::BMC::Plugin.load_test_settings(:bmc_default_provider => 'freeipmi')
Proxy::BMC::IPMI.any_instance.stubs(:poweron).returns(true)
Proxy::BMC::IPMI.any_instance.expects(:connect).with(:host => 'host', :username => 'user', :password => 'pass',
:bmc_provider => 'freeipmi',
:options => nil)
Proxy::BMC::IPMI.any_instance.expects(:connect).with({:host => 'host', :username => 'user', :password => 'pass',
:bmc_provider => 'freeipmi',
:options => nil})
body = {'bmc_provider' => 'freeipmi', :options => nil}.to_json
put "/#{host}/chassis/power/on", body, "CONTENT_TYPE" => "application/json"
assert last_response.ok?, "Last response was not ok: #{last_response.body}"
Expand Down Expand Up @@ -463,7 +464,7 @@ def test_api_returns_error_for_get_bmc_action_bogus

def test_api_can_set_bmc_action_reset_type_cold
Rubyipmi.stubs(:is_provider_installed?).returns(true)
Proxy::BMC::IPMI.any_instance.expects(:reset).returns(true)
Proxy::BMC::IPMI.any_instance.expects(:reset).with('cold').returns(true)
put "/#{@host}/bmc/reset", :type => "cold"
assert last_response.ok?, "Last response was not ok: #{last_response.body}"
data = JSON.parse(last_response.body)
Expand All @@ -472,7 +473,7 @@ def test_api_can_set_bmc_action_reset_type_cold

def test_api_can_set_bmc_action_reset_type_warm
Rubyipmi.stubs(:is_provider_installed?).returns(true)
Proxy::BMC::IPMI.any_instance.expects(:reset).returns(true)
Proxy::BMC::IPMI.any_instance.expects(:reset).with('warm').returns(true)
put "/#{@host}/bmc/reset", :type => "warm"
assert last_response.ok?, "Last response was not ok: #{last_response.body}"
data = JSON.parse(last_response.body)
Expand Down Expand Up @@ -612,9 +613,9 @@ def test_api_calls_redfish_provider_reboot
def test_api_can_pass_options_in_body
Rubyipmi.stubs(:is_provider_installed?).returns(true)
args = { 'bmc_provider' => 'freeipmi', :options => {:driver => 'lan20', :privilege => 'USER'} }.to_json
Proxy::BMC::IPMI.any_instance.expects(:connect).with(:username => 'user', :password => 'pass',
:host => 'host', :bmc_provider => 'freeipmi',
:options => {"driver" => "lan20", "privilege" => "USER"})
Proxy::BMC::IPMI.any_instance.expects(:connect).with({:username => 'user', :password => 'pass',
:host => 'host', :bmc_provider => 'freeipmi',
:options => {"driver" => "lan20", "privilege" => "USER"}})
Proxy::BMC::IPMI.any_instance.stubs(:bootbios).returns(true)
put "/#{@host}/chassis/config/bootdevice/bios", args, "CONTENT_TYPE" => "application/json"
assert last_response.ok?, "Last response was not ok: #{last_response.body}"
Expand Down
72 changes: 43 additions & 29 deletions test/bmc/bmc_redfish_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'bmc/redfish_test_helper'
require 'json'

class BmcRedfishTest < Test::Unit::TestCase
class BmcRedfishTest < Minitest::Test
include RedfishTestHelper

def setup
Expand Down Expand Up @@ -41,125 +41,139 @@ def test_bootdevice_pxe_uses_patch_if_match
system_mock = mock('system')

system_mock.expects(:patch_if_match).with(
'Boot' => {
'BootSourceOverrideTarget' => 'Pxe',
'BootSourceOverrideEnabled' => 'Once',
{
'Boot' => {
'BootSourceOverrideTarget' => 'Pxe',
'BootSourceOverrideEnabled' => 'Once',
},
}
).returns(true)

@bmc.expects(:system).returns(system_mock)
@bmc.expects(:powercycle).never

result = @bmc.bootdevice = { :device => 'pxe', :reboot => false, :persistent => false }
assert_not_nil result
refute_nil result
end

def test_bootdevice_disk_persistent_uses_patch_if_match
# Test that bootdevice uses patch_if_match with persistent boot
system_mock = mock('system')

system_mock.expects(:patch_if_match).with(
'Boot' => {
'BootSourceOverrideTarget' => 'Hdd',
'BootSourceOverrideEnabled' => 'Enabled',
{
'Boot' => {
'BootSourceOverrideTarget' => 'Hdd',
'BootSourceOverrideEnabled' => 'Enabled',
},
}
).returns(true)

@bmc.expects(:system).returns(system_mock)
@bmc.expects(:powercycle).never

result = @bmc.bootdevice = { :device => 'disk', :reboot => false, :persistent => true }
assert_not_nil result
refute_nil result
end

def test_bootdevice_with_reboot
# Test bootdevice with reboot option
system_mock = mock('system')

system_mock.expects(:patch_if_match).with(
'Boot' => {
'BootSourceOverrideTarget' => 'Pxe',
'BootSourceOverrideEnabled' => 'Enabled',
{
'Boot' => {
'BootSourceOverrideTarget' => 'Pxe',
'BootSourceOverrideEnabled' => 'Enabled',
},
}
).returns(true)

@bmc.expects(:system).returns(system_mock)
@bmc.expects(:powercycle).once

result = @bmc.bootdevice = { :device => 'pxe', :reboot => true, :persistent => true }
assert_not_nil result
refute_nil result
end

def test_bootpxe_calls_bootdevice
# Test that convenience method bootpxe works
system_mock = mock('system')

system_mock.expects(:patch_if_match).with(
'Boot' => {
'BootSourceOverrideTarget' => 'Pxe',
'BootSourceOverrideEnabled' => 'Once',
{
'Boot' => {
'BootSourceOverrideTarget' => 'Pxe',
'BootSourceOverrideEnabled' => 'Once',
},
}
).returns(true)

@bmc.expects(:system).returns(system_mock)
@bmc.expects(:powercycle).never

result = @bmc.bootpxe(false, false)
assert_not_nil result
refute_nil result
end

def test_bootdisk_calls_bootdevice
# Test that convenience method bootdisk works
system_mock = mock('system')

system_mock.expects(:patch_if_match).with(
'Boot' => {
'BootSourceOverrideTarget' => 'Hdd',
'BootSourceOverrideEnabled' => 'Once',
{
'Boot' => {
'BootSourceOverrideTarget' => 'Hdd',
'BootSourceOverrideEnabled' => 'Once',
},
}
).returns(true)

@bmc.expects(:system).returns(system_mock)
@bmc.expects(:powercycle).never

result = @bmc.bootdisk(false, false)
assert_not_nil result
refute_nil result
end

def test_bootbios_calls_bootdevice
# Test that convenience method bootbios works
system_mock = mock('system')

system_mock.expects(:patch_if_match).with(
'Boot' => {
'BootSourceOverrideTarget' => 'BiosSetup',
'BootSourceOverrideEnabled' => 'Once',
{
'Boot' => {
'BootSourceOverrideTarget' => 'BiosSetup',
'BootSourceOverrideEnabled' => 'Once',
},
}
).returns(true)

@bmc.expects(:system).returns(system_mock)
@bmc.expects(:powercycle).never

result = @bmc.bootbios(false, false)
assert_not_nil result
refute_nil result
end

def test_bootcdrom_calls_bootdevice
# Test that convenience method bootcdrom works
system_mock = mock('system')

system_mock.expects(:patch_if_match).with(
'Boot' => {
'BootSourceOverrideTarget' => 'Cd',
'BootSourceOverrideEnabled' => 'Once',
{
'Boot' => {
'BootSourceOverrideTarget' => 'Cd',
'BootSourceOverrideEnabled' => 'Once',
},
}
).returns(true)

@bmc.expects(:system).returns(system_mock)
@bmc.expects(:powercycle).never

result = @bmc.bootcdrom(false, false)
assert_not_nil result
refute_nil result
end

def test_identifystatus_uses_indicator_led_when_location_indicator_absent
Expand Down
6 changes: 3 additions & 3 deletions test/bmc/bmc_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'test_helper'
require 'bmc/ipmi'

class BmcTest < Test::Unit::TestCase
class BmcTest < Minitest::Test
def setup
Rubyipmi.stubs(:is_provider_installed?).with('ipmitool').returns(true)
@args = { :username => "user", :password => "pass", :bmc_provider => "ipmitool", :host => "host" }
Expand All @@ -16,7 +16,7 @@ def test_sets_logger
end

def test_creates_rubyipmi_object
assert_not_nil bmc
refute_nil bmc
end

def test_should_run_connection_test
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_should_power_reset
end

def test_should_power_reboot
assert_raise(NotImplementedError) do
assert_raises(NotImplementedError) do
bmc.powerreboot
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/dependency_injection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class TestDependsTwo
inject_attr :singleton_dependency, :singleton_var
end

class DependencyInjectionTest < Test::Unit::TestCase
class DependencyInjectionTest < Minitest::Test
def test_can_locate_dependency
assert TestContainer.instance.get_dependency(:test_dependency_one)
assert TestContainer.instance.get_dependency(:singleton_dependency)
Expand Down
2 changes: 1 addition & 1 deletion test/dhcp/conf_parser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'dhcp_common/dhcp_common'
require 'dhcp_common/isc/configuration_parser'

class Proxy::DHCP::CommonISC::ConfigurationParserTest < Test::Unit::TestCase
class Proxy::DHCP::CommonISC::ConfigurationParserTest < Minitest::Test
def teardown
Rsec::Fail.reset
end
Expand Down
2 changes: 1 addition & 1 deletion test/dhcp/dhcp_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

ENV['RACK_ENV'] = 'test'

class DhcpApiTest < Test::Unit::TestCase
class DhcpApiTest < Minitest::Test
include Rack::Test::Methods
include SparcAttrs

Expand Down
2 changes: 1 addition & 1 deletion test/dhcp/dhcp_config_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'test_helper'
require 'dhcp/dhcp_plugin'

class DhcpConfigTest < Test::Unit::TestCase
class DhcpConfigTest < Minitest::Test
def test_omitted_settings_have_default_values
Proxy::DhcpPlugin.load_test_settings()
assert_equal '127.0.0.1', Proxy::DhcpPlugin.settings.server
Expand Down
2 changes: 1 addition & 1 deletion test/dhcp/dhcp_isc_provider_interface_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'test_helper'
require 'dhcp_common/isc/omapi_provider'

class IscDhcpProviderInterfaceTest < Test::Unit::TestCase
class IscDhcpProviderInterfaceTest < Minitest::Test
def test_provider_interface
assert_dhcp_provider_interface(Proxy::DHCP::CommonISC::IscOmapiProvider.new({}, nil))
end
Expand Down
Loading
Loading