polytrix 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.groc.json +7 -0
  4. data/.rspec +11 -0
  5. data/.rspec_parallel +10 -0
  6. data/Gemfile +23 -0
  7. data/README.md +48 -0
  8. data/Rakefile +143 -0
  9. data/Vagrantfile +41 -0
  10. data/features/0_identity_spec.rb +40 -0
  11. data/features/1_cloud_files_spec.rb +48 -0
  12. data/features/2_servers_spec.rb +19 -0
  13. data/features/features_helper.rb +46 -0
  14. data/features/helpers/cloudfiles_helper.rb +31 -0
  15. data/features/helpers/pacto_helper.rb +33 -0
  16. data/features/helpers/teardown_helper.rb +49 -0
  17. data/features/pacto/extensions/loaders/api_blueprint_loader.rb +63 -0
  18. data/features/pacto/extensions/loaders/simple_loader.rb +55 -0
  19. data/features/pacto/extensions/loaders/yaml_or_json_loader.rb +17 -0
  20. data/features/pacto/extensions/matchers.rb +38 -0
  21. data/features/phase2/feature_coverage_report.rb +109 -0
  22. data/features/phase2/run_all_features.rb +14 -0
  23. data/features/static_site/fixtures/index.html +6 -0
  24. data/lib/polytrix/challenge.rb +27 -0
  25. data/lib/polytrix/challenge_builder.rb +16 -0
  26. data/lib/polytrix/challenge_runner.rb +87 -0
  27. data/lib/polytrix/configuration.rb +31 -0
  28. data/lib/polytrix/core/file_finder.rb +43 -0
  29. data/lib/polytrix/core/implementor.rb +17 -0
  30. data/lib/polytrix/core/result_tracker.rb +25 -0
  31. data/lib/polytrix/documentation_generator.rb +18 -0
  32. data/lib/polytrix/manifest.rb +46 -0
  33. data/lib/polytrix/result.rb +9 -0
  34. data/lib/polytrix/rspec/documentation_formatter.rb +41 -0
  35. data/lib/polytrix/rspec.rb +75 -0
  36. data/lib/polytrix/runners/linux_challenge_runner.rb +22 -0
  37. data/lib/polytrix/runners/middleware/change_directory.rb +20 -0
  38. data/lib/polytrix/runners/middleware/feature_executor.rb +23 -0
  39. data/lib/polytrix/runners/middleware/pacto.rb +59 -0
  40. data/lib/polytrix/runners/middleware/setup_env_vars.rb +38 -0
  41. data/lib/polytrix/runners/windows_challenge_runner.rb +25 -0
  42. data/lib/polytrix/version.rb +3 -0
  43. data/lib/polytrix.rb +56 -0
  44. data/packer/.gitignore +3 -0
  45. data/packer/Berksfile +15 -0
  46. data/packer/Gemfile +5 -0
  47. data/packer/Vagrantfile +128 -0
  48. data/packer/cookbooks/drg/metadata.rb +27 -0
  49. data/packer/cookbooks/drg/recipes/admins.rb +22 -0
  50. data/packer/cookbooks/drg/recipes/default.rb +9 -0
  51. data/packer/cookbooks/drg/recipes/dotnet.rb +4 -0
  52. data/packer/cookbooks/drg/recipes/golang.rb +4 -0
  53. data/packer/cookbooks/drg/recipes/java.rb +5 -0
  54. data/packer/cookbooks/drg/recipes/php.rb +10 -0
  55. data/packer/cookbooks/drg/recipes/ruby.rb +29 -0
  56. data/packer/cookbooks/drg/recipes/system.rb +13 -0
  57. data/packer/create_box.sh +10 -0
  58. data/packer/http/preseed.cfg +87 -0
  59. data/packer/packer.json +91 -0
  60. data/packer/scripts/root_setup.sh +37 -0
  61. data/packer/scripts/setup.sh +32 -0
  62. data/pacto/config/pacto_server.rb +40 -0
  63. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/extensions.json +64 -0
  64. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/flavors/id.json +100 -0
  65. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/images/id.json +176 -0
  66. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers/id.json +189 -0
  67. data/pacto/contracts/dfw.servers.api.rackspacecloud.com/v2/account_id/servers.json +63 -0
  68. data/pacto/contracts/dns.api.rackspacecloud.com/v1.0/_tenant_id/domains.json +62 -0
  69. data/pacto/contracts/identity.api.rackspacecloud.com/v2.0/tokens.json +192 -0
  70. data/pacto/contracts/monitoring.api.rackspacecloud.com/v1.0/_tenant_id/account.json +39 -0
  71. data/pacto/contracts/ord.autoscale.api.rackspacecloud.com/v1.0/_tenant_id/groups.json +38 -0
  72. data/pacto/contracts/ord.blockstorage.api.rackspacecloud.com/v1/_tenant_id/volumes.json +30 -0
  73. data/pacto/contracts/ord.databases.api.rackspacecloud.com/v1.0/_tenant_id/instances.json +30 -0
  74. data/pacto/contracts/ord.loadbalancers.api.rackspacecloud.com/v1.0/_tenant_id/loadbalancers.json +114 -0
  75. data/pacto/contracts/ord.queues.api.rackspacecloud.com/v1/_tenant_id/queues.json +13 -0
  76. data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/os-networksv2.json +46 -0
  77. data/pacto/contracts/ord.servers.api.rackspacecloud.com/v2/_tenant_id/servers/detail.json +230 -0
  78. data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account/container/object.json +15 -0
  79. data/pacto/contracts/storage101.dfw1.clouddrive.com/v1/mosso_account.json +43 -0
  80. data/pacto/contracts/storage101.ord1.clouddrive.com/v1/_mosso_id.json +44 -0
  81. data/pacto/pacto_server.rb +100 -0
  82. data/pacto/rackspace_uri_map.yaml +229 -0
  83. data/polytrix.gemspec +27 -0
  84. data/scripts/bootstrap +10 -0
  85. data/scripts/cibuild +4 -0
  86. data/sdks/fog/.gitignore +1 -0
  87. data/sdks/fog/Gemfile +5 -0
  88. data/sdks/fog/challenges/all_connections.rb +45 -0
  89. data/sdks/fog/challenges/authenticate_token.rb +15 -0
  90. data/sdks/fog/challenges/cdn_enable_container.rb +20 -0
  91. data/sdks/fog/challenges/create_a_container.rb +17 -0
  92. data/sdks/fog/challenges/create_server.rb +36 -0
  93. data/sdks/fog/challenges/get_object_metadata.rb +13 -0
  94. data/sdks/fog/challenges/list_containers.rb +10 -0
  95. data/sdks/fog/challenges/provision_scalable_webapp.rb +30 -0
  96. data/sdks/fog/challenges/upload_folder.rb +25 -0
  97. data/sdks/fog/scripts/bootstrap +4 -0
  98. data/sdks/fog/scripts/bootstrap.ps1 +1 -0
  99. data/sdks/fog/scripts/wrapper +2 -0
  100. data/sdks/fog/scripts/wrapper.ps1 +1 -0
  101. data/sdks/gophercloud/.gitignore +2 -0
  102. data/sdks/gophercloud/challenges/authenticate_token.go +23 -0
  103. data/sdks/gophercloud/scripts/bootstrap +6 -0
  104. data/sdks/gophercloud/scripts/wrapper +10 -0
  105. data/sdks/jclouds/.gitignore +1 -0
  106. data/sdks/jclouds/challenges/AuthenticateToken.java +115 -0
  107. data/sdks/jclouds/pom.xml +34 -0
  108. data/sdks/jclouds/scripts/bootstrap +3 -0
  109. data/sdks/jclouds/scripts/wrapper +7 -0
  110. data/sdks/openstack.net/.gitignore +4 -0
  111. data/sdks/openstack.net/.nuget/Microsoft.Build.dll +0 -0
  112. data/sdks/openstack.net/.nuget/NuGet.Config +6 -0
  113. data/sdks/openstack.net/.nuget/NuGet.exe +0 -0
  114. data/sdks/openstack.net/.nuget/NuGet.targets +136 -0
  115. data/sdks/openstack.net/Challenge.cs +10 -0
  116. data/sdks/openstack.net/RunChallenge.cs +19 -0
  117. data/sdks/openstack.net/challenges/AuthenticateToken.cs +24 -0
  118. data/sdks/openstack.net/challenges/Weird.cs +133 -0
  119. data/sdks/openstack.net/openstack.net.csproj +58 -0
  120. data/sdks/openstack.net/openstack.net.sln +27 -0
  121. data/sdks/openstack.net/openstack.net.userprefs +8 -0
  122. data/sdks/openstack.net/packages.config +6 -0
  123. data/sdks/openstack.net/scripts/bootstrap +2 -0
  124. data/sdks/openstack.net/scripts/bootstrap.ps1 +2 -0
  125. data/sdks/openstack.net/scripts/wrapper +7 -0
  126. data/sdks/openstack.net/scripts/wrapper.ps1 +1 -0
  127. data/sdks/php-opencloud/.gitignore +4 -0
  128. data/sdks/php-opencloud/challenges/all_connections.php +64 -0
  129. data/sdks/php-opencloud/challenges/authenticate_token.php +14 -0
  130. data/sdks/php-opencloud/challenges/create_server.php +39 -0
  131. data/sdks/php-opencloud/challenges/get_object_metadata.php +19 -0
  132. data/sdks/php-opencloud/composer.json +5 -0
  133. data/sdks/php-opencloud/scripts/bootstrap +4 -0
  134. data/sdks/php-opencloud/scripts/bootstrap.ps1 +2 -0
  135. data/sdks/php-opencloud/scripts/wrapper +2 -0
  136. data/sdks/php-opencloud/scripts/wrapper.ps1 +1 -0
  137. data/sdks/pkgcloud/.gitignore +1 -0
  138. data/sdks/pkgcloud/challenges/authenticate_token.js +17 -0
  139. data/sdks/pkgcloud/challenges/get_object_metadata.js +18 -0
  140. data/sdks/pkgcloud/scripts/bootstrap +2 -0
  141. data/sdks/pkgcloud/scripts/bootstrap.ps1 +1 -0
  142. data/sdks/pkgcloud/scripts/wrapper +2 -0
  143. data/sdks/pkgcloud/scripts/wrapper.ps1 +1 -0
  144. data/sdks/pyrax/.gitignore +2 -0
  145. data/sdks/pyrax/challenges/all_connections.py +61 -0
  146. data/sdks/pyrax/challenges/authenticate_token.py +17 -0
  147. data/sdks/pyrax/challenges/cdn_enable_container.py +22 -0
  148. data/sdks/pyrax/challenges/create_a_container.py +21 -0
  149. data/sdks/pyrax/challenges/create_server.py +35 -0
  150. data/sdks/pyrax/challenges/get_object_metadata.py +17 -0
  151. data/sdks/pyrax/challenges/upload_folder.py +32 -0
  152. data/sdks/pyrax/requirements.txt +21 -0
  153. data/sdks/pyrax/scripts/bootstrap +9 -0
  154. data/sdks/pyrax/scripts/bootstrap.ps1 +7 -0
  155. data/sdks/pyrax/scripts/wrapper +3 -0
  156. data/sdks/pyrax/scripts/wrapper.ps1 +2 -0
  157. data/spec/fixtures/factorial.py +18 -0
  158. data/spec/fixtures/polytrix.yml +16 -0
  159. data/spec/fixtures/src-doc/quine.md.erb +20 -0
  160. data/spec/polytrix/challenge_builder_spec.rb +16 -0
  161. data/spec/polytrix/challenge_runner_spec.rb +14 -0
  162. data/spec/polytrix/challenge_spec.rb +20 -0
  163. data/spec/polytrix/configuration_spec.rb +10 -0
  164. data/spec/polytrix/documentation_generator_spec.rb +36 -0
  165. data/spec/polytrix/file_finder_spec.rb +24 -0
  166. data/spec/polytrix/manifest_spec.rb +26 -0
  167. data/spec/polytrix/middleware/feature_executor_spec.rb +48 -0
  168. data/spec/polytrix_spec.rb +13 -0
  169. data/spec/rspec_spec.rb +17 -0
  170. data/spec/spec_helper.rb +7 -0
  171. metadata +325 -0
@@ -0,0 +1,75 @@
1
+ require 'polytrix'
2
+ begin
3
+ require 'rspec/core'
4
+ require 'rspec/expectations'
5
+ require 'rspec/core/formatters/base_text_formatter'
6
+ rescue LoadError
7
+ raise 'polytrix/rspec requires rspec 2 or later'
8
+ end
9
+
10
+ module Polytrix
11
+ module RSpec
12
+ module Helper
13
+ def challenge_runner
14
+ @challenge_runner ||= Polytrix::ChallengeRunner.createRunner
15
+ end
16
+
17
+ def execute_challenge(sdk_dir, challenge_name, vars)
18
+ implementor_name = File.basename(sdk_dir) # Might not be a good assumption
19
+ implementor = Polytrix.implementors.find { |i| i.name == implementor_name }
20
+ challenge = ChallengeBuilder.new(implementor).build :name => challenge_name, :vars => vars, :basedir => sdk_dir, :implementor => implementor.name
21
+ example.metadata[:polytrix] = challenge
22
+ result = challenge.run
23
+ yield result
24
+ end
25
+ end
26
+
27
+ class << self
28
+ def run_manifest(manifest)
29
+ manifest['suites'].each do |suite_name, suite_config|
30
+ describe suite_name do
31
+ suite_config['samples'].each do |scenario|
32
+ code_sample scenario, '', suite_config['env'].to_hash do |result|
33
+ instance_exec result, &Polytrix.default_validator_callback
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def code_sample(challenge, description = '', environment = [], services = [], &block)
44
+ challenge_file = challenge.downcase.gsub(' ', '_')
45
+ describe challenge, markdown: description,
46
+ # :environment => redact(environment),
47
+ services: services do
48
+ Polytrix.implementors.each do |sdk|
49
+ sdk = sdk.name if sdk.respond_to? :name
50
+ it sdk, sdk.to_sym => true, 'data-challenge' => challenge_file, 'data-sdk' => sdk do
51
+ Polytrix.results.example_started example
52
+ begin
53
+ sdk_dir = Polytrix.sdk_dir sdk
54
+ pending "#{sdk} is not setup" unless File.directory? sdk_dir
55
+ challenge_runner.find_challenge! challenge_file, sdk_dir
56
+ execute_challenge sdk_dir, challenge_file, environment do |result|
57
+ Polytrix.results.execution_result example, result
58
+ instance_exec result, &block
59
+ end
60
+
61
+ rescue Polytrix::FeatureNotImplementedError => e
62
+ pending e.message
63
+ rescue ThreadError => e
64
+ puts "ThreadError detected: #{e.message}"
65
+ puts "ThreadError backtrace: #{e.backtrace}"
66
+ raise e
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ RSpec.configure do |c|
74
+ c.include Polytrix::RSpec::Helper
75
+ end
@@ -0,0 +1,22 @@
1
+ module Polytrix
2
+ module Runners
3
+ class LinuxChallengeRunner < ChallengeRunner
4
+ def script_extension
5
+ 'sh'
6
+ end
7
+
8
+ def challenge_command(env_file, challenge_script)
9
+ challenge_script = "./#{challenge_script}" unless challenge_script.to_s.start_with? '/'
10
+ if File.exist? 'scripts/wrapper'
11
+ ". #{env_file} && scripts/wrapper #{challenge_script}"
12
+ else
13
+ ". #{env_file} && #{challenge_script}"
14
+ end
15
+ end
16
+
17
+ def save_environment_variable(key, value)
18
+ "export #{key}=\"#{value}\""
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module Polytrix
2
+ module Runners
3
+ module Middleware
4
+ class ChangeDirectory
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ sdk_dir = env[:basedir]
11
+ Bundler.with_clean_env do
12
+ Dir.chdir sdk_dir do
13
+ @app.call env
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,23 @@
1
+ module Polytrix
2
+ module Runners
3
+ module Middleware
4
+ class FeatureExecutor
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ challenge_runner = env[:challenge_runner]
11
+ env_file = env[:env_file]
12
+ source_file = env[:source_file]
13
+ relative_source_file = source_file.relative_path_from env[:basedir]
14
+ command = challenge_runner.challenge_command(env_file, relative_source_file)
15
+ process = challenge_runner.run_command command
16
+ env[:result] = Result.new(process: process, source: env[:source_file])
17
+ @app.call env
18
+ env[:result]
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,59 @@
1
+ require 'pacto_server'
2
+ require 'goliath/test_helper'
3
+
4
+ module Polytrix
5
+ module Runners
6
+ module Middleware
7
+ class Pacto
8
+ include Goliath::TestHelper
9
+
10
+ def initialize(app, server_options)
11
+ @app = app
12
+ # FIXM: Ideal would be to start a Pacto server once
13
+ # @pacto_server = server(PactoServer, server_options.delete(:port) || 9901, server_options)
14
+ # puts "Started Pacto middleware on port #{@pacto_server.port}"
15
+ end
16
+
17
+ def call(env)
18
+ # FIXME: Ideal (continued) and clear the Pacto validation results before each test...
19
+ with_pacto do
20
+ @app.call(env)
21
+ end
22
+ # Hacky - need better Pacto API
23
+ contracts = ::Pacto::ValidationRegistry.instance.validations.map(&:contract)
24
+ # Unknown services aren't captured in detected services
25
+ detected_services = contracts.compact.map(&:name)
26
+ puts "Services detected: #{detected_services.join ','}"
27
+ env[:plugin_data][:pacto] = {
28
+ :detected_services => detected_services
29
+ }
30
+ # ...
31
+ end
32
+
33
+ private
34
+
35
+ def with_pacto
36
+ result = nil
37
+ puts "Starting Pacto on port #{pacto_port}"
38
+ with_api(PactoServer,
39
+ stdout: true,
40
+ log_file: 'pacto.log',
41
+ config: 'pacto/config/pacto_server.rb',
42
+ live: true,
43
+ generate: generate?,
44
+ verbose: true,
45
+ validate: true,
46
+ directory: File.join(Dir.pwd, 'pacto', 'contracts'),
47
+ port: pacto_port
48
+ ) do
49
+ EM::Synchrony.defer do
50
+ result = yield
51
+ EM.stop
52
+ end
53
+ end
54
+ result
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,38 @@
1
+ require 'fileutils'
2
+
3
+ module Polytrix
4
+ module Runners
5
+ module Middleware
6
+ class SetupEnvVars
7
+ def initialize(app)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ challenge_runner = env[:challenge_runner]
13
+ vars = begin
14
+ Polytrix.manifest[:global_env].dup
15
+ rescue
16
+ {}
17
+ end
18
+ vars = vars.merge env[:vars].dup
19
+
20
+ env[:env_file] = setup_env_vars(vars, challenge_runner)
21
+ @app.call env
22
+ end
23
+
24
+ private
25
+
26
+ def setup_env_vars(vars, challenge_runner)
27
+ FileUtils.mkdir_p 'tmp'
28
+ file = File.open("tmp/vars.#{challenge_runner.script_extension}", 'w')
29
+ vars.each do |key, value|
30
+ file.puts challenge_runner.save_environment_variable(key, value)
31
+ end
32
+ file.close
33
+ file.path
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,25 @@
1
+ module Polytrix
2
+ module Runners
3
+ class WindowsChallengeRunner < ChallengeRunner
4
+ PS_OPTIONS = '-NoProfile -ExecutionPolicy Bypass'
5
+ def script_extension
6
+ 'ps1'
7
+ end
8
+
9
+ def challenge_command(env_file, challenge_script)
10
+ # I don't know a simple powershell replacement for &&
11
+ # See http://stackoverflow.com/questions/2416662/what-are-the-powershell-equivalent-of-bashs-and-operators
12
+ if File.exist? 'scripts/wrapper.ps1'
13
+ command = ". ./#{env_file}; ./scripts/wrapper.ps1 #{challenge_script}"
14
+ else
15
+ command = ". ./#{env_file}; ./#{challenge_script}"
16
+ end
17
+ "PowerShell #{PS_OPTIONS} -Command \"#{command}\""
18
+ end
19
+
20
+ def save_environment_variable(key, value)
21
+ "$Env:#{key}='#{value}'"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Polytrix
2
+ VERSION = '0.0.1'
3
+ end
data/lib/polytrix.rb ADDED
@@ -0,0 +1,56 @@
1
+ require 'polytrix/version'
2
+ require 'polytrix/manifest'
3
+ require 'polytrix/core/implementor'
4
+ require 'polytrix/core/result_tracker'
5
+ require 'polytrix/core/file_finder'
6
+ require 'polytrix/challenge_runner'
7
+ require 'polytrix/challenge'
8
+ require 'polytrix/challenge_builder'
9
+ require 'polytrix/configuration'
10
+ require 'polytrix/result'
11
+ require 'polytrix/documentation_generator'
12
+
13
+ require 'polytrix/rspec'
14
+
15
+ module Polytrix
16
+ class << self
17
+ attr_accessor :implementors
18
+ attr_accessor :manifest
19
+ attr_accessor :default_validator_callback
20
+
21
+ def default_validator_callback
22
+ @default_validator_callback ||= proc{ |challenge|
23
+ expect(challenge[:result].process.exitstatus).to eq(0)
24
+ }
25
+ end
26
+
27
+ def default_validator_callback=(callback)
28
+ @default_validator_callback = callback
29
+ end
30
+
31
+ def configuration
32
+ fail "configuration doesn't take a block, use configure" if block_given?
33
+ @configuration ||= Configuration.new
34
+ end
35
+
36
+ def configure
37
+ yield(configuration)
38
+ end
39
+
40
+ def sdk_dir(sdk)
41
+ "sdks/#{sdk}"
42
+ end
43
+
44
+ def load_manifest(yaml_file)
45
+ @manifest = Polytrix::Manifest.from_yaml yaml_file
46
+ end
47
+
48
+ def results
49
+ Polytrix::ResultTracker.instance
50
+ end
51
+
52
+ def run_tests
53
+ Polytrix::RSpec.run_manifest(@manifest)
54
+ end
55
+ end
56
+ end
data/packer/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ vendor/
2
+ Berksfile.lock
3
+ output-virtualbox/
data/packer/Berksfile ADDED
@@ -0,0 +1,15 @@
1
+ site :opscode
2
+
3
+ cookbook 'apt'
4
+ cookbook 'python'
5
+ cookbook 'rbenv'
6
+ cookbook 'golang'
7
+ cookbook 'nodejs'
8
+ cookbook 'php'
9
+ cookbook 'java'
10
+ cookbook 'groovy'
11
+ cookbook 'maven', git: 'git@github.com:soundcloud-cookbooks/maven.git'
12
+ cookbook 'dnsmasq', git: 'git://github.com/maxlinc/dnsmasq.git', branch: "hash_merge"
13
+ cookbook 'ssh_known_hosts'
14
+ cookbook 'users'
15
+ cookbook 'sudo'
data/packer/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # A sample Gemfile
2
+ source "https://rubygems.org"
3
+
4
+ gem "berkshelf"
5
+
@@ -0,0 +1,128 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
+ VAGRANTFILE_API_VERSION = "2"
6
+
7
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
+ # All Vagrant configuration is done here. The most common configuration
9
+ # options are documented and commented below. For a complete reference,
10
+ # please see the online documentation at vagrantup.com.
11
+
12
+ # Every Vagrant virtual environment requires a box to build off of.
13
+ config.vm.box = "saucy"
14
+
15
+ config.vm.provider :rackspace do |rs, override|
16
+ override.vm.box = "dummy"
17
+ override.ssh.private_key_path = '~/.ssh/id_rsa'
18
+ rs.public_key_path = '~/.ssh/id_rsa.pub'
19
+ rs.username = ENV['RAX_USERNAME']
20
+ rs.api_key = ENV['RAX_API_KEY']
21
+ rs.flavor = /512MB/
22
+ rs.image = "Ubuntu 13.10 (Saucy Salamander)"
23
+ end
24
+
25
+ # The url from where the 'config.vm.box' box will be fetched if it
26
+ # doesn't already exist on the user's system.
27
+ # config.vm.box_url = "http://domain.com/path/to/above.box"
28
+
29
+ # Create a forwarded port mapping which allows access to a specific port
30
+ # within the machine from a port on the host machine. In the example below,
31
+ # accessing "localhost:8080" will access port 80 on the guest machine.
32
+ # config.vm.network :forwarded_port, guest: 80, host: 8080
33
+
34
+ # Create a private network, which allows host-only access to the machine
35
+ # using a specific IP.
36
+ # config.vm.network :private_network, ip: "192.168.33.10"
37
+
38
+ # Create a public network, which generally matched to bridged network.
39
+ # Bridged networks make the machine appear as another physical device on
40
+ # your network.
41
+ # config.vm.network :public_network
42
+
43
+ # If true, then any SSH connections made will enable agent forwarding.
44
+ # Default value: false
45
+ # config.ssh.forward_agent = true
46
+
47
+ # Share an additional folder to the guest VM. The first argument is
48
+ # the path on the host to the actual folder. The second argument is
49
+ # the path on the guest to mount the folder. And the optional third
50
+ # argument is a set of non-required options.
51
+ # config.vm.synced_folder "../data", "/vagrant_data"
52
+
53
+ # Provider-specific configuration so you can fine-tune various
54
+ # backing providers for Vagrant. These expose provider-specific options.
55
+ # Example for VirtualBox:
56
+ #
57
+ # config.vm.provider :virtualbox do |vb|
58
+ # # Don't boot with headless mode
59
+ # vb.gui = true
60
+ #
61
+ # # Use VBoxManage to customize the VM. For example to change memory:
62
+ # vb.customize ["modifyvm", :id, "--memory", "1024"]
63
+ # end
64
+ #
65
+ # View the documentation for the provider you're using for more
66
+ # information on available options.
67
+
68
+ # Enable provisioning with Puppet stand alone. Puppet manifests
69
+ # are contained in a directory path relative to this Vagrantfile.
70
+ # You will need to create the manifests directory and a manifest in
71
+ # the file base.pp in the manifests_path directory.
72
+ #
73
+ # An example Puppet manifest to provision the message of the day:
74
+ #
75
+ # # group { "puppet":
76
+ # # ensure => "present",
77
+ # # }
78
+ # #
79
+ # # File { owner => 0, group => 0, mode => 0644 }
80
+ # #
81
+ # # file { '/etc/motd':
82
+ # # content => "Welcome to your Vagrant-built virtual machine!
83
+ # # Managed by Puppet.\n"
84
+ # # }
85
+ #
86
+ # config.vm.provision :puppet do |puppet|
87
+ # puppet.manifests_path = "manifests"
88
+ # puppet.manifest_file = "site.pp"
89
+ # end
90
+
91
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
92
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
93
+ # some recipes and/or roles.
94
+ #
95
+ config.vm.provision :chef_solo do |chef|
96
+ chef.cookbooks_path = ["cookbooks", "vendor/cookbooks"]
97
+ # chef.roles_path = "../my-recipes/roles"
98
+ # chef.data_bags_path = "../my-recipes/data_bags"
99
+ chef.add_recipe "drg"
100
+ # chef.add_role "web"
101
+ #
102
+ # # You may also specify custom JSON attributes:
103
+ # chef.json = { :mysql_password => "foo" }
104
+ end
105
+
106
+ # Enable provisioning with chef server, specifying the chef server URL,
107
+ # and the path to the validation key (relative to this Vagrantfile).
108
+ #
109
+ # The Opscode Platform uses HTTPS. Substitute your organization for
110
+ # ORGNAME in the URL and validation key.
111
+ #
112
+ # If you have your own Chef Server, use the appropriate URL, which may be
113
+ # HTTP instead of HTTPS depending on your configuration. Also change the
114
+ # validation key to validation.pem.
115
+ #
116
+ # config.vm.provision :chef_client do |chef|
117
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
118
+ # chef.validation_key_path = "ORGNAME-validator.pem"
119
+ # end
120
+ #
121
+ # If you're using the Opscode platform, your validator client is
122
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
123
+ #
124
+ # If you have your own Chef Server, the default validation client name is
125
+ # chef-validator, unless you changed the configuration.
126
+ #
127
+ # chef.validation_client_name = "ORGNAME-validator"
128
+ end
@@ -0,0 +1,27 @@
1
+ name "drg"
2
+ maintainer "Rackspace US, Inc"
3
+ maintainer_email "sdk-support@rackspace.com"
4
+ license "MIT"
5
+ description "Installs tools required for testing Rackspace SDKS."
6
+ version "0.0.1"
7
+
8
+ depends 'apt'
9
+ depends 'python'
10
+ depends 'rbenv'
11
+ depends 'golang'
12
+ depends 'nodejs'
13
+ depends 'php'
14
+ depends 'java'
15
+ depends 'groovy'
16
+ depends 'maven'
17
+ depends 'dnsmasq'
18
+ depends 'ssh_known_hosts'
19
+ depends 'users'
20
+ depends 'sudo'
21
+ depends 'mono'
22
+
23
+ recipe "drg", "Installs tools required for testing Rackspace SDKS."
24
+
25
+ %w{ ubuntu }.each do |os|
26
+ supports os
27
+ end
@@ -0,0 +1,22 @@
1
+ node.override['authorization']['sudo']['groups'] = ["sudo"]
2
+ node.override['authorization']['sudo']['passwordless'] = true
3
+ include_recipe 'sudo'
4
+
5
+ # Jenkins User... jenkins-jclouds plugin will setup the rest
6
+ user "jenkins" do
7
+ supports :manage_home => true
8
+ home '/jenkins'
9
+ end
10
+
11
+ group "sudo" do
12
+ action :modify
13
+ members ["jenkins"]
14
+ append true
15
+ end
16
+
17
+ # /etc/sudoers should be set for "sudo" instead of "wheel", but let's add them just in case
18
+ # group "wheel" do
19
+ # action :modify
20
+ # members ["jenkins"]
21
+ # append true
22
+ # end
@@ -0,0 +1,9 @@
1
+ include_recipe 'drg::system'
2
+ include_recipe 'drg::admins'
3
+ include_recipe 'python'
4
+ include_recipe 'drg::ruby'
5
+ include_recipe 'drg::golang'
6
+ include_recipe "nodejs::install_from_package"
7
+ include_recipe 'drg::php'
8
+ include_recipe 'drg::java'
9
+ include_recipe 'drg::dotnet'
@@ -0,0 +1,4 @@
1
+ # FIXME: May need to setup a PPA to get a more recent Mono
2
+ # FIXME: Microsoft.Build.dll was not shipped with current Ubuntu stable Mono, is in latest.
3
+ # FIXME: Need to automate `mozroots --import --sync` before Mono can fetch packages.
4
+ include_recipe 'mono'
@@ -0,0 +1,4 @@
1
+ node.override["go"]["version"] = "1.1.1"
2
+ node.override["go"]["filename"] = "go#{node["go"]["version"]}.#{node["os"]}-#{node["go"]["platform"]}.tar.gz"
3
+ node.override['go']['url'] = "http://go.googlecode.com/files/#{node["go"]["filename"]}"
4
+ include_recipe 'golang'
@@ -0,0 +1,5 @@
1
+ node.override['maven']['3']['version'] = '3.1.1'
2
+
3
+ include_recipe 'java'
4
+ include_recipe 'maven'
5
+ include_recipe 'groovy'
@@ -0,0 +1,10 @@
1
+ include_recipe 'php'
2
+ node.override['php']['directives'] = {
3
+ 'date.timezone' => 'GMT'
4
+ }
5
+
6
+ %w{php5-json php5-curl}.each do |pkg|
7
+ package pkg do
8
+ action :install
9
+ end
10
+ end
@@ -0,0 +1,29 @@
1
+ if node[:instance_role] == 'vagrant'
2
+ # Ideally would be group_users, but see https://github.com/RiotGames/rbenv-cookbook/issues/44
3
+ # node.override[:rbenv][:group_users] = ['vagrant']
4
+ node.override[:rbenv][:user] = 'vagrant'
5
+ else
6
+ node.override[:rbenv][:user] = 'jenkins'
7
+ end
8
+
9
+ include_recipe "rbenv::default"
10
+ include_recipe "rbenv::ruby_build"
11
+ include_recipe "rbenv::rbenv_vars"
12
+
13
+ global_ruby = "2.1.0"
14
+ other_rubies = ["1.9.3-p448", "2.0.0-p353"]
15
+
16
+ rbenv_ruby global_ruby do
17
+ ruby_version global_ruby
18
+ global true
19
+ end
20
+
21
+ other_rubies.each do |version|
22
+ rbenv_ruby version
23
+ end
24
+
25
+ other_rubies.push(global_ruby).each do |version|
26
+ rbenv_gem "bundler" do
27
+ ruby_version version
28
+ end
29
+ end
@@ -0,0 +1,13 @@
1
+ include_recipe 'apt'
2
+
3
+ ssh_known_hosts_entry 'github.com'
4
+
5
+ node.force_default[:dnsmasq][:dns] = {
6
+ # 'no-poll' => nil,
7
+ # 'no-resolv' => nil,
8
+ 'bind-interfaces' => nil,
9
+ 'server' => '127.0.0.1',
10
+ 'address' => '/dev/127.0.0.1'
11
+ }
12
+
13
+ include_recipe 'dnsmasq'
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ #export PACKER_LOG=1
6
+ rm packer_virtualbox_virtualbox.box || true
7
+ packer build -var-file ~/.rackspace-creds.json -only=virtualbox packer.json
8
+ vagrant box remove vagrant_machine || true
9
+ vagrant box add vagrant_machine packer_virtualbox_virtualbox.box
10
+