bosh-gen 0.24.0 → 0.90.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -362
  3. data/bosh-gen.gemspec +2 -1
  4. data/lib/bosh/gen/cli.rb +0 -8
  5. data/lib/bosh/gen/generators/errand_generator/templates/jobs/%job_name%/templates/bin/run.tt +2 -1
  6. data/lib/bosh/gen/generators/job_generator.rb +0 -5
  7. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/monit.tt +2 -2
  8. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/spec.tt +24 -0
  9. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/bin/ctl.tt +1 -1
  10. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/helpers/ctl_setup.sh +0 -26
  11. data/lib/bosh/gen/generators/new_release_generator.rb +7 -8
  12. data/lib/bosh/gen/generators/new_release_generator/templates/README.md.tt +13 -63
  13. data/lib/bosh/gen/generators/new_release_generator/templates/jobs/{just_install_packages → %project_name%}/monit.tt +0 -0
  14. data/lib/bosh/gen/generators/new_release_generator/templates/jobs/{just_install_packages → %project_name%}/spec.tt +1 -1
  15. data/lib/bosh/gen/generators/new_release_generator/templates/jobs/{just_install_packages → %project_name%}/templates/ignoreme +0 -0
  16. data/lib/bosh/gen/generators/new_release_generator/templates/manifests/%project_name%.yml.tt +38 -0
  17. data/lib/bosh/gen/generators/new_release_generator/templates/manifests/operators/dev.yml.tt +6 -0
  18. data/lib/bosh/gen/version.rb +1 -1
  19. metadata +28 -191
  20. data/.travis.yml +0 -13
  21. data/lib/bosh/cli/commands/share_release.rb +0 -80
  22. data/lib/bosh/gen/generators/bosh_cli_plugin_generator.rb +0 -33
  23. data/lib/bosh/gen/generators/bosh_cli_plugin_generator/templates/lib/bosh/cli/commands/%underscore_plugin_name%.rb.tt +0 -9
  24. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/monit.tt +0 -13
  25. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/%job_name%_rack_ctl.tt +0 -59
  26. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_db_utils.sh.erb +0 -54
  27. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_nginx.sh.erb +0 -17
  28. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_redis_utils.sh.erb +0 -18
  29. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_setup.sh.erb +0 -48
  30. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_start.sh.erb +0 -57
  31. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/ctl_utils.sh +0 -147
  32. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/monit_debugger +0 -13
  33. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/nginx_ctl.tt +0 -40
  34. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/bin/rails_ctl_setup.sh.erb +0 -39
  35. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/database.yml.erb +0 -17
  36. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/mime.types +0 -73
  37. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/nginx.conf.erb +0 -150
  38. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/nginx_proxy.conf +0 -11
  39. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_nginx_rack/templates/config/redis.yml.erb +0 -6
  40. data/lib/bosh/gen/generators/job_generator/templates/jobs/%job_name%_simple/templates/data/properties.sh.erb +0 -10
  41. data/lib/bosh/gen/generators/new_release_generator/templates/templates/deployment.yml.tt +0 -31
  42. data/lib/bosh/gen/generators/new_release_generator/templates/templates/infrastructure-aws-ec2.yml.tt +0 -33
  43. data/lib/bosh/gen/generators/new_release_generator/templates/templates/infrastructure-warden.yml.tt +0 -37
  44. data/lib/bosh/gen/generators/new_release_generator/templates/templates/jobs.yml.tt +0 -21
  45. data/lib/bosh/gen/generators/new_release_generator/templates/templates/make_manifest.tt +0 -83
  46. data/lib/bosh/gen/generators/new_release_generator/templates/templates/stub.yml.tt +0 -14
  47. data/lib/bosh/gen/models.rb +0 -9
  48. data/lib/bosh/gen/models/bosh_config.rb +0 -15
  49. data/lib/bosh/gen/models/deployment_manifest.rb +0 -107
  50. data/lib/bosh/gen/models/release_detection.rb +0 -35
  51. data/lib/bosh/gen/utils/file_with_progress_bar.rb +0 -62
  52. data/spec/fixtures/bosh_config/multiple_boshes.yml +0 -34
  53. data/spec/fixtures/deployment_manifests/2_jobs_1_ip_8196_disk.yml +0 -67
  54. data/spec/fixtures/deployment_manifests/2_jobs_1_ip_8196_disk_with_numeric.yml +0 -67
  55. data/spec/fixtures/deployment_manifests/2_jobs_2_ips_no_disk.yml +0 -67
  56. data/spec/fixtures/releases/bosh-sample-release/.gitignore +0 -9
  57. data/spec/fixtures/releases/bosh-sample-release/LICENSE +0 -8094
  58. data/spec/fixtures/releases/bosh-sample-release/NOTICE +0 -12
  59. data/spec/fixtures/releases/bosh-sample-release/README +0 -53
  60. data/spec/fixtures/releases/bosh-sample-release/config/final.yml +0 -9
  61. data/spec/fixtures/releases/bosh-sample-release/jobs/mysql/monit +0 -5
  62. data/spec/fixtures/releases/bosh-sample-release/jobs/mysql/spec +0 -17
  63. data/spec/fixtures/releases/bosh-sample-release/jobs/mysql/templates/my.bootstrap.erb +0 -6
  64. data/spec/fixtures/releases/bosh-sample-release/jobs/mysql/templates/my.cnf.erb +0 -46
  65. data/spec/fixtures/releases/bosh-sample-release/jobs/mysql/templates/my.shutdown.erb +0 -5
  66. data/spec/fixtures/releases/bosh-sample-release/jobs/mysql/templates/mysql_ctl.erb +0 -56
  67. data/spec/fixtures/releases/bosh-sample-release/jobs/nginx/monit +0 -5
  68. data/spec/fixtures/releases/bosh-sample-release/jobs/nginx/spec +0 -10
  69. data/spec/fixtures/releases/bosh-sample-release/jobs/nginx/templates/mime.types +0 -73
  70. data/spec/fixtures/releases/bosh-sample-release/jobs/nginx/templates/nginx.conf.erb +0 -65
  71. data/spec/fixtures/releases/bosh-sample-release/jobs/nginx/templates/nginx_ctl +0 -28
  72. data/spec/fixtures/releases/bosh-sample-release/jobs/wordpress/monit +0 -5
  73. data/spec/fixtures/releases/bosh-sample-release/jobs/wordpress/spec +0 -12
  74. data/spec/fixtures/releases/bosh-sample-release/jobs/wordpress/templates/httpd.conf.erb +0 -422
  75. data/spec/fixtures/releases/bosh-sample-release/jobs/wordpress/templates/php.ini.erb +0 -1918
  76. data/spec/fixtures/releases/bosh-sample-release/jobs/wordpress/templates/wordpress_ctl +0 -39
  77. data/spec/fixtures/releases/bosh-sample-release/jobs/wordpress/templates/wp-config.php.erb +0 -90
  78. data/spec/fixtures/releases/bosh-sample-release/packages/apache2/packaging +0 -15
  79. data/spec/fixtures/releases/bosh-sample-release/packages/apache2/spec +0 -5
  80. data/spec/fixtures/releases/bosh-sample-release/packages/mysql/packaging +0 -14
  81. data/spec/fixtures/releases/bosh-sample-release/packages/mysql/spec +0 -5
  82. data/spec/fixtures/releases/bosh-sample-release/packages/mysqlclient/packaging +0 -12
  83. data/spec/fixtures/releases/bosh-sample-release/packages/mysqlclient/spec +0 -4
  84. data/spec/fixtures/releases/bosh-sample-release/packages/nginx/packaging +0 -23
  85. data/spec/fixtures/releases/bosh-sample-release/packages/nginx/spec +0 -6
  86. data/spec/fixtures/releases/bosh-sample-release/packages/php5/packaging +0 -24
  87. data/spec/fixtures/releases/bosh-sample-release/packages/php5/spec +0 -7
  88. data/spec/fixtures/releases/bosh-sample-release/packages/wordpress/packaging +0 -14
  89. data/spec/fixtures/releases/bosh-sample-release/packages/wordpress/spec +0 -5
  90. data/spec/fixtures/releases/s3test-boshrelease/.gitignore +0 -18
  91. data/spec/fixtures/releases/s3test-boshrelease/README.md +0 -51
  92. data/spec/fixtures/releases/s3test-boshrelease/Rakefile +0 -15
  93. data/spec/fixtures/releases/s3test-boshrelease/config/blobs.yml +0 -1
  94. data/spec/fixtures/releases/s3test-boshrelease/config/final.yml +0 -5
  95. data/spec/fixtures/releases/s3test-boshrelease/jobs/.gitkeep +0 -0
  96. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/monit +0 -5
  97. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/spec +0 -13
  98. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/bin/monit_debugger +0 -13
  99. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/bin/s3test_ctl +0 -36
  100. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/config/.gitkeep +0 -0
  101. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/config/s3test.conf.erb +0 -5
  102. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/data/properties.sh.erb +0 -10
  103. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/helpers/ctl_setup.sh +0 -81
  104. data/spec/fixtures/releases/s3test-boshrelease/jobs/s3test/templates/helpers/ctl_utils.sh +0 -156
  105. data/spec/fixtures/releases/s3test-boshrelease/packages/.gitkeep +0 -0
  106. data/spec/fixtures/releases/s3test-boshrelease/src/.gitkeep +0 -0
  107. data/spec/fixtures/releases/s3test-boshrelease/templates/deployment.yml +0 -35
  108. data/spec/fixtures/releases/s3test-boshrelease/templates/infrastructure-aws-ec2.yml +0 -40
  109. data/spec/fixtures/releases/s3test-boshrelease/templates/infrastructure-warden.yml +0 -107
  110. data/spec/fixtures/releases/s3test-boshrelease/templates/jobs.yml +0 -34
  111. data/spec/fixtures/releases/s3test-boshrelease/templates/make_manifest +0 -54
  112. data/spec/fixtures/releases/s3test-boshrelease/templates/stub.yml +0 -13
  113. data/spec/fixtures/releases/some_dev_releases/config/dev.yml +0 -3
  114. data/spec/fixtures/releases/some_dev_releases/dev_releases/index.yml +0 -6
  115. data/spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-1.yml +0 -11
  116. data/spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-10.yml +0 -13
  117. data/spec/fixtures/releases/some_dev_releases/dev_releases/myrelease-2.yml +0 -13
  118. data/spec/generators/job_generator_spec.rb +0 -56
  119. data/spec/generators/new_release_generator_spec.rb +0 -93
  120. data/spec/models/bosh_config_spec.rb +0 -11
  121. data/spec/models/deployment_manifest_spec.rb +0 -40
  122. data/spec/models/release_detection_spec.rb +0 -23
  123. data/spec/spec_helper.rb +0 -30
  124. data/spec/support/generator_spec_helper.rb +0 -155
@@ -1,34 +0,0 @@
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
- templates:
14
- - name: s3test
15
- release: s3test
16
- instances: 0
17
- resource_pool: small_z1
18
- networks: (( merge ))
19
- - name: s3test_z1
20
- templates:
21
- - name: s3test
22
- release: s3test
23
- instances: 0
24
- resource_pool: small_z1
25
- networks: (( merge ))
26
- update:
27
- canaries: 10
28
- properties:
29
- s3test:
30
- leader_address: (( merge ))
31
-
32
- networks: (( merge ))
33
-
34
- properties: {}
@@ -1,54 +0,0 @@
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,13 +0,0 @@
1
- ---
2
- meta:
3
- environment: NAME
4
- dns_root: microbosh
5
- network_name: s3test1
6
- security_groups:
7
- - s3test
8
-
9
- director_uuid: PLACEHOLDER-DIRECTOR-UUID
10
-
11
- releases:
12
- - name: s3test
13
- version: latest
@@ -1,3 +0,0 @@
1
- ---
2
- dev_name: myrelease
3
- latest_release_filename: dev_releases/myrelease-10.yml
@@ -1,6 +0,0 @@
1
- ---
2
- builds:
3
- 5c4ded1540f4cc047244f3a5a2e11a99220a2a53:
4
- version: 1
5
- d4e368b6c1734ac34555a349ca567aa226cc1a6e:
6
- version: 2
@@ -1,11 +0,0 @@
1
- ---
2
- packages:
3
- - name: redis
4
- version: 0.1-dev
5
- sha1: 3e4d5b321ae69bee3cc0753d1a91606612d710a4
6
- dependencies: []
7
-
8
- jobs: []
9
-
10
- name: myrelease
11
- version: 1
@@ -1,13 +0,0 @@
1
- ---
2
- packages:
3
- - name: redis
4
- version: 0.2-dev
5
- sha1: 90a1131ebec948be6e4d2d2f25be7fa83b76ea79
6
- dependencies: []
7
-
8
- jobs:
9
- - name: redis
10
- version: 0.1-dev
11
- sha1: f9b23d1e4585357dc47636d75a63283f629bb1ee
12
- name: myrelease
13
- version: 10
@@ -1,13 +0,0 @@
1
- ---
2
- packages:
3
- - name: redis
4
- version: 0.2-dev
5
- sha1: 90a1131ebec948be6e4d2d2f25be7fa83b76ea79
6
- dependencies: []
7
-
8
- jobs:
9
- - name: redis
10
- version: 0.1-dev
11
- sha1: f9b23d1e4585357dc47636d75a63283f629bb1ee
12
- name: myrelease
13
- version: 2
@@ -1,56 +0,0 @@
1
- require "spec_helper"
2
- require "bosh/gen/generators/job_generator"
3
-
4
- # in a tmp folder:
5
- # * run generator
6
- # * specific files created
7
- # * run 'bosh create release'
8
- # * it shouldn't fail
9
-
10
- # generates job for a webapp application package
11
- describe Bosh::Gen::Generators::JobGenerator do
12
- before do
13
- setup_project_release("bosh-sample-release")
14
- end
15
-
16
- it "creates common job files" do
17
- in_project_folder do
18
- generate_job("mywebapp")
19
- expect(File.exist?("jobs/mywebapp/monit")).to eq(true)
20
- expect(File.exist?("jobs/mywebapp/spec")).to eq(true)
21
- job_template_exists "mywebapp", "bin/ctl", "bin/ctl"
22
- job_template_exists "mywebapp", "bin/monit_debugger", "bin/monit_debugger"
23
- job_template_exists "mywebapp", "data/properties.sh.erb", "data/properties.sh"
24
- job_template_exists "mywebapp", "helpers/ctl_setup.sh", "helpers/ctl_setup.sh"
25
- job_template_exists "mywebapp", "helpers/ctl_utils.sh", "helpers/ctl_utils.sh"
26
- end
27
- end
28
-
29
- pending "creates job files with rails & nginx templates" do
30
- in_project_folder do
31
- generate_job("mywebapp", "--purpose", "nginx_rack", '-d', 'nginx', 'ruby', 'myapp')
32
- expect(File.exist?("jobs/mywebapp/monit")).to eq(true)
33
- expect(File.exist?("jobs/mywebapp/spec")).to eq(true)
34
-
35
- expect(job_spec("mywebapp")["packages"]).to eq(%w[nginx ruby myapp])
36
-
37
- job_template_exists "mywebapp", "bin/mywebapp_ctl", "bin/mywebapp_ctl"
38
- job_template_exists "mywebapp", "bin/monit_debugger", "bin/monit_debugger"
39
- job_template_exists "mywebapp", "data/properties.sh.erb", "data/properties.sh"
40
- job_template_exists "mywebapp", "helpers/ctl_setup.sh.erb", "helpers/ctl_setup.sh"
41
- job_template_exists "mywebapp", "helpers/ctl_utils.sh", "helpers/ctl_utils.sh"
42
-
43
- job_template_exists "mywebapp", "bin/ctl_db_utils.sh.erb", "bin/ctl_db_utils.sh"
44
- job_template_exists "mywebapp", "bin/ctl_redis_utils.sh.erb", "bin/ctl_redis_utils.sh"
45
- job_template_exists "mywebapp", "bin/rails_ctl_setup.sh.erb", "bin/rails_ctl_setup.sh"
46
- job_template_exists "mywebapp", "bin/ctl_start.sh.erb", "bin/ctl_start.sh"
47
- job_template_exists "mywebapp", "bin/ctl_nginx.sh.erb", "bin/ctl_nginx.sh"
48
- job_template_exists "mywebapp", "bin/nginx_ctl", "bin/nginx_ctl"
49
- job_template_exists "mywebapp", "config/nginx.conf.erb", "config/nginx.conf"
50
- job_template_exists "mywebapp", "config/nginx_proxy.conf", "config/nginx_proxy.conf"
51
- job_template_exists "mywebapp", "config/mime.types", "config/mime.types"
52
- job_template_exists "mywebapp", "config/database.yml.erb", "config/database.yml"
53
- job_template_exists "mywebapp", "config/redis.yml.erb", "config/redis.yml"
54
- end
55
- end
56
- end
@@ -1,93 +0,0 @@
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
- def cyoi_provider
8
- provider = instance_double("Cyoi::Cli::Provider")
9
- expect(provider).to receive(:execute!)
10
- expect(Cyoi::Cli::Provider).to receive(:new).with([settings_dir]).and_return(provider)
11
- provider
12
- end
13
-
14
- def cyoi_blobstore(blobstore_name)
15
- blobstore = instance_double("Cyoi::Cli::Blobstore")
16
- expect(blobstore).to receive(:execute!)
17
- expect(Cyoi::Cli::Blobstore).to receive(:new).with([blobstore_name, settings_dir]).and_return(blobstore)
18
- blobstore
19
- end
20
-
21
- before do
22
- in_home_folder do
23
- self.settings_dir = "redis-boshrelease/config"
24
- cyoi_provider
25
- cyoi_blobstore "redis-boshrelease"
26
- end
27
- end
28
-
29
- it "generates with s3 blobstore" do
30
- in_home_folder do
31
-
32
- setting "provider.name", "aws"
33
- setting "provider.region", "us-west-2"
34
- setting "provider.credentials.aws_access_key_id", "ACCESS"
35
- setting "provider.credentials.aws_secret_access_key", "SECRET"
36
-
37
- generate_new_release 'redis'
38
- expect(File.directory?("jobs")).to eq(true)
39
-
40
- config = YAML.load_file("config/final.yml")
41
- expect(config).to_not be_nil
42
- expect(config["final_name"]).to eq("redis")
43
- expect(config["blobstore"]).to_not be_nil
44
- expect(config["blobstore"]["options"]).to_not be_nil
45
- expect(config["blobstore"]["provider"]).to eq("s3")
46
- expect(config["blobstore"]["options"].keys).to eq(["bucket_name"])
47
- expect(config["blobstore"]["options"]["bucket_name"]).to eq("redis-boshrelease")
48
-
49
- config = YAML.load_file("config/private.yml")
50
- expect(config).to_not be_nil
51
- expect(config["blobstore"]).to_not be_nil
52
- expect(config["blobstore"]["s3"]).to_not be_nil
53
- expect(config["blobstore"]["s3"]["access_key_id"]).to eq("ACCESS")
54
- expect(config["blobstore"]["s3"]["secret_access_key"]).to eq("SECRET")
55
- end
56
- end
57
-
58
- it "generates with swift blobstore" do
59
- in_home_folder do
60
- setting "provider.name", "openstack"
61
- setting "provider.credentials.openstack_auth_url", "http://10.0.0.2:5000/v2.0/tokens"
62
- setting "provider.credentials.openstack_username", "USER"
63
- setting "provider.credentials.openstack_api_key", "PASSWORD"
64
- setting "provider.credentials.openstack_tenant", "TENANT"
65
- setting "provider.credentials.openstack_region", "REGION"
66
-
67
- # TODO: get rid of this prompt from Cyoi::Provider
68
- setting "provider.options.boot_from_volume", false
69
-
70
- generate_new_release 'redis'
71
- expect(File.directory?("jobs")).to eq(true)
72
-
73
- config = YAML.load_file("config/final.yml")
74
- expect(config).to_not be_nil
75
- expect(config["final_name"]).to eq("redis")
76
- expect(config["blobstore"]).to_not be_nil
77
- expect(config["blobstore"]["options"]).to_not be_nil
78
- expect(config["blobstore"]["provider"]).to eq("swift")
79
- expect(config["blobstore"]["options"].keys).to eq(["container_name", "swift_provider"])
80
- expect(config["blobstore"]["options"]["container_name"]).to eq("redis-boshrelease")
81
-
82
- config = YAML.load_file("config/private.yml")
83
- expect(config).to_not be_nil
84
- expect(config["blobstore"]).to_not be_nil
85
- expect(config["blobstore"]["swift"]["openstack"]).to_not be_nil
86
- expect(config["blobstore"]["swift"]["openstack"]["openstack_auth_url"]).to eq("http://10.0.0.2:5000/v2.0/tokens")
87
- expect(config["blobstore"]["swift"]["openstack"].keys).to eq(["openstack_auth_url", "openstack_username", "openstack_api_key", "openstack_tenant", "openstack_region"])
88
- end
89
- end
90
-
91
- # generate_new_release 'redis'
92
- # generate_new_release 'redis-boshrelease'
93
- end
@@ -1,11 +0,0 @@
1
- require "spec_helper"
2
- require "bosh/gen/models"
3
-
4
- describe Bosh::Gen::Models::BoshConfig do
5
- it "knows UUID of current target bosh" do
6
- fake_config = File.expand_path( \
7
- "../../fixtures/bosh_config/multiple_boshes.yml", __FILE__)
8
- config = Bosh::Gen::Models::BoshConfig.new(fake_config)
9
- expect(config.target_uuid).to eq "f734ed1f-6892-4d96-9123-018c830a8543"
10
- end
11
- end
@@ -1,40 +0,0 @@
1
- require "spec_helper"
2
- require "bosh/gen/models"
3
-
4
- describe Bosh::Gen::Models::DeploymentManifest do
5
- it "creates manifest document with 2 jobs, no disk" do
6
- manifest = Bosh::Gen::Models::DeploymentManifest.new("myproj", "UUID",
7
- {"name" => "myrelease", "version" => 2},
8
- {"instance_type" => "m3.medium", "static_ips" => ['1.2.3.4', '6.7.8.9']}, {})
9
- manifest.jobs = [
10
- { "name" => "job-with-ips"},
11
- { "name" => "misc"}
12
- ]
13
- expect(manifest.to_yaml).to eq fixture_manifest("2_jobs_2_ips_no_disk")
14
- end
15
-
16
- it "creates manifest document with 2 jobs, with disk" do
17
- manifest = Bosh::Gen::Models::DeploymentManifest.new("myproj", "UUID",
18
- {"name" => "myrelease", "version" => 2},
19
- {"instance_type" => "m3.medium", "persistent_disk" => "8196", "static_ips" => ['1.2.3.4']}, {})
20
- manifest.jobs = [
21
- { "name" => "job-with-ips"},
22
- { "name" => "misc"}
23
- ]
24
- expect(manifest.to_yaml).to eq fixture_manifest("2_jobs_1_ip_8196_disk")
25
- end
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" => "m3.medium", "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
-
37
- def fixture_manifest(name)
38
- File.read(File.expand_path("../../fixtures/deployment_manifests/#{name}.yml", __FILE__))
39
- end
40
- end
@@ -1,23 +0,0 @@
1
- require "spec_helper"
2
- require "bosh/gen/models"
3
-
4
- describe Bosh::Gen::Models::ReleaseDetection do
5
- it "detects latest dev release version" do
6
- detector = Bosh::Gen::Models::ReleaseDetection.new(fixture_release_path('some_dev_releases'))
7
- latest_dev_release_version = detector.latest_dev_release_version
8
- expect(latest_dev_release_version).to eq 10
9
- end
10
-
11
- it "creates release properties for deployment manifest" do
12
- detector = Bosh::Gen::Models::ReleaseDetection.new(fixture_release_path('some_dev_releases'))
13
- expect(detector.latest_dev_release_properties).to eq({
14
- "name" => "myrelease",
15
- "version" => 10
16
- })
17
- end
18
-
19
- it "returns list of jobs" do
20
- detector = Bosh::Gen::Models::ReleaseDetection.new(fixture_release_path('some_dev_releases'))
21
- expect(detector.latest_dev_release_job_names).to eq %w[redis]
22
- end
23
- end
data/spec/spec_helper.rb DELETED
@@ -1,30 +0,0 @@
1
- # Copyright (c) 2012-2014 Stark & Wayne, LLC
2
-
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__)
22
- end
23
-
24
- RSpec.configure do |c|
25
- c.before do
26
- extend GeneratorSpecHelper
27
- setup_universe
28
- end
29
- c.color = true
30
- end
@@ -1,155 +0,0 @@
1
- require "bosh/gen/cli"
2
-
3
- module GeneratorSpecHelper
4
- def setup_universe
5
- @@local_developer_bosh_config ||= File.expand_path("~/.bosh_config") # ENV['HOME'] messed with later
6
- @tmp_root = File.expand_path("../../tmp", __FILE__)
7
- @home_path = File.join(@tmp_root, "home")
8
- @fixtures_path = File.expand_path('../../fixtures', __FILE__)
9
- FileUtils.rm_rf @tmp_root
10
- FileUtils.mkdir_p @home_path
11
- ENV['HOME'] = @home_path
12
- if File.exists?(@@local_developer_bosh_config)
13
- FileUtils.cp_r(@@local_developer_bosh_config, @home_path)
14
- end
15
- setup_git
16
- end
17
-
18
- def setup_project_release(name)
19
- release_path = File.join(@fixtures_path, "releases", name)
20
- FileUtils.cp_r(release_path, @tmp_root)
21
- @active_project_folder = File.join(@tmp_root, name)
22
- end
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
-
43
- # Runs 'bosh-gen job NAME ...'
44
- #
45
- # generate_job 'JOBNAME'
46
- # generate_job 'JOBNAME', '-d', 'nginx'
47
- # generate_job "JOBNAME", "--template", "nginx_rack", '-d', 'nginx', 'ruby', 'myapp'
48
- def generate_job(*args)
49
- stdout, stderr = capture_stdios do
50
- Bosh::Gen::Command.start(["job", *args])
51
- end
52
- @stdout = File.expand_path(File.join(@tmp_root, "generate_job.out"))
53
- File.open(@stdout, "w") {|f| f << stdout; f << stderr}
54
- end
55
-
56
- # Runs 'bosh-gen manifest path/to/release'
57
- # generate_manifest "path/to/release"
58
- def generate_manifest(*args)
59
- stdout, stderr = capture_stdios do
60
- Bosh::Gen::Command.start(["manifest", *args])
61
- end
62
- @stdout = File.expand_path(File.join(@tmp_root, "generate_manifest.out"))
63
- File.open(@stdout, "w") {|f| f << stdout; f << stderr}
64
- end
65
-
66
- # Test that a file exists in job
67
- # job_file_exists "mywebapp", "monit"
68
- # job_file_exists "mywebapp", "templates", "mywebapp_ctl", :executable => true
69
- def job_file_exists(*args)
70
- if args.last.is_a?(Hash)
71
- options = args.pop
72
- end
73
- path = File.join(["jobs"] + args) # jobs/JOBNAME/monit
74
- expect(File.exist?(path)).to eq(true)
75
- if options && options[:executable]
76
- expect(File.executable?(path)).to eq(true)
77
- end
78
- end
79
-
80
- # Tests a job template and its spec
81
- # job_template_exists "mywebapp", "mywebapp_ctl.erb", "bin/mywebapp_ctl"
82
- #
83
- # Spec would contain:
84
- # mywebapp_ctl.erb: bin/mywebapp_ctl
85
- def job_template_exists(job, template_name, spec_path)
86
- path = File.join("jobs", job, "templates", template_name)
87
- expect(File.exist?(path)).to eq(true)
88
- spec_templates = job_spec(job)["templates"]
89
- expect(spec_templates[template_name]).to_not be_nil
90
- expect(spec_templates[template_name]).to eq(spec_path)
91
- end
92
-
93
- def job_spec(job)
94
- @specs ||= {}
95
- @specs[job] ||= YAML.load_file(File.join("jobs", job, "spec"))
96
- end
97
-
98
- def setup_active_project_folder project_name
99
- @active_project_folder = File.join(@tmp_root, project_name)
100
- @project_name = project_name
101
- end
102
-
103
- def in_tmp_folder(&block)
104
- FileUtils.chdir(@tmp_root, &block)
105
- end
106
-
107
- def in_project_folder(&block)
108
- project_folder = @active_project_folder || @tmp_root
109
- FileUtils.chdir(project_folder, &block)
110
- end
111
-
112
- def in_home_folder(&block)
113
- FileUtils.chdir(@home_path, &block)
114
- end
115
-
116
- def capture_stdios(input = nil, &block)
117
- require 'stringio'
118
- org_stdin, $stdin = $stdin, StringIO.new(input) if input
119
- org_stdout, $stdout = $stdout, StringIO.new
120
- org_stderr, $stderr = $stdout, StringIO.new
121
- yield
122
- return [$stdout.string, $stderr.string]
123
- ensure
124
- $stderr = org_stderr
125
- $stdout = org_stdout
126
- $stdin = org_stdin
127
- end
128
-
129
- def get_command_output
130
- strip_color_codes(File.read(@stdout)).chomp
131
- end
132
-
133
- def strip_color_codes(text)
134
- text.gsub(/\e\[\d+m/, '')
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
-
155
- end