vagrant-openshift 1.0.12 → 1.0.13

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/README.asciidoc +5 -3
  4. data/lib/vagrant-openshift/action/build_openshift3.rb +30 -5
  5. data/lib/vagrant-openshift/action/{install_rhc.rb → build_openshift3_base_images.rb} +13 -11
  6. data/lib/vagrant-openshift/action/{run_openshift2_tests.rb → build_sti.rb} +28 -11
  7. data/lib/vagrant-openshift/action/clean.rb +1 -4
  8. data/lib/vagrant-openshift/action/clean_network_setup.rb +1 -1
  9. data/lib/vagrant-openshift/action/download_artifacts_openshift3.rb +4 -1
  10. data/lib/vagrant-openshift/action/{download_artifacts_openshift2.rb → download_artifacts_sti.rb} +3 -11
  11. data/lib/vagrant-openshift/action/generate_template.rb +38 -40
  12. data/lib/vagrant-openshift/action/install_openshift3.rb +5 -16
  13. data/lib/vagrant-openshift/action/{build_openshift2.rb → install_openshift3_asset_dependencies.rb} +17 -5
  14. data/lib/vagrant-openshift/action/install_openshift3_base_dependencies.rb +20 -5
  15. data/lib/vagrant-openshift/action/{local_openshift2_checkout.rb → push_openshift3_release.rb} +14 -14
  16. data/lib/vagrant-openshift/action/run_openshift3_tests.rb +38 -14
  17. data/lib/vagrant-openshift/action/run_sti_tests.rb +64 -0
  18. data/lib/vagrant-openshift/action.rb +44 -83
  19. data/lib/vagrant-openshift/command/build_openshift3.rb +9 -0
  20. data/lib/vagrant-openshift/command/{build_openshift2_base.rb → build_openshift3_base_images.rb} +5 -5
  21. data/lib/vagrant-openshift/command/{build_openshift3_infrastructure_images.rb → build_sti.rb} +10 -12
  22. data/lib/vagrant-openshift/command/checkout_repositories.rb +1 -1
  23. data/lib/vagrant-openshift/command/{install_rhc.rb → install_openshift3_assets_base.rb} +5 -5
  24. data/lib/vagrant-openshift/command/local_openshift3_setup.rb +1 -1
  25. data/lib/vagrant-openshift/command/openshift_init.rb +4 -4
  26. data/lib/vagrant-openshift/command/push_openshift3_release.rb +57 -0
  27. data/lib/vagrant-openshift/command/repo_sync_openshift3.rb +1 -13
  28. data/lib/vagrant-openshift/command/{repo_sync_openshift2.rb → repo_sync_sti.rb} +11 -19
  29. data/lib/vagrant-openshift/command/test_openshift3.rb +8 -0
  30. data/lib/vagrant-openshift/command/test_openshift3_image.rb +8 -17
  31. data/lib/vagrant-openshift/command/test_sti.rb +59 -0
  32. data/lib/vagrant-openshift/config.rb +2 -14
  33. data/lib/vagrant-openshift/constants.rb +3 -67
  34. data/lib/vagrant-openshift/helper/command_helper.rb +0 -3
  35. data/lib/vagrant-openshift/plugin.rb +24 -29
  36. data/lib/vagrant-openshift/provisioner.rb +5 -37
  37. data/lib/vagrant-openshift/templates/builder/Rakefile +0 -205
  38. data/lib/vagrant-openshift/templates/command/init-openshift/box_info.yaml +34 -49
  39. data/lib/vagrant-openshift/version.rb +1 -1
  40. metadata +33 -48
  41. data/lib/vagrant-openshift/action/build_openshift3_images.rb +0 -54
  42. data/lib/vagrant-openshift/action/build_openshift3_infrastructure_images.rb +0 -50
  43. data/lib/vagrant-openshift/action/checkout_openshift2_tests.rb +0 -57
  44. data/lib/vagrant-openshift/action/create_openshift2_puppet_file.rb +0 -84
  45. data/lib/vagrant-openshift/action/create_openshift2_test_users.rb +0 -36
  46. data/lib/vagrant-openshift/action/idle_all_gears_openshift2.rb +0 -36
  47. data/lib/vagrant-openshift/action/install_openshift2_base_dependencies.rb +0 -50
  48. data/lib/vagrant-openshift/action/install_openshift2_build_dependencies.rb +0 -48
  49. data/lib/vagrant-openshift/action/preserve_mcollective_logs.rb +0 -48
  50. data/lib/vagrant-openshift/action/setup_builder_files.rb +0 -57
  51. data/lib/vagrant-openshift/action/uninstall_openshift2_rpms.rb +0 -37
  52. data/lib/vagrant-openshift/command/build_openshift3_images.rb +0 -68
  53. data/lib/vagrant-openshift/command/local_openshift2_setup.rb +0 -62
  54. data/lib/vagrant-openshift/command/test_openshift2.rb +0 -108
  55. data/lib/vagrant-openshift/templates/builder/lib/rpm.rb +0 -248
  56. data/lib/vagrant-openshift/templates/builder/lib/test.rb +0 -432
  57. data/lib/vagrant-openshift/templates/builder/yum-listbuilddep +0 -124
  58. data/lib/vagrant-openshift/templates/command/init-openshift/Vagrantfile.erb +0 -171
@@ -41,6 +41,14 @@ module Vagrant
41
41
  o.on("-d","--artifacts", String, "Download logs") do |f|
42
42
  options[:download] = true
43
43
  end
44
+
45
+ o.on("-s","--skip-image-cleanup", String, "Skip Docker image teardown for E2E test") do |f|
46
+ options[:skip_image_cleanup] = true
47
+ end
48
+
49
+ o.on("-c","--report-coverage", String, "Generate code coverage report in Jenkins") do |f|
50
+ options[:report_coverage] = true
51
+ end
44
52
  end
45
53
 
46
54
  # Parse the options
@@ -77,7 +77,7 @@ module Vagrant
77
77
  set -x
78
78
 
79
79
  # so we can call sti
80
- PATH=/data/bin:$PATH
80
+ PATH=/data/src/github.com/openshift/source-to-image/_output/go/bin:/data/src/github.com/openshift/source-to-image/_output/local/go/bin:$PATH
81
81
 
82
82
  # create a temp dir to play in
83
83
  temp_dir=$(mktemp -d /tmp/image_test.XXXXXXX)
@@ -97,28 +97,19 @@ git checkout #{ref}
97
97
  # get git sha1
98
98
  git_sha1=`git rev-parse --short #{ref}`
99
99
 
100
- # grab the latest image from the index
101
- docker pull #{image}:latest
100
+ # Build the STI image we use for testing
101
+ docker build -t #{image}-candidate .
102
+ status=$?
102
103
 
103
- status=0
104
-
105
- # build and test the sample app, if it exists
106
- if [ -d test-app -a -f .sti/bin/test ]; then
107
- # build
108
- sti build test-app #{image} #{app_name} --clean
104
+ # Run the STI image test framework
105
+ if [ $status -eq 0 ]; then
106
+ IMAGE_NAME=#{image}-candidate ./test/run
109
107
  status=$?
110
-
111
- if [ $status -eq 0 ]; then
112
- # run tests
113
- docker run --rm -v $temp_dir/#{source_dir}/.sti/bin:/tmp/sti #{app_name} /tmp/sti/test
114
-
115
- status=$?
116
- fi
117
108
  fi
118
109
 
119
110
  if [ $status -eq 0 ]; then
120
111
  # get the image id
121
- image_id=`docker inspect --format="{{ .Id }}" #{image}:latest`
112
+ image_id=`docker inspect --format="{{ .Id }}" #{image}-candidate:latest`
122
113
 
123
114
  # tag it devenv-ready
124
115
  docker tag $image_id #{image}:devenv-ready
@@ -0,0 +1,59 @@
1
+ #--
2
+ # Copyright 2013 Red Hat, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #++
16
+ require_relative "../action"
17
+
18
+ module Vagrant
19
+ module Openshift
20
+ module Commands
21
+ class TestSti < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "run the sti tests"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:download] = false
31
+ options[:all] = false
32
+
33
+ opts = OptionParser.new do |o|
34
+ o.banner = "Usage: vagrant test-sti [machine-name]"
35
+ o.separator ""
36
+
37
+ o.on("-a", "--all", String, "Run all tests") do |f|
38
+ options[:all] = true
39
+ end
40
+
41
+ o.on("-d","--artifacts", String, "Download logs") do |f|
42
+ options[:download] = true
43
+ end
44
+ end
45
+
46
+ # Parse the options
47
+ argv = parse_options(opts)
48
+ return if !argv
49
+
50
+ with_target_vms(argv, :reverse => true) do |machine|
51
+ actions = Vagrant::Openshift::Action.run_sti_tests(options)
52
+ @env.action_runner.run actions, {:machine => machine}
53
+ 0
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -17,38 +17,26 @@
17
17
  module Vagrant
18
18
  module Openshift
19
19
  class Config < Vagrant.plugin(2, :config)
20
- attr_accessor :cloud_domain, :ignore_packages, :additional_services, :container,
21
- :advanced_puppet_values, :repos_base, :os_repo, :os_updates_repo,
22
- :jenkins_repo_base, :optional_repo, :os_extras_repo, :os_scl_repo
20
+ attr_accessor :cloud_domain, :repos_base, :os_repo, :os_updates_repo,
21
+ :optional_repo, :os_extras_repo, :os_scl_repo
23
22
 
24
23
  def initialize
25
24
  super
26
25
 
27
- @ignore_packages = UNSET_VALUE
28
26
  @cloud_domain = UNSET_VALUE
29
- @additional_services = UNSET_VALUE
30
- @container = UNSET_VALUE
31
27
  @repos_base = UNSET_VALUE
32
28
  @os_repo = nil
33
29
  @os_updates_repo = nil
34
30
  @os_extras_repo = nil
35
- @jenkins_repo_base = UNSET_VALUE
36
31
  @optional_repo = nil
37
32
  @os_scl_repo = nil
38
-
39
- @advanced_puppet_values = UNSET_VALUE
40
33
  end
41
34
 
42
35
  def finalize!
43
36
  super
44
37
 
45
- @ignore_packages = [] if @ignore_packages == UNSET_VALUE
46
38
  @cloud_domain = "example.com" if @cloud_domain == UNSET_VALUE
47
- @additional_services = [] if @additional_services == UNSET_VALUE
48
- @container = "selinux" if @container == UNSET_VALUE
49
- @advanced_puppet_values = {} if @advanced_puppet_values == UNSET_VALUE
50
39
  @repos_base = nil if @repos_base == UNSET_VALUE
51
- @jenkins_repo_base = "http://pkg.jenkins-ci.org/redhat/" if @jenkins_repo_base == UNSET_VALUE
52
40
  end
53
41
  end
54
42
  end
@@ -19,33 +19,14 @@ module Vagrant
19
19
  module Openshift
20
20
  class Constants
21
21
 
22
- FILTER_BROKER="broker"
23
- FILTER_CONSOLE="console"
24
- FILTER_IMAGES="images"
25
- FILTER_RHC="rhc"
26
- FILTER_ORIGIN="origin"
27
-
28
22
  def self.repos(env)
29
- is_fedora = env[:machine].communicate.test("test -e /etc/fedora-release")
30
- if is_fedora
31
- openshift3_repos
32
- else
33
- openshift2_repos
34
- end
35
- end
36
-
37
- def self.openshift2_repos
38
- {
39
- 'origin-server' => 'https://github.com/openshift/origin-server.git',
40
- 'rhc' => 'https://github.com/openshift/rhc.git',
41
- 'puppet-openshift_origin' => 'https://github.com/openshift/puppet-openshift_origin.git'
42
- }
23
+ openshift3_repos
43
24
  end
44
25
 
45
26
  def self.openshift3_repos
46
27
  {
47
- 'origin' => 'https://github.com/openshift/origin.git'
48
-
28
+ 'origin' => 'https://github.com/openshift/origin.git',
29
+ 'source-to-image' => 'https://github.com/openshift/source-to-image.git'
49
30
  }.merge(openshift3_images)
50
31
  end
51
32
 
@@ -56,13 +37,6 @@ module Vagrant
56
37
  }
57
38
  end
58
39
 
59
- def self.openshift3_infrastructure_images
60
- {
61
- 'sti-builder' => 'origin/images/builder/docker/sti-builder',
62
- 'docker-builder' => 'origin/images/builder/docker/docker-builder'
63
- }
64
- end
65
-
66
40
  def self.images
67
41
  [
68
42
  'centos'
@@ -85,48 +59,10 @@ module Vagrant
85
59
  Pathname.new "/data/src/github.com/openshift/"
86
60
  end
87
61
 
88
- def self.deps_marker
89
- Pathname.new "/.origin_deps_installed"
90
- end
91
-
92
62
  def self.git_ssh
93
63
  ""
94
64
  end
95
65
 
96
- def self.restart_services_cmd(is_fedora)
97
- services = [ 'mongod', 'activemq', 'cgconfig', 'cgred', 'named',
98
- 'openshift-broker', 'openshift-console',
99
- 'openshift-node-web-proxy', 'openshift-watchman',
100
- 'sshd', 'httpd' ]
101
-
102
- if(is_fedora)
103
- services << 'mcollective'
104
- else
105
- services << 'ruby193-mcollective'
106
- end
107
-
108
- cmd = []
109
- cmd += services.map do |service|
110
- "/sbin/service #{service} stop;"
111
- end
112
- cmd << "rm -f /var/www/openshift/broker/httpd/run/httpd.pid;"
113
- cmd << "rm -f /var/www/openshift/console/httpd/run/httpd.pid;"
114
- cmd += services.map do |service|
115
- "/sbin/service #{service} start;"
116
- end
117
- cmd << "rm -rf /var/www/openshift/broker/tmp/cache/*;"
118
- cmd << "/etc/cron.minutely/openshift-facts;"
119
- cmd << "/sbin/service openshift-tc start || /sbin/service openshift-tc reload;"
120
- if(is_fedora)
121
- cmd << "/sbin/service network reload;"
122
- else
123
- cmd << "/sbin/service network restart;"
124
- end
125
- cmd << "/sbin/service messagebus restart;"
126
- cmd << "/sbin/service oddjobd restart;"
127
-
128
- cmd
129
- end
130
66
  end
131
67
  end
132
68
  end
@@ -19,9 +19,6 @@ require "timeout"
19
19
  module Vagrant
20
20
  module Openshift
21
21
  module CommandHelper
22
- def scl_wrapper(is_fedora, command)
23
- is_fedora ? command : %{scl enable ruby193 "#{command}"}
24
- end
25
22
 
26
23
  def sudo(machine, command, options={})
27
24
  stdout = []
@@ -32,19 +32,14 @@ module Vagrant
32
32
  Config
33
33
  end
34
34
 
35
- command "sync-openshift2" do
36
- require_relative "command/repo_sync_openshift2"
37
- Commands::RepoSyncOpenshift2
38
- end
39
-
40
35
  command "sync-openshift3" do
41
36
  require_relative "command/repo_sync_openshift3"
42
37
  Commands::RepoSyncOpenshift3
43
38
  end
44
39
 
45
- command "build-openshift2-base" do
46
- require_relative "command/build_openshift2_base"
47
- Commands::BuildOpenshift2Base
40
+ command "sync-sti" do
41
+ require_relative "command/repo_sync_sti"
42
+ Commands::RepoSyncSti
48
43
  end
49
44
 
50
45
  command "build-openshift3-base" do
@@ -57,24 +52,29 @@ module Vagrant
57
52
  Commands::BuildOpenshift3
58
53
  end
59
54
 
55
+ command "build-sti" do
56
+ require_relative "command/build_sti"
57
+ Commands::BuildSti
58
+ end
59
+
60
60
  command "install-openshift3" do
61
61
  require_relative "command/install_openshift3"
62
62
  Commands::InstallOpenshift3
63
63
  end
64
64
 
65
+ command "install-openshift3-assets-base" do
66
+ require_relative "command/install_openshift3_assets_base"
67
+ Commands::InstallOpenshift3AssetsBase
68
+ end
69
+
65
70
  command "try-restart-openshift3" do
66
71
  require_relative "command/try_restart_openshift3"
67
72
  Commands::TryRestartOpenshift3
68
73
  end
69
74
 
70
- command "build-openshift3-images" do
71
- require_relative "command/build_openshift3_images"
72
- Commands::BuildOpenshift3Images
73
- end
74
-
75
- command "build-openshift3-infrastructure-images" do
76
- require_relative "command/build_openshift3_infrastructure_images"
77
- Commands::BuildOpenshift3InfrastructureImages
75
+ command "build-openshift3-base-images" do
76
+ require_relative "command/build_openshift3_base_images"
77
+ Commands::BuildOpenshift3BaseImages
78
78
  end
79
79
 
80
80
  command "origin-init" do
@@ -82,19 +82,14 @@ module Vagrant
82
82
  Commands::OpenshiftInit
83
83
  end
84
84
 
85
- command "openshift2-local-checkout" do
86
- require_relative "command/local_openshift2_setup"
87
- Commands::LocalOpenshift2Setup
88
- end
89
-
90
85
  command "openshift3-local-checkout" do
91
86
  require_relative "command/local_openshift3_setup"
92
87
  Commands::LocalOpenshift3Setup
93
88
  end
94
89
 
95
- command "test-openshift2" do
96
- require_relative "command/test_openshift2"
97
- Commands::TestOpenshift2
90
+ command "push-openshift3-release" do
91
+ require_relative "command/push_openshift3_release"
92
+ Commands::PushOpenshift3Release
98
93
  end
99
94
 
100
95
  command "test-openshift3" do
@@ -102,6 +97,11 @@ module Vagrant
102
97
  Commands::TestOpenshift3
103
98
  end
104
99
 
100
+ command "test-sti" do
101
+ require_relative "command/test_sti"
102
+ Commands::TestSti
103
+ end
104
+
105
105
  command "create-ami" do
106
106
  require_relative "command/create_ami"
107
107
  Commands::CreateAMI
@@ -127,11 +127,6 @@ module Vagrant
127
127
  Commands::CheckoutRepositories
128
128
  end
129
129
 
130
- command "install-rhc" do
131
- require_relative "command/install_rhc"
132
- Commands::InstallRhc
133
- end
134
-
135
130
  command "test-openshift3-image" do
136
131
  require_relative "command/test_openshift3_image"
137
132
  Commands::TestOpenshift3Image
@@ -39,43 +39,11 @@ module Vagrant
39
39
  #
40
40
  # No return value is expected.
41
41
  def provision
42
- #check if OpenShift has been installed
43
- #reapply puppet configuration so that IPs and ifcfg-* file is correct
44
- if @machine.communicate.test("test -d /etc/openshift")
45
- @machine.ui.info("Reapplying puppet script to update changed IP values")
46
- hostname = @machine.config.vm.hostname
47
- sudo(machine,"echo #{hostname} > /proc/sys/kernel/hostname")
48
- sudo(machine,"puppet apply --verbose #{Vagrant::Openshift::Constants.build_dir + 'configure_origin.pp'}", {timeout: 60*20})
49
- is_fedora = @machine.communicate.test("test -e /etc/fedora-release")
50
-
51
- sudo(machine,Constants.restart_services_cmd(is_fedora).join("\n"))
52
- if @machine.config.openshift.additional_services.size > 0
53
- cmd = ""
54
- @machine.config.openshift.additional_services.each do |service|
55
- cmd += "service #{service} restart;"
56
- end
57
- sudo(machine,cmd)
58
- end
59
-
60
- # TODO: Replace this temporary fix with a complete post-install routine
61
- sudo(machine,"oo-admin-ctl-cartridge -c import-node --activate --obsolete && RAILS_ENV=test oo-admin-ctl-cartridge -c import-node --activate --obsolete")
62
- else
63
- #TODO is_fedora is a temporary fix for the new environment
64
- is_fedora = @machine.communicate.test("test -e /etc/fedora-release")
65
- if is_fedora
66
- ssh_user = machine.ssh_info[:username]
67
- sync_dir = Vagrant::Openshift::Constants.sync_dir
68
- ## pause to stabilize environment to try to correct odd sudo error on aws
69
- sleep 2
70
- sudo(machine, "mkdir -p #{sync_dir} && chown -R #{ssh_user}:#{ssh_user} #{sync_dir}")
71
- end
72
- unless is_fedora || @machine.communicate.test("test -f #{Vagrant::Openshift::Constants.deps_marker}")
73
- @machine.ui.info("Preparing base environment")
74
- require_relative "command/build_openshift2_base"
75
- Vagrant::Openshift::Commands::BuildOpenshift2Base.new([], @machine.env).execute
76
- @machine.communicate.sudo("touch #{Vagrant::Openshift::Constants.deps_marker}")
77
- end
78
- end
42
+ ssh_user = machine.ssh_info[:username]
43
+ sync_dir = Vagrant::Openshift::Constants.sync_dir
44
+ ## pause to stabilize environment to try to correct odd sudo error on aws
45
+ sleep 2
46
+ sudo(machine, "mkdir -p #{sync_dir} && chown -R #{ssh_user}:#{ssh_user} #{sync_dir}")
79
47
  end
80
48
  end
81
49
  end
@@ -20,212 +20,7 @@ require 'yaml'
20
20
  require 'tsort'
21
21
  require_relative 'lib/constants'
22
22
  require_relative 'lib/options'
23
- require_relative 'lib/rpm'
24
- require_relative 'lib/test'
25
23
  $stdout.sync = true
26
24
  $stderr.sync = true
27
25
 
28
26
  VALID_IP_ADDR_RE = Regexp.new('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')
29
-
30
- task :install_deps do
31
- spec_files = RPM::get_packages(ignore_packages: OPTIONS[:ignore_packages], ignore_cache: true)
32
-
33
- all_build_dependencies = []
34
- all_inst_dependencies = []
35
- spec_files.each do |spec|
36
- all_build_dependencies += spec[:build_deps]
37
- all_inst_dependencies += spec[:deps]
38
- end
39
-
40
- all_packages = all_build_dependencies + all_inst_dependencies
41
-
42
- all_packages.map! do |name|
43
- m = name.match(/(ruby193-)?rubygem[(]([a-z\-_]*)[)]/)
44
- if m.nil?
45
- name.strip
46
- else
47
- scl_prefix = m[1].nil? ? "" : m[1]
48
- "#{scl_prefix}rubygem-#{m[2]}".strip
49
- end
50
- end
51
-
52
- all_packages.delete_if { |name| name.match(/openshift/)}
53
-
54
- RPM::install_rpms(all_packages)
55
- end
56
-
57
- task :build_all do
58
- FileUtils.rm_rf("/tmp/tito/*")
59
- spec_files = RPM::get_packages(remove_os_build_deps: true, ignore_packages: OPTIONS[:ignore_packages], ignore_cache: true)
60
- RPM::build_packages(spec_files)
61
- end
62
-
63
- task :clean_rpms do
64
- FileUtils.rm_rf("/tmp/tito/*")
65
- RPM::uninstall_openshift
66
- end
67
-
68
- task :install_puppet do
69
- Dir.chdir((Vagrant::Openshift::Constants.build_dir + "puppet-openshift_origin").to_s) do
70
- FileUtils.rm_rf "pkg"
71
- system("puppet module build .")
72
- pkg = Dir.glob((Vagrant::Openshift::Constants.build_dir + "puppet-openshift_origin/pkg/openshift-openshift_origin*.tar.gz").to_s).first
73
- system("puppet module uninstall openshift-openshift_origin")
74
- system("puppet module install #{pkg}")
75
- system("rm -rf #{Vagrant::Openshift::Constants.build_dir + "puppet-openshift_origin/pkg"}")
76
- end
77
- end
78
-
79
- task :update_packages do
80
- if (Vagrant::Openshift::Constants.build_dir + ".built_packages").exist?
81
- print "Updating packages\n"
82
- RPM::updated_packages
83
- else
84
- print "Building all packages\n"
85
- Rake::Task['build_all'].invoke
86
- print "Installing openshift puppet module\n"
87
- Rake::Task['install_puppet'].invoke
88
- print "Applying openshift puppet recipe\n"
89
- system("puppet apply --verbose #{Vagrant::Openshift::Constants.build_dir + 'configure_origin.pp'}")
90
- end
91
- Rake::Task['restart_services'].invoke
92
- end
93
-
94
- task :restart_services do
95
- is_fedora=File.exists?("/etc/fedora-release")
96
- system(Vagrant::Openshift::Constants.restart_services_cmd(is_fedora).join("\n"))
97
- cmd = ""
98
- OPTIONS[:additional_services].each do |service|
99
- cmd += "service #{service} restart;"
100
- end
101
- system(cmd)
102
-
103
- unless system("service openshift-tc status 2>/dev/null 1>/dev/null")
104
- system("service openshift-tc reload")
105
- end
106
-
107
- # TODO: Replace this temporary fix with a complete post-install routine
108
- `oo-admin-ctl-cartridge -c import-node --activate --obsolete && RAILS_ENV=test oo-admin-ctl-cartridge -c import-node --activate --obsolete`
109
- end
110
-
111
- task :checkout_tests do
112
- print "Updating remote tests..."
113
- system "rm -rf #{Vagrant::Openshift::Constants.build_dir}/openshift-test"
114
- git_archive_commands = ''
115
- Vagrant::Openshift::Constants.openshift2_repos.each do |repo_name, url|
116
- repo_dir = "#{Vagrant::Openshift::Constants.build_dir}/#{repo_name}-bare"
117
- git_archive_commands += "pushd #{repo_dir} > /dev/null; git archive --prefix openshift-test/ --format=tar 'HEAD' | (cd #{Vagrant::Openshift::Constants.build_dir} && tar --warning=no-timestamp -xf -); popd > /dev/null; "
118
- end
119
- git_archive_commands += "pushd #{Vagrant::Openshift::Constants.build_dir}/rhc-bare > /dev/null; git archive --prefix openshift-test/rhc/ --format=tar 'HEAD' | (cd #{Vagrant::Openshift::Constants.build_dir} && tar --warning=no-timestamp -xf -); popd > /dev/null; "
120
-
121
- system %{
122
- set -e;
123
- rm -rf #{Vagrant::Openshift::Constants.build_dir}/openshift-test
124
- #{git_archive_commands}
125
- mkdir -p /tmp/rhc/junit
126
- }
127
-
128
- system(%{
129
- rm -rf #{Vagrant::Openshift::Constants.build_dir}/openshift-test/tests;
130
- ln -s #{Vagrant::Openshift::Constants.build_dir}/openshift-test/controller/test/cucumber #{Vagrant::Openshift::Constants.build_dir}/openshift-test/tests
131
- })
132
- print "done\n"
133
- end
134
-
135
- task :create_test_users do
136
- system("mkdir -p /etc/openshift && touch /etc/openshift/htpasswd")
137
- ['test_user@test.com', 'user_with_multiple_gear_sizes@test.com', 'user_with_extra_storage@test.com', 'user_with_certificate_capabilities@test.com']. each do |user|
138
- unless system("/usr/bin/curl -f -k https://openshift.example.com/broker/rest/user -u #{user}:test 2>/dev/null 1>/dev/null")
139
-
140
- # Try to create the user record
141
- print "Creating test user: #{user}\n"
142
- user_created = false
143
- create_retries = 0
144
- while create_retries < 3 do
145
- user_created = system("/usr/bin/htpasswd -b /etc/openshift/htpasswd #{user} test")
146
- break if user_created
147
- create_retries = create_retries + 1
148
- print "Could not add user #{user} to htpasswd file on attempt #{create_retries}\n"
149
- sleep 2
150
- end
151
- if not user_created
152
- print "Unable to add user '#{user}' to /etc/openshift/htpasswd\n"
153
- exit 1
154
- end
155
-
156
- # Test the user record via the REST API
157
- rest_connected = false
158
- rest_retries = 0
159
- while rest_retries < 3 do
160
- rest_connected = system("/usr/bin/curl -f -k https://openshift.example.com/broker/rest/user -u #{user}:test 2>/dev/null 1>/dev/null")
161
- break if rest_connected
162
- rest_retries = rest_retries + 1
163
- print "Could not verify user #{user} via the REST API on attempt #{rest_retries}\n"
164
- sleep 10
165
- end
166
- if not rest_connected
167
- print "Unable to verify user #{user} via the REST API\n"
168
- exit 1
169
- end
170
- else
171
- print "#{user} already exists\n"
172
- end
173
- end
174
-
175
- # Create a known test user with medium-sized gears
176
- # This must be done before the deployment of application templates!
177
- exitcode = system("/usr/sbin/oo-admin-ctl-user -l user_with_multiple_gear_sizes@test.com --addgearsize medium")
178
- if(!exitcode)
179
- print "Unable to assign medium gear capability to user_with_multiple_gear_sizes@test.com"
180
- exit 1
181
- end
182
-
183
- # Create a test user with additional storage capabilities
184
- exitcode = system("/usr/sbin/oo-admin-ctl-user -l user_with_extra_storage@test.com --setmaxuntrackedstorage 5 --setmaxgears 10")
185
- if(!exitcode)
186
- print "Unable to assign additional storage to user_with_extra_storage@test.com"
187
- exit 1
188
- end
189
-
190
- # Create a test user with ssl certificates capabilities
191
- exitcode = system("/usr/sbin/oo-admin-ctl-user -l user_with_certificate_capabilities@test.com --allowprivatesslcertificates true")
192
- if(!exitcode)
193
- print "Unable to assign ssl certificates capabilities to user_with_certificate_capabilities@test.com"
194
- exit 1
195
- end
196
-
197
- unless system("test -e /root/.ssh/id_rsa")
198
- system("ssh-keygen -q -f /root/.ssh/id_rsa -P \"\" </dev/null")
199
- end
200
- end
201
-
202
- task :idle_all_gears do
203
- Test.new.idle_all_gears
204
- end
205
-
206
- task :run_tests do
207
- options = {}
208
- options[:fixme] = ENV["fixme"] == "true"
209
- if ENV["extended"] == "true"
210
- options[:gear_extended] = ENV["gear"] == "true"
211
- options[:node_extended] = ENV["node"] == "true"
212
- options[:cart_extended] = ENV["cart"] == "true"
213
- options[:broker_extended] = ENV["broker"] == "true"
214
- options[:rhc_extended] = ENV["rhc"] == "true"
215
- options[:console_extended] = ENV["console"] == "true"
216
- options[:node] = false
217
- options[:cart] = false
218
- options[:broker] = false
219
- options[:rhc] = false
220
- options[:console] = false
221
- else
222
- options[:gear] = ENV["gear"] == "true"
223
- options[:node] = ENV["node"] == "true"
224
- options[:cart] = ENV["cart"] == "true"
225
- options[:broker] = ENV["broker"] == "true"
226
- options[:rhc] = ENV["rhc"] == "true"
227
- options[:console] = ENV["console"] == "true"
228
- end
229
-
230
- Test.new.test(options)
231
- end