cf 5.0.0.rc1 → 5.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/lib/admin/plugin.rb +1 -0
  2. data/lib/admin/service_broker/add.rb +46 -0
  3. data/lib/cf/cli.rb +8 -3
  4. data/lib/cf/cli/service/create.rb +68 -20
  5. data/lib/cf/cli/service/delete.rb +1 -1
  6. data/lib/cf/cli/service/service_instance_helper.rb +99 -0
  7. data/lib/cf/cli/service/services.rb +12 -32
  8. data/lib/cf/cli/start/target.rb +1 -1
  9. data/lib/cf/version.rb +1 -1
  10. data/lib/manifests/manifests.rb +41 -25
  11. data/lib/tasks/gem_release.rake +1 -1
  12. data/spec/admin/service_broker/add_spec.rb +59 -0
  13. data/spec/assets/env/Gemfile +4 -0
  14. data/spec/assets/env/Gemfile.lock +20 -0
  15. data/spec/assets/env/env_test.rb +58 -0
  16. data/spec/cf/cli/app/delete_spec.rb +2 -2
  17. data/spec/cf/cli/app/push/create_spec.rb +1 -1
  18. data/spec/cf/cli/service/create_spec.rb +51 -4
  19. data/spec/cf/cli/service/rename_spec.rb +1 -1
  20. data/spec/cf/cli/service/service_instance_helper_spec.rb +155 -0
  21. data/spec/cf/cli/service/services_spec.rb +63 -34
  22. data/spec/cf/cli/space/space_spec.rb +1 -1
  23. data/spec/cf/cli/space/spaces_spec.rb +3 -3
  24. data/spec/factories/cfoundry/v2/{service_instances_factory.rb → managed_service_instances_factory.rb} +2 -2
  25. data/spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb +12 -0
  26. data/spec/features/delete_orphaned_service_spec.rb +64 -0
  27. data/spec/features/manifests_spec.rb +86 -0
  28. data/spec/features/org_spec.rb +4 -4
  29. data/spec/{integration → features}/push_flow_spec.rb +27 -3
  30. data/spec/features/services_spec.rb +96 -0
  31. data/spec/integration/service_broker_spec.rb +49 -0
  32. data/spec/manifests/manifests_spec.rb +46 -25
  33. data/spec/spec_helper.rb +7 -1
  34. data/spec/support/features_helper.rb +36 -3
  35. data/spec/support/matchers.rb +14 -3
  36. metadata +109 -9
@@ -65,13 +65,29 @@ describe CFManifests do
65
65
  :service_binding,
66
66
  :service_instance =>
67
67
  build(
68
- :service_instance,
68
+ :managed_service_instance,
69
69
  :name => "service-1",
70
70
  :service_plan =>
71
71
  build(
72
72
  :service_plan,
73
73
  :name => "P200",
74
- :service => build(:service))))
74
+ :service => build(:service,
75
+ label: "managed",
76
+ provider: "hamazon",
77
+ version: "v3"
78
+ )
79
+ )
80
+ )
81
+ ),
82
+ build(
83
+ :service_binding,
84
+ :service_instance =>
85
+ build(
86
+ :user_provided_service_instance,
87
+ :name => "service-2",
88
+ :credentials => { uri: "mysql://example.com" }
89
+ )
90
+ )
75
91
  ]
76
92
  end
77
93
 
@@ -87,28 +103,18 @@ describe CFManifests do
87
103
  its(["buildpack"]) { should eq "git://example.com/foo.git" }
88
104
 
89
105
  it "contains the service information" do
90
- expect(subject["services"]).to be_a Hash
91
-
92
- services = subject["services"]
93
- app.service_bindings.each do |b|
94
- service = b.service_instance
95
-
96
- expect(services).to include service.name
97
-
98
- info = services[service.name]
99
-
100
- plan = service.service_plan
101
- offering = plan.service
102
-
103
- {"plan" => plan.name,
104
- "label" => offering.label,
105
- "provider" => offering.provider,
106
- "version" => offering.version
107
- }.each do |attr, val|
108
- expect(info).to include attr
109
- expect(info[attr]).to eq val
110
- end
111
- end
106
+ expect(subject["services"]).to eq(
107
+ "service-1" => {
108
+ "plan" => "P200",
109
+ "label" => "managed",
110
+ "provider" => "hamazon",
111
+ "version" => "v3",
112
+ },
113
+ "service-2" => {
114
+ "credentials" => {"uri" => "mysql://example.com"},
115
+ "label" => "user-provided"
116
+ },
117
+ )
112
118
  end
113
119
 
114
120
  context "with only minimum configuration" do
@@ -135,12 +141,27 @@ describe CFManifests do
135
141
  dont_allow_ask(anything, anything)
136
142
  end
137
143
 
144
+ context "when user-provided services are defined in the manifest" do
145
+ let(:client) do
146
+ build(:client).tap { |client| client.stub(:services => [], :service_instances => []) }
147
+ end
148
+
149
+ let(:info) { {:services => {'moracle' => {:label => "user-provided", :credentials =>{"k" => "v"}}}}}
150
+
151
+ it "creates the service with label user-provided" do
152
+ cmd.should_receive(:invoke).with(:create_service,
153
+ :name => 'moracle', :offering => has_label("user-provided"), :app => app, :credentials => {"k" => "v"}
154
+ )
155
+ cmd.send("setup_services", app, info)
156
+ end
157
+ end
158
+
138
159
  context "when services are defined in the manifest" do
139
160
  let(:info) do
140
161
  {:services => {"service-1" => {:label => "mysql", :plan => "100"}}}
141
162
  end
142
163
 
143
- let(:service_1) { build(:service_instance, :name => "service-1") }
164
+ let(:service_1) { build(:managed_service_instance, :name => "service-1") }
144
165
  let(:plan_100) { build :service_plan, :name => "100" }
145
166
 
146
167
  let(:mysql) do
data/spec/spec_helper.rb CHANGED
@@ -10,6 +10,7 @@ require "webmock/rspec"
10
10
  require "ostruct"
11
11
  require "fakefs/safe"
12
12
  require "blue-shell"
13
+ require_relative '../vendor/integration-test-support/support/integration_example_group.rb'
13
14
 
14
15
  TRAVIS_BUILD_ID = ENV["TRAVIS_BUILD_ID"]
15
16
 
@@ -29,6 +30,10 @@ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |file|
29
30
  require file
30
31
  end
31
32
 
33
+ tmp_dir = File.expand_path('../tmp', File.dirname(__FILE__))
34
+ FileUtils.mkdir_p(tmp_dir)
35
+ IntegrationExampleGroup.tmp_dir = tmp_dir
36
+
32
37
  RSpec.configure do |c|
33
38
  c.include BlueShell::Matchers
34
39
 
@@ -41,9 +46,10 @@ RSpec.configure do |c|
41
46
  c.include InteractHelper
42
47
  c.include ConfigHelper
43
48
  c.include FeaturesHelper
49
+ c.include IntegrationExampleGroup, type: :integration, :example_group => {:file_path => /\/integration\//}
44
50
 
45
51
  c.before(:all) do
46
- WebMock.disable_net_connect!
52
+ WebMock.disable_net_connect!(:allow_localhost => true)
47
53
  end
48
54
 
49
55
  c.before do
@@ -28,9 +28,40 @@ module FeaturesHelper
28
28
  end
29
29
  end
30
30
 
31
- def push_app(app_folder, deployed_app_name)
31
+ def create_service_instance(service_name, instance_name, opts = {})
32
+ plan_name = opts[:plan]
33
+ credentials = opts[:credentials]
34
+
35
+ BlueShell::Runner.run("#{cf_bin} create-service") do |runner|
36
+ expect(runner).to say "What kind?>"
37
+ runner.send_keys service_name
38
+
39
+ expect(runner).to say "Name?>"
40
+ runner.send_keys instance_name
41
+
42
+ if service_name == "user-provided"
43
+ expect(runner).to say "What credential parameters should applications use to connect to this service instance?\n(e.g. hostname, port, password)>"
44
+ runner.send_keys credentials.keys.join(", ")
45
+
46
+ credentials.each do |key, value|
47
+ expect(runner).to say key.to_s
48
+ runner.send_keys value.to_s
49
+ end
50
+ else
51
+ expect(runner).to say "Which plan?"
52
+ runner.send_keys plan_name
53
+ end
54
+
55
+ expect(runner).to say "Creating service #{instance_name}... OK"
56
+ end
57
+ end
58
+
59
+ def push_app(app_folder, deployed_app_name, opts = {})
60
+ push_cmd = "#{cf_bin} push --no-manifest"
61
+ push_cmd += " --command #{opts[:start_command]}" if opts[:start_command]
62
+
32
63
  Dir.chdir("#{SPEC_ROOT}/assets/#{app_folder}") do
33
- BlueShell::Runner.run("#{cf_bin} push --no-manifest") do |runner|
64
+ BlueShell::Runner.run(push_cmd) do |runner|
34
65
  expect(runner).to say "Name>"
35
66
  runner.send_keys deployed_app_name
36
67
 
@@ -59,7 +90,9 @@ module FeaturesHelper
59
90
  runner.send_return
60
91
  end
61
92
 
62
- runner.wait_for_exit
93
+ expect(runner).to say "Push successful!"
94
+
95
+ runner.wait_for_exit opts[:timeout] || 30
63
96
  end
64
97
  end
65
98
  end
@@ -1,5 +1,16 @@
1
- RSpec::Matchers.define :has_label do |expected|
2
- match do |actual|
3
- actual.label == expected
1
+ class HasLabelMatcher
2
+ def initialize(expected_label)
3
+ @expected = expected_label
4
4
  end
5
+ def failure_message_for_should
6
+ "#{actual} does not have label #{@expected}"
7
+ end
8
+ def ==(actual)
9
+ actual.label == @expected
10
+ end
11
+ alias_method :matches?, :==
12
+ end
13
+
14
+ def has_label(expected_label)
15
+ HasLabelMatcher.new(expected_label)
5
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.rc1
4
+ version: 5.0.0.rc3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-05 00:00:00.000000000 Z
13
+ date: 2013-08-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -51,7 +51,7 @@ dependencies:
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 4.0.3
54
+ version: 4.2.0.rc
55
55
  type: :runtime
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  requirements:
60
60
  - - ~>
61
61
  - !ruby/object:Gem::Version
62
- version: 4.0.3
62
+ version: 4.2.0.rc
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: interact
65
65
  requirement: !ruby/object:Gem::Requirement
@@ -306,6 +306,86 @@ dependencies:
306
306
  - - ~>
307
307
  - !ruby/object:Gem::Version
308
308
  version: '1.9'
309
+ - !ruby/object:Gem::Dependency
310
+ name: httpclient
311
+ requirement: !ruby/object:Gem::Requirement
312
+ none: false
313
+ requirements:
314
+ - - ~>
315
+ - !ruby/object:Gem::Version
316
+ version: '2.3'
317
+ type: :development
318
+ prerelease: false
319
+ version_requirements: !ruby/object:Gem::Requirement
320
+ none: false
321
+ requirements:
322
+ - - ~>
323
+ - !ruby/object:Gem::Version
324
+ version: '2.3'
325
+ - !ruby/object:Gem::Dependency
326
+ name: yajl-ruby
327
+ requirement: !ruby/object:Gem::Requirement
328
+ none: false
329
+ requirements:
330
+ - - ! '>='
331
+ - !ruby/object:Gem::Version
332
+ version: '0'
333
+ type: :development
334
+ prerelease: false
335
+ version_requirements: !ruby/object:Gem::Requirement
336
+ none: false
337
+ requirements:
338
+ - - ! '>='
339
+ - !ruby/object:Gem::Version
340
+ version: '0'
341
+ - !ruby/object:Gem::Dependency
342
+ name: nats
343
+ requirement: !ruby/object:Gem::Requirement
344
+ none: false
345
+ requirements:
346
+ - - ! '>='
347
+ - !ruby/object:Gem::Version
348
+ version: '0'
349
+ type: :development
350
+ prerelease: false
351
+ version_requirements: !ruby/object:Gem::Requirement
352
+ none: false
353
+ requirements:
354
+ - - ! '>='
355
+ - !ruby/object:Gem::Version
356
+ version: '0'
357
+ - !ruby/object:Gem::Dependency
358
+ name: typhoeus
359
+ requirement: !ruby/object:Gem::Requirement
360
+ none: false
361
+ requirements:
362
+ - - ! '>='
363
+ - !ruby/object:Gem::Version
364
+ version: '0'
365
+ type: :development
366
+ prerelease: false
367
+ version_requirements: !ruby/object:Gem::Requirement
368
+ none: false
369
+ requirements:
370
+ - - ! '>='
371
+ - !ruby/object:Gem::Version
372
+ version: '0'
373
+ - !ruby/object:Gem::Dependency
374
+ name: anchorman
375
+ requirement: !ruby/object:Gem::Requirement
376
+ none: false
377
+ requirements:
378
+ - - ! '>='
379
+ - !ruby/object:Gem::Version
380
+ version: '0'
381
+ type: :development
382
+ prerelease: false
383
+ version_requirements: !ruby/object:Gem::Requirement
384
+ none: false
385
+ requirements:
386
+ - - ! '>='
387
+ - !ruby/object:Gem::Version
388
+ version: '0'
309
389
  description:
310
390
  email:
311
391
  - vcap-dev@googlegroups.com
@@ -321,6 +401,7 @@ files:
321
401
  - lib/admin/plugin.rb
322
402
  - lib/admin/README.md
323
403
  - lib/admin/service_auth_token.rb
404
+ - lib/admin/service_broker/add.rb
324
405
  - lib/admin/set_quota.rb
325
406
  - lib/cf/cli/app/app.rb
326
407
  - lib/cf/cli/app/apps.rb
@@ -372,6 +453,7 @@ files:
372
453
  - lib/cf/cli/service/delete.rb
373
454
  - lib/cf/cli/service/rename.rb
374
455
  - lib/cf/cli/service/service.rb
456
+ - lib/cf/cli/service/service_instance_helper.rb
375
457
  - lib/cf/cli/service/services.rb
376
458
  - lib/cf/cli/service/unbind.rb
377
459
  - lib/cf/cli/space/base.rb
@@ -433,7 +515,11 @@ files:
433
515
  - lib/tunnel/tunnel.rb
434
516
  - spec/admin/curl_spec.rb
435
517
  - spec/admin/guid_spec.rb
518
+ - spec/admin/service_broker/add_spec.rb
436
519
  - spec/admin/set_quota_spec.rb
520
+ - spec/assets/env/env_test.rb
521
+ - spec/assets/env/Gemfile
522
+ - spec/assets/env/Gemfile.lock
437
523
  - spec/assets/hello-sinatra/config.ru
438
524
  - spec/assets/hello-sinatra/fat-cat-makes-app-larger.png
439
525
  - spec/assets/hello-sinatra/Gemfile
@@ -520,6 +606,7 @@ files:
520
606
  - spec/cf/cli/service/delete_spec.rb
521
607
  - spec/cf/cli/service/help_spec.rb
522
608
  - spec/cf/cli/service/rename_spec.rb
609
+ - spec/cf/cli/service/service_instance_helper_spec.rb
523
610
  - spec/cf/cli/service/service_spec.rb
524
611
  - spec/cf/cli/service/services_spec.rb
525
612
  - spec/cf/cli/service/unbind_spec.rb
@@ -546,24 +633,28 @@ files:
546
633
  - spec/factories/cfoundry/v2/apps_factory.rb
547
634
  - spec/factories/cfoundry/v2/clients_factory.rb
548
635
  - spec/factories/cfoundry/v2/domains_factory.rb
636
+ - spec/factories/cfoundry/v2/managed_service_instances_factory.rb
549
637
  - spec/factories/cfoundry/v2/organizations_factory.rb
550
638
  - spec/factories/cfoundry/v2/quota_definitions.rb
551
639
  - spec/factories/cfoundry/v2/routes_factory.rb
552
640
  - spec/factories/cfoundry/v2/service_bindings_factory.rb
553
- - spec/factories/cfoundry/v2/service_instances_factory.rb
554
641
  - spec/factories/cfoundry/v2/service_plans_factory.rb
555
642
  - spec/factories/cfoundry/v2/services_factory.rb
556
643
  - spec/factories/cfoundry/v2/spaces_factory.rb
557
644
  - spec/factories/cfoundry/v2/stacks_factory.rb
645
+ - spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb
558
646
  - spec/factories/cfoundry/v2/users_factory.rb
559
647
  - spec/features/account_lifecycle_spec.rb
560
648
  - spec/features/create_user_spec.rb
649
+ - spec/features/delete_orphaned_service_spec.rb
561
650
  - spec/features/login_spec.rb
651
+ - spec/features/manifests_spec.rb
562
652
  - spec/features/org_spec.rb
653
+ - spec/features/push_flow_spec.rb
563
654
  - spec/features/services_spec.rb
564
655
  - spec/features/space_spec.rb
565
656
  - spec/features/switching_targets_spec.rb
566
- - spec/integration/push_flow_spec.rb
657
+ - spec/integration/service_broker_spec.rb
567
658
  - spec/manifests/errors_spec.rb
568
659
  - spec/manifests/loader/builder_spec.rb
569
660
  - spec/manifests/loader/normalizer_spec.rb
@@ -598,7 +689,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
598
689
  version: '0'
599
690
  segments:
600
691
  - 0
601
- hash: -3163619912203413768
692
+ hash: 4338688848602713526
602
693
  required_rubygems_version: !ruby/object:Gem::Requirement
603
694
  none: false
604
695
  requirements:
@@ -614,7 +705,11 @@ summary: Friendly command-line interface for Cloud Foundry.
614
705
  test_files:
615
706
  - spec/admin/curl_spec.rb
616
707
  - spec/admin/guid_spec.rb
708
+ - spec/admin/service_broker/add_spec.rb
617
709
  - spec/admin/set_quota_spec.rb
710
+ - spec/assets/env/env_test.rb
711
+ - spec/assets/env/Gemfile
712
+ - spec/assets/env/Gemfile.lock
618
713
  - spec/assets/hello-sinatra/config.ru
619
714
  - spec/assets/hello-sinatra/fat-cat-makes-app-larger.png
620
715
  - spec/assets/hello-sinatra/Gemfile
@@ -701,6 +796,7 @@ test_files:
701
796
  - spec/cf/cli/service/delete_spec.rb
702
797
  - spec/cf/cli/service/help_spec.rb
703
798
  - spec/cf/cli/service/rename_spec.rb
799
+ - spec/cf/cli/service/service_instance_helper_spec.rb
704
800
  - spec/cf/cli/service/service_spec.rb
705
801
  - spec/cf/cli/service/services_spec.rb
706
802
  - spec/cf/cli/service/unbind_spec.rb
@@ -727,24 +823,28 @@ test_files:
727
823
  - spec/factories/cfoundry/v2/apps_factory.rb
728
824
  - spec/factories/cfoundry/v2/clients_factory.rb
729
825
  - spec/factories/cfoundry/v2/domains_factory.rb
826
+ - spec/factories/cfoundry/v2/managed_service_instances_factory.rb
730
827
  - spec/factories/cfoundry/v2/organizations_factory.rb
731
828
  - spec/factories/cfoundry/v2/quota_definitions.rb
732
829
  - spec/factories/cfoundry/v2/routes_factory.rb
733
830
  - spec/factories/cfoundry/v2/service_bindings_factory.rb
734
- - spec/factories/cfoundry/v2/service_instances_factory.rb
735
831
  - spec/factories/cfoundry/v2/service_plans_factory.rb
736
832
  - spec/factories/cfoundry/v2/services_factory.rb
737
833
  - spec/factories/cfoundry/v2/spaces_factory.rb
738
834
  - spec/factories/cfoundry/v2/stacks_factory.rb
835
+ - spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb
739
836
  - spec/factories/cfoundry/v2/users_factory.rb
740
837
  - spec/features/account_lifecycle_spec.rb
741
838
  - spec/features/create_user_spec.rb
839
+ - spec/features/delete_orphaned_service_spec.rb
742
840
  - spec/features/login_spec.rb
841
+ - spec/features/manifests_spec.rb
743
842
  - spec/features/org_spec.rb
843
+ - spec/features/push_flow_spec.rb
744
844
  - spec/features/services_spec.rb
745
845
  - spec/features/space_spec.rb
746
846
  - spec/features/switching_targets_spec.rb
747
- - spec/integration/push_flow_spec.rb
847
+ - spec/integration/service_broker_spec.rb
748
848
  - spec/manifests/errors_spec.rb
749
849
  - spec/manifests/loader/builder_spec.rb
750
850
  - spec/manifests/loader/normalizer_spec.rb