Skip to content

Commit e66ec63

Browse files
committed
Spec: update integration spec task and update docs
1 parent e969131 commit e66ec63

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

ci/tasks/test-integration.yml

-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ params:
2424
SPEC_PATH: ~
2525
SHA2_MODE: ~
2626
DEFAULT_UPDATE_VM_STRATEGY: "delete-create"
27-
NUM_PROCESSES:
2827
GOOS: linux

docs/running_tests.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,12 @@ Integration tests describe communication between BOSH components focusing on the
5353
bosh/src$ bundle exec rake spec:integration
5454
```
5555

56-
In order to run the integration tests in parallel:
56+
Individual specs can be run by setting `SPEC_PATH` to a comma separated list of spec paths relative to `bosh/src/` (ex: `spec/integration/deploy/basic_spec.rb,spec/integration/cli_cck/cloud_config_update_spec.rb`). By default, integration specs are executed in parallel via `parallel_rspec`, if a line number is specified (ex: `some_spec.rb:123`) then `rspec` is used. More information about the integration test set up can be found in the [workstation setup docs](workstation_setup.md).
5757

58-
```
59-
export NUM_PROCESSES=<n>
60-
```
61-
62-
You can run individual tests by invoking `rspec` directly after setting up the sandbox with `rake spec:integration:install_dependencies` and `rake spec:integration:download_bosh_agent`. More information about the integration test set up can be found in the [workstation setup docs](workstation_setup.md).
58+
NOTE: as of 2025-01 the team has not invested in ensuring that local execution is possible, one-off integration spec execution is done via Concourse using the `fly:integration` task. This task also accepts `SPEC_PATH`, as well as `DB` environment variables. Concourse execution requires privileges on that Concourse instance, and a functioning bosh CI pipeline (see: `ci/pipeline.yml`)
6359

6460
```
65-
bosh/src$ bundle exec rspec spec/integration/cli_env_spec.rb
61+
bosh/src$ bundle exec rake fly:integration
6662
```
6763

6864
Run tests against a specific database by setting the `DB` environment variable.

src/tasks/spec.rake

+18-25
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,29 @@
11
namespace :spec do
2-
namespace :integration do
2+
desc 'Run all integration tests against a local sandbox'
3+
task :integration do
34
$LOAD_PATH << File.join(BOSH_SRC_ROOT, 'spec')
45
require 'integration_support/sandbox'
6+
IntegrationSupport::Sandbox.setup
57

6-
def run_integration_specs(tags: nil)
7-
IntegrationSupport::Sandbox.setup
8+
rspec_opts = ['--format documentation']
9+
rspec_opts += ENV.fetch('RSPEC_TAGS', '').split(',').map { |t| "--tag #{t}" }
810

9-
proxy_env = 'https_proxy= http_proxy='
11+
paths = ENV.fetch('SPEC_PATH', 'spec').split(',').join(' ')
1012

11-
rspec_opts += "--tag #{tags}" if tags
12-
rspec_opts = "SPEC_OPTS='--format documentation #{rspec_opts}'"
13+
spec_runner_command =
14+
if paths =~ /:\d+/ # line number was specified; run with `rspec`
15+
"bundle exec rspec #{rspec_opts.join(' ')} #{paths}"
1316

14-
parallel_options = '--multiply-processes 0.5'
15-
unless (num_processes = ENV.fetch('NUM_PROCESSES', '')).empty?
16-
parallel_options += " -n #{num_processes}"
17+
else
18+
# no line number specified; run with `parallel_rspec`
19+
"SPEC_OPTS='#{rspec_opts.join(' ')}' bundle exec parallel_rspec --multiply-processes 0.5"
1720
end
1821

19-
paths = ENV.fetch('SPEC_PATH', ['spec']).split(',').join(' ')
20-
21-
command =
22-
"#{proxy_env} #{rspec_opts} bundle exec parallel_rspec #{parallel_options} #{paths}"
23-
24-
puts command
25-
raise unless system(command)
26-
ensure
27-
IntegrationSupport::Sandbox.teardown
28-
end
29-
end
22+
proxy_env = 'https_proxy= http_proxy='
3023

31-
desc 'Run all integration tests against a local sandbox'
32-
task :integration do
33-
run_integration_specs
24+
sh("#{proxy_env} #{spec_runner_command} #{paths}")
25+
ensure
26+
IntegrationSupport::Sandbox.teardown
3427
end
3528

3629
desc 'Run template test unit tests (i.e. Bosh::Template::Test)'
@@ -55,13 +48,13 @@ namespace :spec do
5548
desc 'Run all release unit tests (ERB templates)'
5649
task :release do
5750
puts 'Run unit tests for the release (ERB templates)'
58-
sh("cd #{File.expand_path('..')} && rspec")
51+
sh("cd #{BOSH_REPO_ROOT} && rspec")
5952
end
6053

6154
namespace :release do
6255
task :parallel do
6356
puts 'Run unit tests for the release (ERB templates)'
64-
sh("cd #{File.expand_path('..')} && parallel_rspec spec")
57+
sh("cd #{BOSH_REPO_ROOT} && parallel_rspec spec")
6558
end
6659
end
6760

0 commit comments

Comments
 (0)