1 |
3bc253a2
|
David Davis
|
require 'test_plugin_helper'
|
2 |
|
|
|
3 |
|
|
module Containers
|
4 |
|
|
class StepsControllerTest < ActionController::TestCase
|
5 |
38e5019c
|
Daniel Lobato
|
setup do
|
6 |
3bc253a2
|
David Davis
|
@container = FactoryGirl.create(:container)
|
7 |
38e5019c
|
Daniel Lobato
|
end
|
8 |
|
|
|
9 |
8d215ef6
|
Daniel Lobato
|
test 'wizard finishes with a redirect to the managed container' do
|
10 |
6d101d7a
|
Dmitri Dolguikh
|
state = DockerContainerWizardState.create!
|
11 |
63ae5d99
|
Dmitri Dolguikh
|
Service::Containers.any_instance.expects(:start_container!).with(equals(state))
|
12 |
|
|
.returns(@container)
|
13 |
6d101d7a
|
Dmitri Dolguikh
|
put :update, { :wizard_state_id => state.id,
|
14 |
|
|
:id => :environment,
|
15 |
d5d9d39e
|
Shlomi Zadok
|
:start_on_create => true,
|
16 |
6d101d7a
|
Dmitri Dolguikh
|
:docker_container_wizard_states_environment => { :tty => false } },
|
17 |
|
|
set_session_user
|
18 |
|
|
|
19 |
8d215ef6
|
Daniel Lobato
|
assert_redirected_to container_path(:id => @container.id)
|
20 |
|
|
end
|
21 |
41572b90
|
Partha Aji
|
|
22 |
|
|
test 'image show doesnot load katello' do
|
23 |
|
|
compute_resource = FactoryGirl.create(:docker_cr)
|
24 |
|
|
state = DockerContainerWizardState.create!
|
25 |
|
|
create_options = { :wizard_state => state,
|
26 |
|
|
:compute_resource_id => compute_resource.id
|
27 |
|
|
|
28 |
|
|
}
|
29 |
|
|
state.preliminary = DockerContainerWizardStates::Preliminary.create!(create_options)
|
30 |
|
|
DockerContainerWizardState.expects(:find).at_least_once.returns(state)
|
31 |
|
|
get :show, { :wizard_state_id => state.id, :id => :image }, set_session_user
|
32 |
|
|
refute state.image.katello?
|
33 |
|
|
refute response.body.include?("katello")
|
34 |
|
|
docker_image = @controller.instance_eval do
|
35 |
|
|
@docker_container_wizard_states_image
|
36 |
|
|
end
|
37 |
|
|
assert_equal state.image, docker_image
|
38 |
|
|
end
|
39 |
8e2848d5
|
Vanya Jauhal
|
|
40 |
|
|
test 'new container respects exposed_ports configuration' do
|
41 |
|
|
state = DockerContainerWizardState.create!
|
42 |
|
|
environment_options = {
|
43 |
|
|
:docker_container_wizard_state_id => state.id
|
44 |
|
|
}
|
45 |
|
|
state.environment = DockerContainerWizardStates::Environment.create!(environment_options)
|
46 |
|
|
state.environment.exposed_ports.create!(:name => '1654', :value => 'tcp')
|
47 |
|
|
state.environment.exposed_ports.create!(:name => '1655', :value => 'udp')
|
48 |
|
|
get :show, { :wizard_state_id => state.id, :id => :environment }, set_session_user
|
49 |
|
|
assert response.body.include?("1654")
|
50 |
|
|
assert response.body.include?("1655")
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
state.environment.exposed_ports.each do |e|
|
54 |
|
|
@container.exposed_ports.build :name => e.name,
|
55 |
|
|
:value => e.value,
|
56 |
|
|
:priority => e.priority
|
57 |
|
|
end
|
58 |
|
|
|
59 |
|
|
assert @container.parametrize.key? "ExposedPorts"
|
60 |
|
|
assert @container.parametrize["ExposedPorts"].key? "1654/tcp"
|
61 |
|
|
assert @container.parametrize["ExposedPorts"].key? "1655/udp"
|
62 |
|
|
end
|
63 |
bc82d5d5
|
Vanya Jauhal
|
|
64 |
|
|
test 'new container respects dns configuration' do
|
65 |
|
|
state = DockerContainerWizardState.create!
|
66 |
|
|
environment_options = {
|
67 |
|
|
:docker_container_wizard_state_id => state.id
|
68 |
|
|
}
|
69 |
|
|
state.environment = DockerContainerWizardStates::Environment.create!(environment_options)
|
70 |
|
|
state.environment.dns.create!(:name => '18.18.18.18')
|
71 |
|
|
state.environment.dns.create!(:name => '19.19.19.19')
|
72 |
|
|
get :show, { :wizard_state_id => state.id, :id => :environment }, set_session_user
|
73 |
|
|
assert response.body.include?("18.18.18.18")
|
74 |
|
|
assert response.body.include?("19.19.19.19")
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
state.environment.dns.each do |e|
|
78 |
|
|
@container.dns.build :name => e.name,
|
79 |
|
|
:priority => e.priority
|
80 |
|
|
end
|
81 |
|
|
|
82 |
|
|
assert @container.parametrize.key? "HostConfig"
|
83 |
|
|
assert @container.parametrize["HostConfig"].key? "Dns"
|
84 |
|
|
assert @container.parametrize["HostConfig"].value? ["18.18.18.18", "19.19.19.19"]
|
85 |
|
|
end
|
86 |
3bc253a2
|
David Davis
|
end
|
87 |
|
|
end |