openshift-origin-controller 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYRIGHT +1 -0
- data/Gemfile +4 -0
- data/LICENSE +12 -0
- data/README.md +3 -0
- data/Rakefile +9 -0
- data/app/controllers/app_events_controller.rb +115 -0
- data/app/controllers/application_templates_controller.rb +19 -0
- data/app/controllers/applications_controller.rb +214 -0
- data/app/controllers/base_controller.rb +367 -0
- data/app/controllers/cartridges_controller.rb +48 -0
- data/app/controllers/descriptors_controller.rb +23 -0
- data/app/controllers/dns_resolvable_controller.rb +35 -0
- data/app/controllers/domains_controller.rb +156 -0
- data/app/controllers/emb_cart_controller.rb +276 -0
- data/app/controllers/emb_cart_events_controller.rb +52 -0
- data/app/controllers/environment_controller.rb +11 -0
- data/app/controllers/estimates_controller.rb +71 -0
- data/app/controllers/gear_groups_controller.rb +53 -0
- data/app/controllers/gears_controller.rb +70 -0
- data/app/controllers/keys_controller.rb +96 -0
- data/app/controllers/legacy_broker_controller.rb +510 -0
- data/app/controllers/quickstarts_controller.rb +29 -0
- data/app/controllers/user_controller.rb +38 -0
- data/app/helpers/cartridge_helper.rb +25 -0
- data/app/helpers/legacy_broker_helper.rb +21 -0
- data/app/helpers/user_action_logger.rb +38 -0
- data/app/models/application.rb +1718 -0
- data/app/models/application_template.rb +27 -0
- data/app/models/cartridge_cache.rb +51 -0
- data/app/models/cloud_user.rb +334 -0
- data/app/models/component_instance.rb +228 -0
- data/app/models/connection_endpoint.rb +10 -0
- data/app/models/district.rb +210 -0
- data/app/models/domain.rb +234 -0
- data/app/models/gear.rb +376 -0
- data/app/models/group_instance.rb +306 -0
- data/app/models/key.rb +20 -0
- data/app/models/legacy_reply.rb +15 -0
- data/app/models/legacy_request.rb +126 -0
- data/app/models/link.rb +11 -0
- data/app/models/message.rb +10 -0
- data/app/models/name_server_cache.rb +46 -0
- data/app/models/optional_param.rb +12 -0
- data/app/models/param.rb +13 -0
- data/app/models/remote_job.rb +57 -0
- data/app/models/rest_application.rb +126 -0
- data/app/models/rest_application10.rb +106 -0
- data/app/models/rest_application12.rb +124 -0
- data/app/models/rest_application_estimate.rb +12 -0
- data/app/models/rest_application_template.rb +20 -0
- data/app/models/rest_cartridge10.rb +41 -0
- data/app/models/rest_cartridge11.rb +151 -0
- data/app/models/rest_domain.rb +43 -0
- data/app/models/rest_domain10.rb +42 -0
- data/app/models/rest_estimates.rb +16 -0
- data/app/models/rest_gear.rb +14 -0
- data/app/models/rest_gear_group.rb +26 -0
- data/app/models/rest_key.rb +24 -0
- data/app/models/rest_reply.rb +31 -0
- data/app/models/rest_user.rb +43 -0
- data/app/models/result_io.rb +67 -0
- data/app/models/usage_record.rb +37 -0
- data/app/models/validators/app_validator.rb +30 -0
- data/app/models/validators/key_validator.rb +30 -0
- data/app/models/validators/namespace_validator.rb +18 -0
- data/config/routes.rb +36 -0
- data/lib/controller_engine.rb +7 -0
- data/lib/openshift-origin-controller.rb +14 -0
- data/lib/openshift/application_container_proxy.rb +241 -0
- data/lib/openshift/auth_service.rb +101 -0
- data/lib/openshift/data_store.rb +33 -0
- data/lib/openshift/dns_service.rb +41 -0
- data/lib/openshift/mongo_data_store.rb +671 -0
- data/openshift-origin-controller.gemspec +42 -0
- data/rubygem-openshift-origin-controller.spec +274 -0
- data/test/cucumber/application-estimate.feature +25 -0
- data/test/cucumber/cartridge-10gen-mms-agent.feature +28 -0
- data/test/cucumber/cartridge-cron.feature +32 -0
- data/test/cucumber/cartridge-haproxy.feature +31 -0
- data/test/cucumber/cartridge-jenkins-build.feature +12 -0
- data/test/cucumber/cartridge-jenkins-client.feature +10 -0
- data/test/cucumber/cartridge-lifecycle-diy.feature +21 -0
- data/test/cucumber/cartridge-lifecycle-jbossas.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jbosseap.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jbossews10.feature +61 -0
- data/test/cucumber/cartridge-lifecycle-jenkins.feature +41 -0
- data/test/cucumber/cartridge-lifecycle-nodejs.feature +59 -0
- data/test/cucumber/cartridge-lifecycle-perl.feature +40 -0
- data/test/cucumber/cartridge-lifecycle-php.feature +106 -0
- data/test/cucumber/cartridge-lifecycle-python.feature +40 -0
- data/test/cucumber/cartridge-lifecycle-ruby18.feature +49 -0
- data/test/cucumber/cartridge-lifecycle-ruby19.feature +41 -0
- data/test/cucumber/cartridge-mongodb.feature +31 -0
- data/test/cucumber/cartridge-mysql.feature +30 -0
- data/test/cucumber/cartridge-php.feature +14 -0
- data/test/cucumber/cartridge-phpmyadmin.feature +32 -0
- data/test/cucumber/cartridge-postgresql.feature +32 -0
- data/test/cucumber/cartridge-runtime-extended-db.feature +64 -0
- data/test/cucumber/cartridge-runtime-extended-jboss.feature +24 -0
- data/test/cucumber/cartridge-runtime-extended-nodejs.feature +21 -0
- data/test/cucumber/cartridge-runtime-extended-perl.feature +18 -0
- data/test/cucumber/cartridge-runtime-extended-php.feature +19 -0
- data/test/cucumber/cartridge-runtime-extended-python.feature +18 -0
- data/test/cucumber/cartridge-runtime-extended-ruby.feature +22 -0
- data/test/cucumber/cartridge-runtime-standard-diy.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-jbossas.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jbosseap.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jbossews10.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-jenkins.feature +8 -0
- data/test/cucumber/cartridge-runtime-standard-nodejs.feature +7 -0
- data/test/cucumber/cartridge-runtime-standard-perl.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-php.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-python.feature +6 -0
- data/test/cucumber/cartridge-runtime-standard-ruby.feature +19 -0
- data/test/cucumber/cartridge-switchyard.feature +36 -0
- data/test/cucumber/descriptor.feature +40 -0
- data/test/cucumber/embedded.feature +44 -0
- data/test/cucumber/idler.feature +75 -0
- data/test/cucumber/misc/descriptor/manifest.yml +22 -0
- data/test/cucumber/misc/php/db_test.php +21 -0
- data/test/cucumber/openshift-node.feature +21 -0
- data/test/cucumber/rest-application-templates.feature +31 -0
- data/test/cucumber/rest-applications.feature +431 -0
- data/test/cucumber/rest-cartridge-types.feature +16 -0
- data/test/cucumber/rest-domains.feature +276 -0
- data/test/cucumber/rest-gears.feature +38 -0
- data/test/cucumber/rest-keys.feature +247 -0
- data/test/cucumber/rest-quickstarts.feature +27 -0
- data/test/cucumber/rest-workflow.feature +64 -0
- data/test/cucumber/step_definitions/api_steps.rb +369 -0
- data/test/cucumber/step_definitions/application-estimate-steps.rb +51 -0
- data/test/cucumber/step_definitions/application_steps.rb +215 -0
- data/test/cucumber/step_definitions/cartridge-10gen-mms-agent_steps.rb +11 -0
- data/test/cucumber/step_definitions/cartridge-cron_steps.rb +51 -0
- data/test/cucumber/step_definitions/cartridge-haproxy_steps.rb +30 -0
- data/test/cucumber/step_definitions/cartridge-jenkins_steps.rb +93 -0
- data/test/cucumber/step_definitions/cartridge-lifecycle-nodejs_steps.rb +30 -0
- data/test/cucumber/step_definitions/cartridge-mongodb_steps.rb +60 -0
- data/test/cucumber/step_definitions/cartridge-mysql_steps.rb +56 -0
- data/test/cucumber/step_definitions/cartridge-php_steps.rb +72 -0
- data/test/cucumber/step_definitions/cartridge-postgresql_steps.rb +59 -0
- data/test/cucumber/step_definitions/cartridge-switchyard_steps.rb +29 -0
- data/test/cucumber/step_definitions/client_steps.rb +12 -0
- data/test/cucumber/step_definitions/descriptor_step.rb +32 -0
- data/test/cucumber/step_definitions/idler_steps.rb +37 -0
- data/test/cucumber/step_definitions/node_steps.rb +203 -0
- data/test/cucumber/step_definitions/runtime_steps.rb +547 -0
- data/test/cucumber/step_definitions/runtime_url_steps.rb +46 -0
- data/test/cucumber/step_definitions/trap-user-extended_steps.rb +14 -0
- data/test/cucumber/step_definitions/trap-user_steps.rb +58 -0
- data/test/cucumber/support/00_setup_helper.rb +106 -0
- data/test/cucumber/support/app_helper.rb +243 -0
- data/test/cucumber/support/assertions.rb +52 -0
- data/test/cucumber/support/command_helper.rb +453 -0
- data/test/cucumber/support/dns_helper.rb +54 -0
- data/test/cucumber/support/env.rb +5 -0
- data/test/cucumber/support/process_helper.rb +44 -0
- data/test/cucumber/support/runtime_support.rb +440 -0
- data/test/cucumber/support/unused.rb +27 -0
- data/test/cucumber/support/user_helper.rb +37 -0
- data/test/cucumber/trap-user-extended.feature +53 -0
- data/test/cucumber/trap-user.feature +34 -0
- data/test/ddns/1.168.192-rev.db.init +13 -0
- data/test/ddns/HOWTO.txt +207 -0
- data/test/ddns/Kexample.com.+157+06142.key +1 -0
- data/test/ddns/Kexample.com.+157+06142.private +7 -0
- data/test/ddns/authconfig.rb +14 -0
- data/test/ddns/example.com.db.init +23 -0
- data/test/ddns/example.com.key +4 -0
- data/test/ddns/named.ca +52 -0
- data/test/ddns/named.conf +48 -0
- data/test/ddns/named.empty +10 -0
- data/test/ddns/named.localhost +10 -0
- data/test/ddns/named.loopback +11 -0
- data/test/ddns/named.rfc1912.zones +42 -0
- data/test/ddns/named.root.key +5 -0
- data/test/ddns/named_service.rb +127 -0
- data/test/unit/bind_dns_service_test.rb +167 -0
- data/test/unit/broker_auth_test.rb +28 -0
- metadata +545 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
When /^I add dependencies to (deplist.txt|package.json) on node modules(.*)$/ do |depfile, modules|
|
|
4
|
+
Dir.chdir(@app.repo) do
|
|
5
|
+
case depfile.strip
|
|
6
|
+
when "deplist.txt"
|
|
7
|
+
run("echo -e '#{modules.gsub(" ", "\n")}' >> ./deplist.txt")
|
|
8
|
+
when "package.json"
|
|
9
|
+
pkg = ""
|
|
10
|
+
File.open("package.json") { |f| pkg = JSON.parse(f.read) }
|
|
11
|
+
modules.split.each { |m| pkg['dependencies'][m] = "*" }
|
|
12
|
+
File.open("package.json", "w") { |f| f.write(JSON.dump(pkg)) }
|
|
13
|
+
end
|
|
14
|
+
run("git commit -a -m 'Test change'")
|
|
15
|
+
run("git push >> " + @app.get_log("git_push_nodejs_deps") + " 2>&1")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Then /^the application will have the (.*) node modules installed$/ do |modules|
|
|
20
|
+
app_dir = File.join("/var/lib/openshift", @app.uid, @app.type)
|
|
21
|
+
node_mods_dir = File.join(app_dir, "node_modules")
|
|
22
|
+
repo_mods_dir = File.join(app_dir, "repo", "node_modules")
|
|
23
|
+
modules.split.each do |m|
|
|
24
|
+
if !File.directory?(File.join(node_mods_dir, m)) &&
|
|
25
|
+
!File.directory?(File.join(repo_mods_dir, m))
|
|
26
|
+
raise "Missing node_modules dir for #{m}"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# step descriptions for MongoDB cartridge behavior.
|
|
2
|
+
|
|
3
|
+
require 'mongo'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
Then /^the mongodb configuration file will( not)? exist$/ do |negate|
|
|
7
|
+
cart = @gear.carts['mongodb-2.2']
|
|
8
|
+
user_root = "#{$home_root}/#{@gear.uuid}/#{cart.name}"
|
|
9
|
+
config_file = "#{user_root}/etc/mongodb.conf"
|
|
10
|
+
|
|
11
|
+
begin
|
|
12
|
+
cnffile = File.new config_file
|
|
13
|
+
rescue Errno::ENOENT
|
|
14
|
+
cnffile = nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
unless negate
|
|
18
|
+
cnffile.should be_a(File)
|
|
19
|
+
else
|
|
20
|
+
cnffile.should be_nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Then /^the mongodb database will( not)? +exist$/ do |negate|
|
|
26
|
+
cart = @gear.carts['mongodb-2.2']
|
|
27
|
+
user_root = "#{$home_root}/#{@gear.uuid}/#{cart.name}"
|
|
28
|
+
config_file = "#{user_root}/etc/mongodb.conf"
|
|
29
|
+
data_dir = "#{user_root}/data/"
|
|
30
|
+
|
|
31
|
+
begin
|
|
32
|
+
datadir = Dir.new data_dir
|
|
33
|
+
rescue Errno::ENOENT
|
|
34
|
+
datadir = nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
unless negate
|
|
38
|
+
datadir.should include "#{@app.name}.0"
|
|
39
|
+
datadir.should include "#{@app.name}.ns"
|
|
40
|
+
datadir.should include "mongod.lock"
|
|
41
|
+
datadir.should include "admin.0"
|
|
42
|
+
datadir.should include "admin.ns"
|
|
43
|
+
else
|
|
44
|
+
datadir.should be_nil
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Then /^the mongodb admin user will have access$/ do
|
|
49
|
+
mongo_cart = @gear.carts['mongodb-2.2']
|
|
50
|
+
|
|
51
|
+
begin
|
|
52
|
+
dbh = Mongo::Connection.new(mongo_cart.db.ip.to_s).db(@app.name)
|
|
53
|
+
dbh.authenticate(mongo_cart.db.username.to_s, mongo_cart.db.password.to_s)
|
|
54
|
+
rescue Mongo::ConnectionError
|
|
55
|
+
dbh = nil
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
dbh.should be_a(Mongo::DB)
|
|
59
|
+
dbh.logout if dbh
|
|
60
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# step descriptions for MySQL cartridge behavior.
|
|
2
|
+
|
|
3
|
+
require 'mysql'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
Then /^the mysql configuration file will( not)? exist$/ do |negate|
|
|
7
|
+
mysql_cart = @gear.carts['mysql-5.1']
|
|
8
|
+
|
|
9
|
+
mysql_user_root = "#{$home_root}/#{@gear.uuid}/#{mysql_cart.name}"
|
|
10
|
+
mysql_config_file = "#{mysql_user_root}/etc/my.cnf"
|
|
11
|
+
|
|
12
|
+
if negate
|
|
13
|
+
assert_file_not_exists mysql_config_file
|
|
14
|
+
else
|
|
15
|
+
assert_file_exists mysql_config_file
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Then /^the mysql database will( not)? +exist$/ do |negate|
|
|
21
|
+
mysql_cart = @gear.carts['mysql-5.1']
|
|
22
|
+
|
|
23
|
+
mysql_user_root = "#{$home_root}/#{@gear.uuid}/#{mysql_cart.name}"
|
|
24
|
+
mysql_data_dir = "#{mysql_user_root}/data"
|
|
25
|
+
|
|
26
|
+
begin
|
|
27
|
+
datadir = Dir.new mysql_data_dir
|
|
28
|
+
rescue Errno::ENOENT
|
|
29
|
+
datadir = nil
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
unless negate
|
|
33
|
+
datadir.should include "ibdata1"
|
|
34
|
+
datadir.should include "ib_logfile0"
|
|
35
|
+
datadir.should include "mysql"
|
|
36
|
+
datadir.should include @app.name
|
|
37
|
+
else
|
|
38
|
+
datadir.should be_nil
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
Then /^the mysql admin user will have access$/ do
|
|
43
|
+
mysql_cart = @gear.carts['mysql-5.1']
|
|
44
|
+
|
|
45
|
+
begin
|
|
46
|
+
dbh = Mysql.real_connect(mysql_cart.db.ip,
|
|
47
|
+
mysql_cart.db.username,
|
|
48
|
+
mysql_cart.db.password,
|
|
49
|
+
'mysql')
|
|
50
|
+
rescue Mysql::Error
|
|
51
|
+
dbh = nil
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
dbh.should be_a(Mysql)
|
|
55
|
+
dbh.close if dbh
|
|
56
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Steps specific to the php-5.3 cartridge.
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'test/unit/assertions'
|
|
4
|
+
|
|
5
|
+
include Test::Unit::Assertions
|
|
6
|
+
|
|
7
|
+
# NOTE: Assumes the test context is the basic steps provided
|
|
8
|
+
# by runtime_steps.rb
|
|
9
|
+
Then /^the php application will( not)? be aliased$/ do | negate |
|
|
10
|
+
good_status = negate ? 1 : 0
|
|
11
|
+
|
|
12
|
+
exit_status = -1
|
|
13
|
+
OpenShift::timeout(20) do
|
|
14
|
+
begin
|
|
15
|
+
sleep 1
|
|
16
|
+
command = "/usr/bin/curl -L -H 'Host: #{@app.name}.#{$alias_domain}' -s http://localhost/health_check.php | /bin/grep -q -e '^1$'"
|
|
17
|
+
exit_status = runcon command, $selinux_user, $selinux_role, $selinux_type
|
|
18
|
+
end while exit_status != good_status
|
|
19
|
+
end
|
|
20
|
+
exit_status.should == good_status
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
When /^I (expose-port|conceal-port) the php application$/ do |action|
|
|
24
|
+
@cart.run_hook action, 0
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Then /^the php application will( not)? be exposed$/ do | negate |
|
|
28
|
+
exitcode, output = @cart.run_hook_output 'show-port', 0
|
|
29
|
+
|
|
30
|
+
if negate
|
|
31
|
+
assert_nil output[0].index('PROXY_PORT')
|
|
32
|
+
else
|
|
33
|
+
assert_not_nil output[0].index('PROXY_PORT')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
Then /^the php file permissions are correct/ do
|
|
38
|
+
gear_uuid = @gear.uuid
|
|
39
|
+
app_home = "/var/lib/openshift/#{gear_uuid}"
|
|
40
|
+
uid = Etc.getpwnam(gear_uuid).uid
|
|
41
|
+
gid = Etc.getpwnam(gear_uuid).gid
|
|
42
|
+
mcs = get_mcs_level(uid)
|
|
43
|
+
se_context = "unconfined_u:object_r:openshift_var_lib_t:#{mcs}"
|
|
44
|
+
se_context2 = "unconfined_u:object_r:openshift_rw_file_t:#{mcs}"
|
|
45
|
+
# Configure files (relative to app_home)
|
|
46
|
+
configure_files = { "php-5.3" => ['root', 'root', '40755', se_context],
|
|
47
|
+
"php-5.3/" => ['root', 'root', '40755', se_context],
|
|
48
|
+
".pearrc" => ['root', 'root', '100644', se_context],
|
|
49
|
+
"php-5.3/conf/" => ['root', 'root', '40755', se_context],
|
|
50
|
+
"php-5.3/conf/php.ini" => ['root', 'root', '100644', se_context],
|
|
51
|
+
"php-5.3/conf/magic" => ['root', 'root', '100644', se_context],
|
|
52
|
+
"php-5.3/conf.d/" => ['root', 'root', '40755', se_context],
|
|
53
|
+
"php-5.3/conf.d/openshift.conf" => ['root', 'root', '100644', se_context],
|
|
54
|
+
"app-root/data/" => [gear_uuid, gear_uuid, '40755', se_context2],
|
|
55
|
+
"php-5.3/logs/" => [gear_uuid, gear_uuid, '40755', se_context],
|
|
56
|
+
"php-5.3/phplib/pear/" => [gear_uuid, gear_uuid, '40755', se_context],
|
|
57
|
+
"app-root/data/" => [gear_uuid, gear_uuid, '40750', se_context2],
|
|
58
|
+
"app-root/repo/" => [gear_uuid, gear_uuid, '40750', se_context],
|
|
59
|
+
"php-5.3/run/" => [gear_uuid, gear_uuid, '40755', se_context],
|
|
60
|
+
"php-5.3/run/httpd.pid" => [gear_uuid, gear_uuid, '100644', se_context],
|
|
61
|
+
"app-root/repo/php/index.php" => [gear_uuid, gear_uuid, '100664', se_context],
|
|
62
|
+
"php-5.3/sessions/" => [gear_uuid, gear_uuid, '40755', se_context],
|
|
63
|
+
"php-5.3/tmp/" => [gear_uuid, gear_uuid, '40755', se_context]
|
|
64
|
+
}
|
|
65
|
+
configure_files.each do | file, permissions |
|
|
66
|
+
raise "Invalid permissions for #{file}" unless mode?("#{app_home}/#{file}", permissions[2])
|
|
67
|
+
raise "Invalid context for #{file}" unless context?("#{app_home}/#{file}", permissions[3])
|
|
68
|
+
target_uid = Etc.getpwnam(permissions[0]).uid.to_i
|
|
69
|
+
target_gid = Etc.getgrnam(permissions[1]).gid.to_i
|
|
70
|
+
raise "Invalid ownership for #{file}" unless owner?("#{app_home}/#{file}", target_uid, target_gid)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# step descriptions for PostgreSQL cartridge behavior.
|
|
2
|
+
|
|
3
|
+
require 'pg'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Then /^the postgresql configuration file will( not)? exist$/ do |negate|
|
|
8
|
+
pgsql_cart = @gear.carts['postgresql-8.4']
|
|
9
|
+
|
|
10
|
+
pgsql_user_root = "#{$home_root}/#{@gear.uuid}/#{pgsql_cart.name}"
|
|
11
|
+
pgsql_config_file = "#{pgsql_user_root}/data/postgresql.conf"
|
|
12
|
+
|
|
13
|
+
if negate
|
|
14
|
+
assert_file_not_exists pgsql_config_file
|
|
15
|
+
else
|
|
16
|
+
assert_file_exists pgsql_config_file
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
Then /^the postgresql database will( not)? +exist$/ do |negate|
|
|
22
|
+
pgsql_cart = @gear.carts['postgresql-8.4']
|
|
23
|
+
|
|
24
|
+
pgsql_user_root = "#{$home_root}/#{@gear.uuid}/#{pgsql_cart.name}"
|
|
25
|
+
pgsql_data_dir = "#{pgsql_user_root}/data"
|
|
26
|
+
|
|
27
|
+
begin
|
|
28
|
+
datadir = Dir.new pgsql_data_dir
|
|
29
|
+
rescue Errno::ENOENT
|
|
30
|
+
datadir = nil
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
unless negate
|
|
34
|
+
datadir.should include "base"
|
|
35
|
+
datadir.should include "global"
|
|
36
|
+
datadir.should include "pg_clog"
|
|
37
|
+
datadir.should include "pg_log"
|
|
38
|
+
datadir.should include "pg_xlog"
|
|
39
|
+
else
|
|
40
|
+
datadir.should be_nil
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
Then /^the postgresql admin user will have access$/ do
|
|
46
|
+
pgsql_cart = @gear.carts['postgresql-8.4']
|
|
47
|
+
|
|
48
|
+
begin
|
|
49
|
+
# FIXME: For now use psql -- we should try programatically later.
|
|
50
|
+
dbconn = PGconn.connect(pgsql_cart.db.ip, 5432, '', '', 'postgres',
|
|
51
|
+
pgsql_cart.db.username, pgsql_cart.db.password)
|
|
52
|
+
rescue PGError
|
|
53
|
+
$logger.error("Couldn't connect to Postgres, ip=#{pgsql_cart.db.ip}, user=#{pgsql_cart.db.username}, pwd=#{pgsql_cart.db.password}")
|
|
54
|
+
dbconn = nil
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
dbconn.should be_a(PGconn)
|
|
58
|
+
dbconn.close if dbconn
|
|
59
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# step descriptions for MySQL cartridge behavior.
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
Then /^the eap module configuration file will( not)? exist$/ do |negate|
|
|
6
|
+
|
|
7
|
+
env_dir = "#{$home_root}/#{@gear.uuid}/.env"
|
|
8
|
+
module_config_file = "#{env_dir}/OPENSHIFT_JBOSSEAP_MODULE_PATH"
|
|
9
|
+
|
|
10
|
+
if negate
|
|
11
|
+
assert_file_not_exists module_config_file
|
|
12
|
+
else
|
|
13
|
+
assert_file_exists module_config_file
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
Then /^the as module configuration file will( not)? exist$/ do |negate|
|
|
18
|
+
|
|
19
|
+
env_dir = "#{$home_root}/#{@gear.uuid}/.env"
|
|
20
|
+
module_config_file = "#{env_dir}/OPENSHIFT_JBOSSAS_MODULE_PATH"
|
|
21
|
+
|
|
22
|
+
if negate
|
|
23
|
+
assert_file_not_exists module_config_file
|
|
24
|
+
else
|
|
25
|
+
assert_file_exists module_config_file
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Given /^an accepted node$/ do
|
|
2
|
+
# TODO: Add any required checks here
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
Given /^the libra client tools$/ do
|
|
6
|
+
File.exists?($create_app_script).should be_true
|
|
7
|
+
File.exists?($create_domain_script).should be_true
|
|
8
|
+
File.exists?($client_config).should be_true
|
|
9
|
+
File.exists?($ctl_app_script).should be_true
|
|
10
|
+
|
|
11
|
+
File.exists?($rhc_script).should be_true
|
|
12
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'openshift-origin-controller'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
When /^a descriptor file is provided$/ do
|
|
6
|
+
@descriptor_file = File.expand_path("../misc/descriptor/manifest.yml", File.expand_path(File.dirname(__FILE__)))
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
When /^the descriptor file is parsed as a cartridge$/ do
|
|
10
|
+
f = File.open(@descriptor_file)
|
|
11
|
+
@app = OpenShift::Cartridge.new.from_descriptor(YAML.load(f))
|
|
12
|
+
f.close
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Then /^the descriptor profile exists$/ do
|
|
16
|
+
@app.default_profile.nil?.should be_false
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Then /^atleast (\d+) group exists$/ do |count|
|
|
20
|
+
len = @app.profiles[0].groups.length
|
|
21
|
+
check = (len >= Integer(count))
|
|
22
|
+
check.should be_true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Then /^atleast (\d+) component exists$/ do |count|
|
|
26
|
+
g = @app.profiles[0].groups[0]
|
|
27
|
+
comp = @app.profiles[0].components(g.component_refs[0].component)
|
|
28
|
+
check = (not comp.nil?)
|
|
29
|
+
check.should be_true
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# match against oo-idle and oo-restore to avoid conflict
|
|
2
|
+
When /^I oo-(idle|restore) the application$/ do |action|
|
|
3
|
+
cmd = nil
|
|
4
|
+
|
|
5
|
+
case action
|
|
6
|
+
when "idle"
|
|
7
|
+
cmd = "/usr/sbin/oo-idler -u #{@gear.uuid}"
|
|
8
|
+
when "restore"
|
|
9
|
+
cmd = "/usr/sbin/oo-restorer -u #{@gear.uuid}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
exit_code = run cmd
|
|
13
|
+
assert_equal 0, exit_code, "Failed to #{action} application running #{cmd}"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Then /^I record the active capacity( after idling)?$/ do |negate|
|
|
17
|
+
@active_capacity = `facter active_capacity`.to_f
|
|
18
|
+
|
|
19
|
+
if (negate)
|
|
20
|
+
# active capacity may be 0.0 after idling.
|
|
21
|
+
@active_capacity.should be >= 0.0
|
|
22
|
+
else
|
|
23
|
+
@active_capacity.should be > 0.0
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Then /^the active capacity has been (reduced|increased)$/ do |change|
|
|
28
|
+
current_capacity = `facter active_capacity`.to_f
|
|
29
|
+
current_capacity.should be >= 0.0
|
|
30
|
+
|
|
31
|
+
case change
|
|
32
|
+
when "reduced"
|
|
33
|
+
@active_capacity.should be > current_capacity
|
|
34
|
+
when "increased"
|
|
35
|
+
@active_capacity.should be < current_capacity
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#
|
|
2
|
+
#
|
|
3
|
+
# Steps that can be used to check applications installed on a server (node)
|
|
4
|
+
#
|
|
5
|
+
#require 'etc'
|
|
6
|
+
|
|
7
|
+
require 'open4'
|
|
8
|
+
require 'dnsruby'
|
|
9
|
+
|
|
10
|
+
# Controller cartridge command paths
|
|
11
|
+
$cartridge_root = '/usr/libexec/openshift/cartridges'
|
|
12
|
+
$controller_config_path = "oo-app-create"
|
|
13
|
+
$controller_config_format = "#{$controller_config_path} -c '%s' -a '%s' --with-namespace '%s' --with-app-name '%s'"
|
|
14
|
+
$controller_deconfig_path = "oo-app-destroy"
|
|
15
|
+
$controller_deconfig_format = "#{$controller_deconfig_path} -c '%s' -a '%s' --with-namespace '%s' --with-app-name '%s'"
|
|
16
|
+
$home_root = "/var/lib/openshift"
|
|
17
|
+
|
|
18
|
+
# --------------------------------------------------------------------------
|
|
19
|
+
# Account Checks
|
|
20
|
+
# --------------------------------------------------------------------------
|
|
21
|
+
# These must run after server_steps.rb: I create a <name> app for <framework>
|
|
22
|
+
|
|
23
|
+
# These depend on test data of this form:
|
|
24
|
+
# And the following test data
|
|
25
|
+
# | accountname
|
|
26
|
+
# | 00112233445566778899aabbccdde000
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# copied from server-common/openshift/user.rb 20110630
|
|
30
|
+
def gen_small_uuid()
|
|
31
|
+
# Put config option for rhlogin here so we can ignore uuid for dev environments
|
|
32
|
+
%x[/usr/bin/uuidgen].gsub('-', '').strip
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def gen_unique_login_and_namespace(namespace=nil)
|
|
36
|
+
if !namespace
|
|
37
|
+
chars = ("1".."9").to_a
|
|
38
|
+
namespace = "ci" + Array.new(8, '').collect{chars[rand(chars.size)]}.join
|
|
39
|
+
end
|
|
40
|
+
login = "cucumber-test_#{namespace}@example.com"
|
|
41
|
+
[ login, namespace ]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def gen_unique_app_name
|
|
45
|
+
chars = ("1".."9").to_a
|
|
46
|
+
"app" + Array.new(4, '').collect{chars[rand(chars.size)]}.join
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Given /^a new gear with namespace "([^\"]*)" and app name "([^\"]*)"$/ do |namespace, name|
|
|
50
|
+
# generate a random account name and use the stock SSH keys
|
|
51
|
+
# generate a random UUID and use the stock keys
|
|
52
|
+
acctname = gen_small_uuid
|
|
53
|
+
login, namespace = gen_unique_login_and_namespace(namespace)
|
|
54
|
+
@account = {
|
|
55
|
+
'accountname' => acctname,
|
|
56
|
+
'login' => login,
|
|
57
|
+
'namespace' => namespace,
|
|
58
|
+
'appnames' => [ name ],
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
command = $controller_config_format % [acctname, acctname, namespace, name]
|
|
62
|
+
runcon(command, $selinux_user, $selinux_role, $selinux_type)
|
|
63
|
+
|
|
64
|
+
# get and store the account UID's by name
|
|
65
|
+
@account['uid'] = Etc.getpwnam(acctname).uid
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
Given /^a new guest account$/ do
|
|
69
|
+
# generate a random account name and use the stock SSH keys
|
|
70
|
+
# generate a random UUID and use the stock keys
|
|
71
|
+
acctname = gen_small_uuid
|
|
72
|
+
login, namespace = gen_unique_login_and_namespace
|
|
73
|
+
appname = gen_unique_app_name
|
|
74
|
+
@account = {
|
|
75
|
+
'accountname' => acctname,
|
|
76
|
+
'login' => login,
|
|
77
|
+
'namespace' => namespace,
|
|
78
|
+
'appnames' => [ appname ],
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
command = $controller_config_format % [acctname, acctname, namespace, appname]
|
|
82
|
+
runcon(command, $selinux_user, $selinux_role, $selinux_type)
|
|
83
|
+
|
|
84
|
+
# get and store the account UID's by name
|
|
85
|
+
@account['uid'] = Etc.getpwnam(acctname).uid
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
Given /^the guest account has no application installed$/ do
|
|
89
|
+
# Assume this is true
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
When /^I create a guest account$/ do
|
|
93
|
+
# call /usr/libexec/openshift/cartridges @table.hashes.each do |row|
|
|
94
|
+
# generate a random account name and use the stock SSH keys
|
|
95
|
+
# generate a random UUID and use the stock keys
|
|
96
|
+
acctname = gen_small_uuid
|
|
97
|
+
login, namespace = gen_unique_login_and_namespace
|
|
98
|
+
appname = gen_unique_app_name
|
|
99
|
+
@account = {
|
|
100
|
+
'accountname' => acctname,
|
|
101
|
+
'login' => login,
|
|
102
|
+
'namespace' => namespace,
|
|
103
|
+
'appnames' => [ appname ],
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
command = $controller_config_format % [acctname, acctname, namespace, appname]
|
|
107
|
+
runcon(command, $selinux_user, $selinux_role, $selinux_type)
|
|
108
|
+
|
|
109
|
+
# get and store the account UID's by name
|
|
110
|
+
@account['uid'] = Etc.getpwnam(acctname).uid
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
When /^I delete the guest account$/ do
|
|
114
|
+
# call /usr/libexec/openshift/cartridges @table.hashes.each do |row|
|
|
115
|
+
|
|
116
|
+
command = $controller_deconfig_format % [@account['accountname'],
|
|
117
|
+
@account['accountname'],
|
|
118
|
+
@account['namespace'],
|
|
119
|
+
@account['appnames'][0]]
|
|
120
|
+
runcon(command, $selinux_user, $selinux_role, $selinux_type)
|
|
121
|
+
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
When /^I create a new namespace$/ do
|
|
125
|
+
acctname = gen_small_uuid
|
|
126
|
+
login, namespace = gen_unique_login_and_namespace
|
|
127
|
+
@account = {
|
|
128
|
+
'accountname' => acctname,
|
|
129
|
+
'login' => login,
|
|
130
|
+
'password' => 'xyz123',
|
|
131
|
+
'namespace' => namespace
|
|
132
|
+
}
|
|
133
|
+
register_user(login, "xyz123") if $registration_required
|
|
134
|
+
ec = run("#{$rhc_script} domain create #{namespace} -l #{login} -p #{@account['password']} -d")
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
When /^I delete the namespace$/ do
|
|
138
|
+
ec = run("#{$rhc_script} domain destroy #{@account['namespace']} -l #{@account['login']} -p #{@account['password']} -d")
|
|
139
|
+
ec.should be == 0
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
Then /^a namespace should get deleted$/ do
|
|
143
|
+
res = Dnsruby::Resolver.new
|
|
144
|
+
begin
|
|
145
|
+
maxttl=300
|
|
146
|
+
minretry=5
|
|
147
|
+
Timeout::timeout(maxttl + 20) do
|
|
148
|
+
while true
|
|
149
|
+
Dnsruby::PacketSender.clear_caches
|
|
150
|
+
ret = res.query("#{@account['namespace']}.dev.rhcloud.com", Dnsruby::Types.TXT)
|
|
151
|
+
if ret.answer.length >= 1
|
|
152
|
+
if ret.answer[0].ttl > maxttl
|
|
153
|
+
retryin = maxttl
|
|
154
|
+
elsif ret.answer[0].ttl < minretry
|
|
155
|
+
retryin = minretry
|
|
156
|
+
else
|
|
157
|
+
retryin = ret.answer[0].ttl
|
|
158
|
+
end
|
|
159
|
+
else
|
|
160
|
+
retryin = maxttl
|
|
161
|
+
end
|
|
162
|
+
$logger.debug "The domain is still resolvable. Waiting for the TTL to expire in #{retryin} seconds."
|
|
163
|
+
sleep(retryin)
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
rescue Timeout::Error
|
|
167
|
+
$logger.warn "Timed out while waiting for the domain name to disappear."
|
|
168
|
+
raise
|
|
169
|
+
rescue Dnsruby::NXDomain
|
|
170
|
+
true
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
Then /^an account password entry should( not)? exist$/ do |negate|
|
|
175
|
+
# use @app['uuid'] for account name
|
|
176
|
+
|
|
177
|
+
begin
|
|
178
|
+
@pwent = Etc.getpwnam @account['accountname']
|
|
179
|
+
rescue
|
|
180
|
+
nil
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
if negate
|
|
184
|
+
@pwent.should be_nil
|
|
185
|
+
else
|
|
186
|
+
@pwent.should_not be_nil
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
Then /^an HTTP proxy config file should( not)? exist$/ do |negate|
|
|
191
|
+
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
Then /^an account home directory should( not)? exist$/ do |negate|
|
|
195
|
+
@homedir = File.directory? "#{$home_root}/#{@account['accountname']}"
|
|
196
|
+
|
|
197
|
+
if negate
|
|
198
|
+
@homedir.should_not be_true
|
|
199
|
+
else
|
|
200
|
+
@homedir.should be_true
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
|