vagrant-openshift 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.asciidoc +50 -0
  3. data/lib/vagrant-openshift/action/build_origin_base_images.rb +1 -1
  4. data/lib/vagrant-openshift/action/build_origin_images.rb +60 -0
  5. data/lib/vagrant-openshift/action/build_origin_rpm_test.rb +51 -0
  6. data/lib/vagrant-openshift/action/checkout_repositories.rb +1 -1
  7. data/lib/vagrant-openshift/action/clean.rb +3 -2
  8. data/lib/vagrant-openshift/action/clone_upstream_repositories.rb +1 -1
  9. data/lib/vagrant-openshift/action/create_local_yum_repo.rb +54 -0
  10. data/lib/vagrant-openshift/action/download_artifacts_origin.rb +6 -5
  11. data/lib/vagrant-openshift/action/download_artifacts_origin_aggregated_logging.rb +67 -0
  12. data/lib/vagrant-openshift/action/generate_template.rb +0 -4
  13. data/lib/vagrant-openshift/action/install_origin_asset_dependencies.rb +3 -1
  14. data/lib/vagrant-openshift/action/install_origin_base_dependencies.rb +67 -6
  15. data/lib/vagrant-openshift/action/local_origin_checkout.rb +1 -1
  16. data/lib/vagrant-openshift/action/push_openshift_images.rb +2 -2
  17. data/lib/vagrant-openshift/action/run_origin_aggregated_logging_tests.rb +88 -0
  18. data/lib/vagrant-openshift/action/run_origin_tests.rb +28 -15
  19. data/lib/vagrant-openshift/action/sync_local_repository.rb +3 -2
  20. data/lib/vagrant-openshift/action/yum_update.rb +4 -0
  21. data/lib/vagrant-openshift/action.rb +59 -0
  22. data/lib/vagrant-openshift/command/build_origin_images.rb +58 -0
  23. data/lib/vagrant-openshift/command/build_origin_rpm_test.rb +50 -0
  24. data/lib/vagrant-openshift/command/checkout_repositories.rb +6 -1
  25. data/lib/vagrant-openshift/command/create_local_yum_repo.rb +56 -0
  26. data/lib/vagrant-openshift/command/download_artifacts_origin_aggregated_logging.rb +49 -0
  27. data/lib/vagrant-openshift/command/local_origin_setup.rb +5 -0
  28. data/lib/vagrant-openshift/command/repo_sync_origin_aggregated_logging.rb +71 -0
  29. data/lib/vagrant-openshift/command/test_origin.rb +14 -1
  30. data/lib/vagrant-openshift/command/test_origin_aggregated_logging.rb +67 -0
  31. data/lib/vagrant-openshift/command/test_origin_image.rb +6 -4
  32. data/lib/vagrant-openshift/constants.rb +19 -1
  33. data/lib/vagrant-openshift/plugin.rb +30 -0
  34. data/lib/vagrant-openshift/version.rb +1 -1
  35. metadata +13 -2
@@ -38,7 +38,7 @@ module Vagrant
38
38
  end
39
39
  Dir.chdir(go_path) do
40
40
  commands = "echo 'Waiting for the cloning process to finish'\n"
41
- Constants.openshift_repos.each do |repo, url|
41
+ Constants.repos_for_name(@options[:repo]).each do |repo, url|
42
42
  commands += repo_checkout_bash_command(repo, url)
43
43
  end
44
44
 
@@ -111,9 +111,9 @@ git init && git remote add -t master origin #{repo_url}
111
111
  git fetch && git checkout #{git_ref}
112
112
  git_ref=$(git rev-parse --short HEAD)
113
113
  echo "Building and testing #{image_name}-centos7:$git_ref ..."
114
- sudo env "PATH=$PATH" make test TARGET=centos7 VERSION=#{version} TAG_ON_SUCCESS=true
114
+ sudo env "PATH=$PATH" SKIP_SQUASH=1 make test TARGET=centos7 VERSION=#{version} TAG_ON_SUCCESS=true
115
115
  echo "Building and testing #{image_name}-rhel7:$git_ref ..."
116
- sudo env "PATH=$PATH" make test TARGET=rhel7 VERSION=#{version} TAG_ON_SUCCESS=true
116
+ sudo env "PATH=$PATH" SKIP_SQUASH=1 make test TARGET=rhel7 VERSION=#{version} TAG_ON_SUCCESS=true
117
117
  popd
118
118
  set +e
119
119
  }
@@ -0,0 +1,88 @@
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
+
17
+ module Vagrant
18
+ module Openshift
19
+ module Action
20
+ class RunOriginAggregatedLoggingTests
21
+ include CommandHelper
22
+
23
+ @@SSH_TIMEOUT = 4800
24
+
25
+ def initialize(app, env, options)
26
+ @app = app
27
+ @env = env
28
+ @options = options.clone
29
+ end
30
+
31
+ def run_tests(env, cmds, as_root=true)
32
+ tests = ''
33
+ cmds.each do |cmd|
34
+ tests += "
35
+ echo '***************************************************'
36
+ echo 'Running #{cmd}...'
37
+ time #{cmd}
38
+ echo 'Finished #{cmd}'
39
+ echo '***************************************************'
40
+ "
41
+ end
42
+ cmd = %{
43
+ set -e
44
+ pushd #{Constants.build_dir}/origin-aggregated-logging/hack/testing >/dev/null
45
+ export PATH=$GOPATH/bin:$PATH
46
+ #{tests}
47
+ popd >/dev/null
48
+ }
49
+ exit_code = 0
50
+ if as_root
51
+ _,_,exit_code = sudo(env[:machine], cmd, {:timeout => 60*60*4, :fail_on_error => false, :verbose => false})
52
+ else
53
+ _,_,exit_code = do_execute(env[:machine], cmd, {:timeout => 60*60*4, :fail_on_error => false, :verbose => false})
54
+ end
55
+ exit_code
56
+ end
57
+
58
+ #
59
+ # Build and run the make commands
60
+ # for testing all run make test
61
+ # for testing unit tests only run make build check
62
+ # for testing assets run hack/test-assets.sh
63
+ #
64
+ # All env vars will be added to the beginning of the command like VAR=1 make test
65
+ #
66
+ def call(env)
67
+ @options.delete :logs
68
+
69
+ cmd_env = []
70
+
71
+ if @options[:envs]
72
+ cmd_env += @options[:envs]
73
+ end
74
+
75
+ if @options[:image_registry]
76
+ cmd_env << "OPENSHIFT_TEST_IMAGE_REGISTRY=#{@options[:image_registry]}"
77
+ end
78
+
79
+ cmd_env << './logging.sh'
80
+ cmd = cmd_env.join(' ')
81
+ env[:test_exit_code] = run_tests(env, [cmd], @options[:root])
82
+
83
+ @app.call(env)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -67,30 +67,42 @@ popd >/dev/null
67
67
  @options.delete :logs
68
68
 
69
69
  cmd_env = []
70
+ cmd_env << 'TEST_ASSETS=true'
71
+ cmd_env << 'TEST_ASSETS_HEADLESS=true'
72
+ if @options[:skip_image_cleanup]
73
+ cmd_env << 'SKIP_IMAGE_CLEANUP=1'
74
+ end
75
+
70
76
  build_targets = ["make"]
71
77
  if @options[:parallel]
72
78
  build_targets << '-j'
73
79
  build_targets << '--output-sync=recurse'
74
80
  end
75
81
 
76
- if @options[:all]
77
- cmd_env << 'TEST_ASSETS=true'
78
- cmd_env << 'TEST_ASSETS_HEADLESS=true'
82
+ # call specific make targets
83
+ if @options[:target]
84
+ @options[:all] = nil
85
+ build_targets = build_targets << @options[:target]
86
+
87
+ # run bulk tests
88
+ elsif @options[:all]
79
89
  cmd_env << 'TESTFLAGS=\'"" -p=4\''
80
90
  build_targets << 'test'
81
- # we want to test the output of build-release, this flag tells the makefile to skip the build dependency
82
- # so the command comes out to <cmd_env settings> make test SKIP_BUILD=true
83
- build_targets << "SKIP_BUILD=true"
84
91
 
85
- if @options[:skip_image_cleanup]
86
- cmd_env << 'SKIP_IMAGE_CLEANUP=1'
87
- end
92
+ # run the check target only
88
93
  else
94
+
89
95
  build_targets << "check" if !@options[:skip_check]
90
96
  end
91
97
 
92
98
  if @options[:report_coverage]
93
- cmd_env << 'OUTPUT_COVERAGE=/tmp/origin/e2e/artifacts/coverage'
99
+ # TODO(skuznets): make this a boolean and pass it through --env instead, to allow
100
+ # openshift/origin/hack/test-go.sh to choose where it places this artifact
101
+ cmd_env << 'OUTPUT_COVERAGE=/tmp/openshift/test-go/artifacts'
102
+ end
103
+
104
+ if @options[:envs]
105
+ cmd_env += @options[:envs]
94
106
  end
95
107
 
96
108
  if @options[:image_registry]
@@ -98,19 +110,20 @@ popd >/dev/null
98
110
  end
99
111
 
100
112
  cmd = cmd_env.join(' ') + ' ' + build_targets.join(' ')
101
- env[:test_exit_code] = run_tests(env, [cmd], false)
113
+ env[:test_exit_code] = run_tests(env, [cmd], @options[:root])
102
114
 
103
115
  if env[:test_exit_code] == 0 && @options[:extended_test_packages].length > 0
104
116
  cmds = parse_extended(@options[:extended_test_packages])
105
- cmds = cmds.map{ |s| 'TEST_REPORT_DIR=/tmp/openshift-extended-tests/junit/extended ' + s }
106
- env[:test_exit_code] = run_tests(env, cmds, true)
117
+ # TODO(skuznets): make this a boolean and pass it through --env instead, to allow
118
+ # openshift/origin/test/extended/util/test.go to choose where it places this artifact
119
+ cmds = cmds.map{ |s| 'TEST_REPORT_DIR=/tmp/openshift/test-extended/junit ' + s }
120
+ env[:test_exit_code] = run_tests(env, cmds, @options[:root])
107
121
  end
108
122
 
109
-
110
123
  # any other tests that should not be run as sudo
111
124
  if env[:test_exit_code] == 0 && @options[:all]
112
125
  cmds = ['hack/test-assets.sh']
113
- env[:test_exit_code] = run_tests(env, cmds, false)
126
+ env[:test_exit_code] = run_tests(env, cmds, @options[:root])
114
127
  end
115
128
 
116
129
  @app.call(env)
@@ -20,15 +20,16 @@ module Vagrant
20
20
  class SyncLocalRepository
21
21
  include CommandHelper
22
22
 
23
- def initialize(app, env)
23
+ def initialize(app, env, options={})
24
24
  @app = app
25
25
  @env = env
26
+ @options = options
26
27
  end
27
28
 
28
29
  def call(env)
29
30
  env[:machine].env.ui.info("Synchronizing local sources")
30
31
 
31
- Constants.repos(env).each do |repo_name, url|
32
+ Constants.repos_for_name(@options[:repo]).each do |repo_name, url|
32
33
  local_repo = Pathname.new(File.expand_path(File.join(env[:machine].env.root_path, "..", repo_name)))
33
34
  unless local_repo.exist?
34
35
  local_repo = Pathname.new(File.expand_path(File.join(env[:machine].env.root_path, repo_name)))
@@ -44,6 +44,10 @@ obsoletes=1
44
44
  gpgcheck=0
45
45
  plugins=1
46
46
  installonly_limit=3
47
+ retries=20
48
+ timeout=120
49
+
50
+
47
51
 
48
52
  # This is the default, if you make this bigger yum won't see if the metadata
49
53
  # is newer on the remote and so you'll "gain" the bandwidth of not having to
@@ -27,6 +27,24 @@ module Vagrant
27
27
  end
28
28
  end
29
29
 
30
+ def self.build_origin_rpm_test(options)
31
+ Vagrant::Action::Builder.new.tap do |b|
32
+ b.use BuildOriginRpmTest
33
+ end
34
+ end
35
+
36
+ def self.build_origin_images(options)
37
+ Vagrant::Action::Builder.new.tap do |b|
38
+ b.use BuildOriginImages, options
39
+ end
40
+ end
41
+
42
+ def self.create_local_yum_repo(options)
43
+ Vagrant::Action::Builder.new.tap do |b|
44
+ b.use CreateLocalYumRepo, options
45
+ end
46
+ end
47
+
30
48
  def self.build_origin_base(options)
31
49
  Vagrant::Action::Builder.new.tap do |b|
32
50
  b.use CreateYumRepositories
@@ -119,6 +137,26 @@ module Vagrant
119
137
  end
120
138
  end
121
139
 
140
+ def self.repo_sync_origin_aggregated_logging(options)
141
+ Vagrant::Action::Builder.new.tap do |b|
142
+ b.use PrepareSshConfig
143
+ if options[:source]
144
+ if options[:clean]
145
+ b.use(Clean, options)
146
+ b.use(CloneUpstreamRepositories, options)
147
+ end
148
+ b.use(SyncLocalRepository, options)
149
+ b.use(CheckoutRepositories, options)
150
+ end
151
+ # no build support currently
152
+ # if options[:build]
153
+ # b.use(BuildOriginBaseImages, options) if options[:images]
154
+ # b.use(BuildOrigin, options)
155
+ # b.use RunSystemctl, {:action => "try-restart", :service => "openshift"}
156
+ # end
157
+ end
158
+ end
159
+
122
160
  def self.local_origin_checkout(options)
123
161
  Vagrant::Action::Builder.new.tap do |b|
124
162
  if not options[:no_build]
@@ -137,6 +175,16 @@ module Vagrant
137
175
  end
138
176
  end
139
177
 
178
+ def self.run_origin_aggregated_logging_tests(options)
179
+ Vagrant::Action::Builder.new.tap do |b|
180
+ b.use RunOriginAggregatedLoggingTests, options
181
+ if options[:download]
182
+ b.use DownloadArtifactsOriginAggregatedLogging
183
+ end
184
+ b.use TestExitCode
185
+ end
186
+ end
187
+
140
188
  def self.run_sti_tests(options)
141
189
  Vagrant::Action::Builder.new.tap do |b|
142
190
  b.use RunStiTests, options
@@ -159,6 +207,12 @@ module Vagrant
159
207
  end
160
208
  end
161
209
 
210
+ def self.download_origin_aggregated_logging_artifacts(options)
211
+ Vagrant::Action::Builder.new.tap do |b|
212
+ b.use DownloadArtifactsOriginAggregatedLogging
213
+ end
214
+ end
215
+
162
216
  def self.gen_template(options)
163
217
  Vagrant::Action::Builder.new.tap do |b|
164
218
  b.use GenerateTemplate, options
@@ -237,16 +291,21 @@ module Vagrant
237
291
  autoload :CreateBareRepoPlaceholders, action_root.join("create_bare_repo_placeholders")
238
292
  autoload :RunOriginTests, action_root.join("run_origin_tests")
239
293
  autoload :RunStiTests, action_root.join("run_sti_tests")
294
+ autoload :RunOriginAggregatedLoggingTests, action_root.join("run_origin_aggregated_logging_tests")
240
295
  autoload :GenerateTemplate, action_root.join("generate_template")
241
296
  autoload :CreateAMI, action_root.join("create_ami")
242
297
  autoload :ModifyInstance, action_root.join("modify_instance")
243
298
  autoload :ModifyAMI, action_root.join("modify_ami")
244
299
  autoload :DownloadArtifactsOrigin, action_root.join("download_artifacts_origin")
245
300
  autoload :DownloadArtifactsSti, action_root.join("download_artifacts_sti")
301
+ autoload :DownloadArtifactsOriginAggregatedLogging, action_root.join("download_artifacts_origin_aggregated_logging")
246
302
  autoload :TestExitCode, action_root.join("test_exit_code")
247
303
  autoload :CleanNetworkSetup, action_root.join("clean_network_setup")
248
304
  autoload :RunSystemctl, action_root.join("run_systemctl")
249
305
  autoload :AtomicHostUpgrade, action_root.join("atomic_host_upgrade")
306
+ autoload :BuildOriginRpmTest, action_root.join("build_origin_rpm_test")
307
+ autoload :CreateLocalYumRepo, action_root.join("create_local_yum_repo")
308
+ autoload :BuildOriginImages, action_root.join("build_origin_images")
250
309
  end
251
310
  end
252
311
  end
@@ -0,0 +1,58 @@
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 BuildOriginImages < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "Build origin Dockerfiles from local generated RPMs"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:clean] = false
31
+
32
+ opts = OptionParser.new do |o|
33
+ o.banner = "Usage: vagrant build-origin-images [vm-name]"
34
+ o.on("--images [list]", String, "List of images delimited by ','") do |i|
35
+ options[:images] = i
36
+ end
37
+ o.separator ""
38
+ end
39
+
40
+ # Parse the options
41
+ argv = parse_options(opts)
42
+ return if !argv
43
+
44
+ if options[:images].nil?
45
+ @env.ui.warn "You must specify list of images to build, delimited by ','"
46
+ exit
47
+ end
48
+
49
+ with_target_vms(argv, :reverse => true) do |machine|
50
+ actions = Vagrant::Openshift::Action.build_origin_images(options)
51
+ @env.action_runner.run actions, {:machine => machine}
52
+ 0
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,50 @@
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 BuildOriginRpmTest < Vagrant.plugin(2, :command)
22
+ include CommandHelper
23
+
24
+ def self.synopsis
25
+ "Build origin RPM with tito and test"
26
+ end
27
+
28
+ def execute
29
+ options = {}
30
+ options[:clean] = false
31
+
32
+ opts = OptionParser.new do |o|
33
+ o.banner = "Usage: vagrant build-origin-rpm-test [vm-name]"
34
+ o.separator ""
35
+ end
36
+
37
+ # Parse the options
38
+ argv = parse_options(opts)
39
+ return if !argv
40
+
41
+ with_target_vms(argv, :reverse => true) do |machine|
42
+ actions = Vagrant::Openshift::Action.build_origin_rpm_test(options)
43
+ @env.action_runner.run actions, {:machine => machine}
44
+ 0
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -27,6 +27,7 @@ module Vagrant
27
27
 
28
28
  def execute
29
29
  options = {}
30
+ options[:repo] = 'origin'
30
31
 
31
32
  opts = OptionParser.new do |o|
32
33
  o.banner = "Usage: vagrant checkout-repos"
@@ -36,6 +37,10 @@ module Vagrant
36
37
  options[:branch] = {"origin-server" => f}
37
38
  end
38
39
 
40
+ o.on("-r [repo-name]", "--repo [repo-name]", String, "Check out the specified repo. Default is 'origin'.") do |f|
41
+ options[:repo] = f
42
+ end
43
+
39
44
  #@options[:branch][repo_name]
40
45
  end
41
46
 
@@ -52,4 +57,4 @@ module Vagrant
52
57
  end
53
58
  end
54
59
  end
55
- end
60
+ end