bosh-gen 0.16.2 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.rspec +3 -0
- data/.travis.yml +16 -0
- data/ChangeLog.md +110 -89
- data/Gemfile +7 -1
- data/Guardfile +4 -8
- data/README.md +52 -22
- data/Rakefile +10 -0
- data/bosh-gen.gemspec +7 -5
- data/lib/bosh/gen/cli.rb +20 -28
- data/lib/bosh/gen/generators/job_generator.rb +9 -10
- data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/bin/%job_name%_ctl.tt +5 -5
- data/lib/bosh/gen/generators/new_release_generator.rb +63 -68
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/bin/%job_name%_ctl.tt +5 -5
- data/lib/bosh/gen/generators/new_release_generator/templates/jobs/%project_name_hyphenated%/templates/data/properties.sh.erb +6 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/infrastructure-aws-ec2.yml.tt +7 -5
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/infrastructure-warden.yml.tt +3 -4
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/jobs.yml.tt +3 -0
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/make_manifest.tt +18 -2
- data/lib/bosh/gen/generators/new_release_generator/templates/templates/stub.yml.tt +2 -1
- data/lib/bosh/gen/settings.rb +61 -0
- data/lib/bosh/gen/version.rb +1 -1
- data/spec/fixtures/deployment_manifests/2_jobs_1_ip_8196_disk_with_numeric.yml +64 -0
- data/spec/fixtures/releases/s3test-boshrelease/.gitignore +18 -0
- data/spec/fixtures/releases/s3test-boshrelease/README.md +51 -0
- data/spec/fixtures/releases/s3test-boshrelease/Rakefile +15 -0
- data/spec/fixtures/releases/s3test-boshrelease/config/blobs.yml +1 -0
- data/spec/fixtures/releases/s3test-boshrelease/config/final.yml +5 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/.gitkeep +0 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/monit +5 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/spec +13 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/bin/monit_debugger +13 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/bin/s3test_ctl +36 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/config/.gitkeep +0 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/config/s3test.conf.erb +5 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/data/properties.sh.erb +10 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/helpers/ctl_setup.sh +81 -0
- data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/helpers/ctl_utils.sh +156 -0
- data/spec/fixtures/releases/s3test-boshrelease/packages/.gitkeep +0 -0
- data/spec/fixtures/releases/s3test-boshrelease/src/.gitkeep +0 -0
- data/spec/fixtures/releases/s3test-boshrelease/templates/deployment.yml +35 -0
- data/spec/fixtures/releases/s3test-boshrelease/templates/infrastructure-aws-ec2.yml +40 -0
- data/spec/fixtures/releases/s3test-boshrelease/templates/infrastructure-warden.yml +107 -0
- data/spec/fixtures/releases/s3test-boshrelease/templates/jobs.yml +30 -0
- data/spec/fixtures/releases/s3test-boshrelease/templates/make_manifest +54 -0
- data/spec/fixtures/releases/s3test-boshrelease/templates/stub.yml +13 -0
- data/spec/generators/deployment_manifest_generator_spec.rb +19 -14
- data/spec/generators/{jobs/webapp_job_generator_spec.rb → job_generator_spec.rb} +8 -13
- data/spec/generators/new_release_generator_spec.rb +70 -0
- data/spec/models/bosh_config_spec.rb +3 -3
- data/spec/models/deployment_manifest_spec.rb +16 -6
- data/spec/models/release_detection_spec.rb +6 -6
- data/spec/spec_helper.rb +27 -7
- data/spec/support/fog.rb +3 -0
- data/spec/{generators → support}/generator_spec_helper.rb +47 -6
- metadata +105 -36
- data/spec/models/extract_spec.rb +0 -10
@@ -0,0 +1,30 @@
|
|
1
|
+
meta:
|
2
|
+
environment: ~
|
3
|
+
|
4
|
+
update:
|
5
|
+
canaries: 1
|
6
|
+
max_in_flight: 50
|
7
|
+
canary_watch_time: 1000-30000
|
8
|
+
update_watch_time: 1000-30000
|
9
|
+
serial: false
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
- name: s3test_leader_z1
|
13
|
+
template: s3test
|
14
|
+
instances: 0
|
15
|
+
resource_pool: small_z1
|
16
|
+
networks: (( merge ))
|
17
|
+
- name: s3test_z1
|
18
|
+
template: s3test
|
19
|
+
instances: 0
|
20
|
+
resource_pool: small_z1
|
21
|
+
networks: (( merge ))
|
22
|
+
update:
|
23
|
+
canaries: 10
|
24
|
+
properties:
|
25
|
+
s3test:
|
26
|
+
leader_address: (( merge ))
|
27
|
+
|
28
|
+
networks: (( merge ))
|
29
|
+
|
30
|
+
properties: {}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
infrastructure=$1
|
6
|
+
template_prefix="s3test"
|
7
|
+
|
8
|
+
if [ "$infrastructure" != "aws-ec2" ] && \
|
9
|
+
[ "$infrastructure" != "warden" ] ; then
|
10
|
+
echo "usage: ./make_manifest <aws-ec2|warden>"
|
11
|
+
exit 1
|
12
|
+
fi
|
13
|
+
|
14
|
+
shift
|
15
|
+
|
16
|
+
BOSH_STATUS=$(bosh status)
|
17
|
+
DIRECTOR_UUID=$(echo "$BOSH_STATUS" | grep UUID | awk '{print $2}')
|
18
|
+
DIRECTOR_CPI=$(echo "$BOSH_STATUS" | grep CPI | awk '{print $2}')
|
19
|
+
DIRECTOR_NAME=$(echo "$BOSH_STATUS" | grep Name | awk '{print $2}')
|
20
|
+
NAME=$template_prefix-$infrastructure
|
21
|
+
|
22
|
+
if [[ $DIRECTOR_NAME = "warden" ]]; then
|
23
|
+
if [[ $infrastructure != "warden" ]]; then
|
24
|
+
echo "Not targeting bosh-lite with warden CPI. Please use 'bosh target' before running this script."
|
25
|
+
exit 1
|
26
|
+
fi
|
27
|
+
fi
|
28
|
+
|
29
|
+
if [[ $infrastructure = "aws-ec2" ]]; then
|
30
|
+
if [[ $DIRECTOR_CPI != "aws" ]]; then
|
31
|
+
echo "Not targeting an AWS BOSH. Please use 'bosh target' before running this script."
|
32
|
+
exit 1
|
33
|
+
fi
|
34
|
+
fi
|
35
|
+
|
36
|
+
templates=$(dirname $0)
|
37
|
+
release=$templates/..
|
38
|
+
tmpdir=$release/tmp
|
39
|
+
|
40
|
+
mkdir -p $tmpdir
|
41
|
+
cp $templates/stub.yml $tmpdir/stub-with-uuid.yml
|
42
|
+
echo $DIRECTOR_NAME $DIRECTOR_CPI $DIRECTOR_UUID
|
43
|
+
perl -pi -e "s/PLACEHOLDER-DIRECTOR-UUID/$DIRECTOR_UUID/g" $tmpdir/stub-with-uuid.yml
|
44
|
+
perl -pi -e "s/NAME/$NAME/g" $tmpdir/stub-with-uuid.yml
|
45
|
+
|
46
|
+
spiff merge \
|
47
|
+
$templates/deployment.yml \
|
48
|
+
$templates/jobs.yml \
|
49
|
+
$templates/infrastructure-${infrastructure}.yml \
|
50
|
+
$tmpdir/stub-with-uuid.yml \
|
51
|
+
$* > $tmpdir/$NAME-manifest.yml
|
52
|
+
|
53
|
+
bosh deployment $tmpdir/$NAME-manifest.yml
|
54
|
+
bosh status
|
@@ -1,28 +1,20 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "generators/
|
2
|
+
require "bosh/gen/generators/deployment_manifest_generator"
|
3
3
|
|
4
4
|
# in a tmp folder:
|
5
5
|
# * run generator
|
6
6
|
# * deployment manifest created
|
7
7
|
|
8
8
|
# generates dpeloyment manifest for a target release
|
9
|
-
|
10
|
-
include GeneratorSpecHelper
|
9
|
+
describe Bosh::Gen::Generators::DeploymentManifestGenerator do
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
def setup
|
15
|
-
setup_universe
|
11
|
+
xit "creates deployment manifest with properties" do
|
16
12
|
setup_project_release("bosh-sample-release")
|
17
|
-
end
|
18
|
-
|
19
|
-
pending "creates deployment manifest with properties" do
|
20
13
|
release_folder = File.expand_path("../../fixtures/releases/bosh-sample-release", __FILE__)
|
21
14
|
in_home_folder do
|
22
15
|
generate_manifest("wordpress", release_folder)
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
expect(File.exist?("wordpress.yml")).to eq(true)
|
17
|
+
|
26
18
|
manifest = YAML.load_file("wordpress.yml")
|
27
19
|
properties = manifest["properties"]
|
28
20
|
properties.wont_be_nil "manifest properties must be set"
|
@@ -30,4 +22,17 @@ class DeploymentManifestGeneratorSpec < MiniTest::Spec
|
|
30
22
|
properties["mysql"]["password"].must_equal 'mysqlpassword'
|
31
23
|
end
|
32
24
|
end
|
33
|
-
|
25
|
+
|
26
|
+
it "checks for numerics in filenames/properties" do
|
27
|
+
release_folder = File.expand_path("../../tmp", __FILE__)
|
28
|
+
setup_project_release("s3test-boshrelease")
|
29
|
+
expect(File.exist?(File.join(@active_project_folder, "jobs/s3test/spec"))).to eq true
|
30
|
+
|
31
|
+
dev = YAML.load_file(File.join(@active_project_folder, "config/dev.yml"))
|
32
|
+
expect(dev).not_to be_nil
|
33
|
+
expect(dev["dev_name"]).to eq "s3test"
|
34
|
+
|
35
|
+
deployment = YAML.load_file(File.join(@active_project_folder, "templates/deployment.yml"))
|
36
|
+
expect(deployment["compilation"]["network"]).to eq("s3test1")
|
37
|
+
end
|
38
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
require "generators/
|
2
|
+
require "bosh/gen/generators/job_generator"
|
3
3
|
|
4
4
|
# in a tmp folder:
|
5
5
|
# * run generator
|
@@ -8,21 +8,16 @@ require "generators/generator_spec_helper"
|
|
8
8
|
# * it shouldn't fail
|
9
9
|
|
10
10
|
# generates job for a webapp application package
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def self.pending(name, &block); end
|
15
|
-
|
16
|
-
def setup
|
17
|
-
setup_universe
|
11
|
+
describe Bosh::Gen::Generators::JobGenerator do
|
12
|
+
before do
|
18
13
|
setup_project_release("bosh-sample-release")
|
19
14
|
end
|
20
15
|
|
21
16
|
it "creates common job files" do
|
22
17
|
in_project_folder do
|
23
18
|
generate_job("mywebapp")
|
24
|
-
File.exist?("jobs/mywebapp/monit").
|
25
|
-
File.exist?("jobs/mywebapp/spec").
|
19
|
+
expect(File.exist?("jobs/mywebapp/monit")).to eq(true)
|
20
|
+
expect(File.exist?("jobs/mywebapp/spec")).to eq(true)
|
26
21
|
job_template_exists "mywebapp", "bin/mywebapp_ctl", "bin/mywebapp_ctl"
|
27
22
|
job_template_exists "mywebapp", "bin/monit_debugger", "bin/monit_debugger"
|
28
23
|
job_template_exists "mywebapp", "data/properties.sh.erb", "data/properties.sh"
|
@@ -34,10 +29,10 @@ class WebappGeneratorSpec < MiniTest::Spec
|
|
34
29
|
pending "creates job files with rails & nginx templates" do
|
35
30
|
in_project_folder do
|
36
31
|
generate_job("mywebapp", "--purpose", "nginx_rack", '-d', 'nginx', 'ruby', 'myapp')
|
37
|
-
File.exist?("jobs/mywebapp/monit").
|
38
|
-
File.exist?("jobs/mywebapp/spec").
|
32
|
+
expect(File.exist?("jobs/mywebapp/monit")).to eq(true)
|
33
|
+
expect(File.exist?("jobs/mywebapp/spec")).to eq(true)
|
39
34
|
|
40
|
-
job_spec("mywebapp")["packages"].
|
35
|
+
expect(job_spec("mywebapp")["packages"]).to eq(%w[nginx ruby myapp])
|
41
36
|
|
42
37
|
job_template_exists "mywebapp", "bin/mywebapp_ctl", "bin/mywebapp_ctl"
|
43
38
|
job_template_exists "mywebapp", "bin/monit_debugger", "bin/monit_debugger"
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "bosh/gen/generators/new_release_generator"
|
3
|
+
|
4
|
+
describe Bosh::Gen::Generators::NewReleaseGenerator do
|
5
|
+
include Bosh::Gen::Settings
|
6
|
+
|
7
|
+
it "generates with s3 blobstore" do
|
8
|
+
in_home_folder do
|
9
|
+
self.settings_dir = "redis-boshrelease/config"
|
10
|
+
setting "provider.name", "aws"
|
11
|
+
setting "provider.region", "us-west-2"
|
12
|
+
setting "provider.credentials.aws_access_key_id", "ACCESS"
|
13
|
+
setting "provider.credentials.aws_secret_access_key", "SECRET"
|
14
|
+
|
15
|
+
generate_new_release 'redis'
|
16
|
+
expect(File.directory?("jobs")).to eq(true)
|
17
|
+
|
18
|
+
config = YAML.load_file("config/final.yml")
|
19
|
+
expect(config).to_not be_nil
|
20
|
+
expect(config["blobstore"]).to_not be_nil
|
21
|
+
expect(config["blobstore"]["options"]).to_not be_nil
|
22
|
+
expect(config["blobstore"]["provider"]).to eq("s3")
|
23
|
+
expect(config["blobstore"]["options"].keys).to eq(["bucket_name"])
|
24
|
+
expect(config["blobstore"]["options"]["bucket_name"]).to eq("redis-boshrelease")
|
25
|
+
|
26
|
+
config = YAML.load_file("config/private.yml")
|
27
|
+
expect(config).to_not be_nil
|
28
|
+
expect(config["blobstore"]).to_not be_nil
|
29
|
+
expect(config["blobstore"]["s3"]).to_not be_nil
|
30
|
+
expect(config["blobstore"]["s3"]["access_key_id"]).to eq("ACCESS")
|
31
|
+
expect(config["blobstore"]["s3"]["secret_access_key"]).to eq("SECRET")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# TODO: Fog::Errors::MockNotImplemented: Contributions welcome!
|
36
|
+
xit "generates with swift blobstore" do
|
37
|
+
in_home_folder do
|
38
|
+
setting "provider.name", "openstack"
|
39
|
+
setting "provider.credentials.openstack_auth_url", "http://10.0.0.2:5000/v2.0/tokens"
|
40
|
+
setting "provider.credentials.openstack_username", "USER"
|
41
|
+
setting "provider.credentials.openstack_api_key", "PASSWORD"
|
42
|
+
setting "provider.credentials.openstack_tenant", "TENANT"
|
43
|
+
setting "provider.credentials.openstack_region", "REGION"
|
44
|
+
|
45
|
+
# TODO: get rid of this prompt from Cyoi::Provider
|
46
|
+
setting "provider.options.boot_from_volume", false
|
47
|
+
|
48
|
+
generate_new_release 'redis'
|
49
|
+
expect(File.directory?("jobs")).to eq(true)
|
50
|
+
|
51
|
+
config = YAML.load_file("config/final.yml")
|
52
|
+
expect(config).to_not be_nil
|
53
|
+
expect(config["blobstore"]).to_not be_nil
|
54
|
+
expect(config["blobstore"]["options"]).to_not be_nil
|
55
|
+
expect(config["blobstore"]["provider"]).to eq("swift")
|
56
|
+
expect(config["blobstore"]["options"].keys).to eq(["container_name", "swift_provider"])
|
57
|
+
expect(config["blobstore"]["options"]["container_name"]).to eq("redis-boshrelease")
|
58
|
+
|
59
|
+
config = YAML.load_file("config/private.yml")
|
60
|
+
expect(config).to_not be_nil
|
61
|
+
expect(config["blobstore"]).to_not be_nil
|
62
|
+
expect(config["blobstore"]["swift"]["openstack"]).to_not be_nil
|
63
|
+
expect(config["blobstore"]["swift"]["openstack"]["openstack_auth_url"]).to eq("http://10.0.0.2:5000/v2.0/tokens")
|
64
|
+
expect(config["blobstore"]["swift"]["openstack"].keys).to eq(["openstack_auth_url", "openstack_username", "openstack_api_key", "openstack_tenant", "openstack_region"])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# generate_new_release 'redis'
|
69
|
+
# generate_new_release 'redis-boshrelease'
|
70
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "bosh/gen/models"
|
3
3
|
|
4
|
-
|
4
|
+
describe Bosh::Gen::Models::BoshConfig do
|
5
5
|
it "knows UUID of current target bosh" do
|
6
6
|
fake_config = File.expand_path( \
|
7
7
|
"../../fixtures/bosh_config/multiple_boshes.yml", __FILE__)
|
8
8
|
config = Bosh::Gen::Models::BoshConfig.new(fake_config)
|
9
|
-
config.target_uuid.
|
9
|
+
expect(config.target_uuid).to eq "f734ed1f-6892-4d96-9123-018c830a8543"
|
10
10
|
end
|
11
|
-
end
|
11
|
+
end
|
@@ -1,29 +1,39 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "bosh/gen/models"
|
3
3
|
|
4
|
-
|
4
|
+
describe Bosh::Gen::Models::DeploymentManifest do
|
5
5
|
it "creates manifest document with 2 jobs, no disk" do
|
6
|
-
manifest = Bosh::Gen::Models::DeploymentManifest.new("myproj", "UUID",
|
6
|
+
manifest = Bosh::Gen::Models::DeploymentManifest.new("myproj", "UUID",
|
7
7
|
{"name" => "myrelease", "version" => 2},
|
8
8
|
{"instance_type" => "m1.small", "static_ips" => ['1.2.3.4', '6.7.8.9']}, {})
|
9
9
|
manifest.jobs = [
|
10
10
|
{ "name" => "job-with-ips"},
|
11
11
|
{ "name" => "misc"}
|
12
12
|
]
|
13
|
-
manifest.to_yaml.
|
13
|
+
expect(manifest.to_yaml).to eq fixture_manifest("2_jobs_2_ips_no_disk")
|
14
14
|
end
|
15
15
|
|
16
16
|
it "creates manifest document with 2 jobs, with disk" do
|
17
|
-
manifest = Bosh::Gen::Models::DeploymentManifest.new("myproj", "UUID",
|
17
|
+
manifest = Bosh::Gen::Models::DeploymentManifest.new("myproj", "UUID",
|
18
18
|
{"name" => "myrelease", "version" => 2},
|
19
19
|
{"instance_type" => "m1.small", "persistent_disk" => "8196", "static_ips" => ['1.2.3.4']}, {})
|
20
20
|
manifest.jobs = [
|
21
21
|
{ "name" => "job-with-ips"},
|
22
22
|
{ "name" => "misc"}
|
23
23
|
]
|
24
|
-
manifest.to_yaml.
|
24
|
+
expect(manifest.to_yaml).to eq fixture_manifest("2_jobs_1_ip_8196_disk")
|
25
25
|
end
|
26
|
-
|
26
|
+
it "creates manifest document with 2 jobs, with disk, numeric in manifest name" do
|
27
|
+
manifest = Bosh::Gen::Models::DeploymentManifest.new("s3test", "UUID",
|
28
|
+
{"name" => "myrelease", "version" => 2},
|
29
|
+
{"instance_type" => "m1.small", "persistent_disk" => "8196", "static_ips" => ['4.3.2.1']}, {})
|
30
|
+
manifest.jobs = [
|
31
|
+
{ "name" => "job-with-ips"},
|
32
|
+
{ "name" => "misc"}
|
33
|
+
]
|
34
|
+
expect(manifest.to_yaml).to eq fixture_manifest("2_jobs_1_ip_8196_disk_with_numeric")
|
35
|
+
end
|
36
|
+
|
27
37
|
def fixture_manifest(name)
|
28
38
|
File.read(File.expand_path("../../fixtures/deployment_manifests/#{name}.yml", __FILE__))
|
29
39
|
end
|
@@ -1,23 +1,23 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "bosh/gen/models"
|
3
3
|
|
4
|
-
|
4
|
+
describe Bosh::Gen::Models::ReleaseDetection do
|
5
5
|
it "detects latest dev release version" do
|
6
6
|
detector = Bosh::Gen::Models::ReleaseDetection.new(fixture_release_path('some_dev_releases'))
|
7
7
|
latest_dev_release_version = detector.latest_dev_release_version
|
8
|
-
latest_dev_release_version.
|
8
|
+
expect(latest_dev_release_version).to eq 10
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "creates release properties for deployment manifest" do
|
12
12
|
detector = Bosh::Gen::Models::ReleaseDetection.new(fixture_release_path('some_dev_releases'))
|
13
|
-
detector.latest_dev_release_properties.
|
13
|
+
expect(detector.latest_dev_release_properties).to eq({
|
14
14
|
"name" => "myrelease",
|
15
15
|
"version" => 10
|
16
16
|
})
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
it "returns list of jobs" do
|
20
20
|
detector = Bosh::Gen::Models::ReleaseDetection.new(fixture_release_path('some_dev_releases'))
|
21
|
-
detector.latest_dev_release_job_names.
|
21
|
+
expect(detector.latest_dev_release_job_names).to eq %w[redis]
|
22
22
|
end
|
23
23
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,30 @@
|
|
1
|
-
|
2
|
-
require "minitest-colorize"
|
1
|
+
# Copyright (c) 2012-2014 Stark & Wayne, LLC
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
4
|
+
|
5
|
+
require "rubygems"
|
6
|
+
require "bundler"
|
7
|
+
Bundler.setup(:default, :test)
|
8
|
+
|
9
|
+
$:.unshift(File.expand_path("../../lib", __FILE__))
|
10
|
+
|
11
|
+
require "rspec/core"
|
12
|
+
|
13
|
+
require "bosh/gen/settings"
|
14
|
+
|
15
|
+
# load all files in spec/support/* (but not lower down)
|
16
|
+
Dir[File.dirname(__FILE__) + '/support/*'].each do |path|
|
17
|
+
require path unless File.directory?(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def fixture_release_path(name)
|
21
|
+
File.expand_path("../fixtures/releases/#{name}/", __FILE__)
|
8
22
|
end
|
9
23
|
|
10
|
-
|
24
|
+
RSpec.configure do |c|
|
25
|
+
c.before do
|
26
|
+
extend GeneratorSpecHelper
|
27
|
+
setup_universe
|
28
|
+
end
|
29
|
+
c.color = true
|
30
|
+
end
|
data/spec/support/fog.rb
ADDED
@@ -9,7 +9,10 @@ module GeneratorSpecHelper
|
|
9
9
|
FileUtils.rm_rf @tmp_root
|
10
10
|
FileUtils.mkdir_p @home_path
|
11
11
|
ENV['HOME'] = @home_path
|
12
|
-
|
12
|
+
if File.exists?(@@local_developer_bosh_config)
|
13
|
+
FileUtils.cp_r(@@local_developer_bosh_config, @home_path)
|
14
|
+
end
|
15
|
+
setup_git
|
13
16
|
end
|
14
17
|
|
15
18
|
def setup_project_release(name)
|
@@ -18,6 +21,25 @@ module GeneratorSpecHelper
|
|
18
21
|
@active_project_folder = File.join(@tmp_root, name)
|
19
22
|
end
|
20
23
|
|
24
|
+
def setup_git
|
25
|
+
in_home_folder do
|
26
|
+
git config: "--global user.name 'Dr Nic Williams'"
|
27
|
+
git config: "--global user.email 'drnic@starkandwayne.com'"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# generate_new_release 'redis'
|
32
|
+
# generate_new_release 'redis-boshrelease'
|
33
|
+
# generate_new_release 'redis', '--s3'
|
34
|
+
# generate_new_release 'redis', '--swift'
|
35
|
+
def generate_new_release(*args)
|
36
|
+
stdout, stderr = capture_stdios do
|
37
|
+
Bosh::Gen::Command.start(["new", *args])
|
38
|
+
end
|
39
|
+
@stdout = File.expand_path(File.join(@tmp_root, "generate_release.out"))
|
40
|
+
File.open(@stdout, "w") {|f| f << stdout; f << stderr}
|
41
|
+
end
|
42
|
+
|
21
43
|
# Runs 'bosh-gen job NAME ...'
|
22
44
|
#
|
23
45
|
# generate_job 'JOBNAME'
|
@@ -49,9 +71,9 @@ module GeneratorSpecHelper
|
|
49
71
|
options = args.pop
|
50
72
|
end
|
51
73
|
path = File.join(["jobs"] + args) # jobs/JOBNAME/monit
|
52
|
-
File.exist?(path).
|
74
|
+
expect(File.exist?(path)).to eq(true)
|
53
75
|
if options && options[:executable]
|
54
|
-
File.executable?(path).
|
76
|
+
expect(File.executable?(path)).to eq(true)
|
55
77
|
end
|
56
78
|
end
|
57
79
|
|
@@ -62,10 +84,10 @@ module GeneratorSpecHelper
|
|
62
84
|
# mywebapp_ctl.erb: bin/mywebapp_ctl
|
63
85
|
def job_template_exists(job, template_name, spec_path)
|
64
86
|
path = File.join("jobs", job, "templates", template_name)
|
65
|
-
File.exist?(path).
|
87
|
+
expect(File.exist?(path)).to eq(true)
|
66
88
|
spec_templates = job_spec(job)["templates"]
|
67
|
-
spec_templates[template_name].
|
68
|
-
spec_templates[template_name].
|
89
|
+
expect(spec_templates[template_name]).to_not be_nil
|
90
|
+
expect(spec_templates[template_name]).to eq(spec_path)
|
69
91
|
end
|
70
92
|
|
71
93
|
def job_spec(job)
|
@@ -111,4 +133,23 @@ module GeneratorSpecHelper
|
|
111
133
|
def strip_color_codes(text)
|
112
134
|
text.gsub(/\e\[\d+m/, '')
|
113
135
|
end
|
136
|
+
|
137
|
+
# Run a command in git.
|
138
|
+
#
|
139
|
+
# ==== Examples
|
140
|
+
#
|
141
|
+
# git :init
|
142
|
+
# git :add => "this.file that.rb"
|
143
|
+
# git :add => "onefile.rb", :rm => "badfile.cxx"
|
144
|
+
#
|
145
|
+
def git(commands={})
|
146
|
+
if commands.is_a?(Symbol)
|
147
|
+
`git #{commands}`
|
148
|
+
else
|
149
|
+
commands.each do |cmd, options|
|
150
|
+
`git #{cmd} #{options}`
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
114
155
|
end
|