Browse files

fixed worker lifecycle yeti test

  • Loading branch information...
1 parent 6852697 commit 559544ee291dabd8275cc6b09ea890226898e6a4 Dmitriy Kalinin and Mark Rushakoff committed Mar 25, 2013
Showing with 63 additions and 51 deletions.
  1. +1 −1 assets
  2. +7 −6 config/assets.yml
  3. +41 −30 spec/apps/lifecycle_spec.rb
  4. +0 −14 spec/apps/ruby_spec.rb
  5. +3 −0 spec/spec_helper.rb
  6. +11 −0 spec/support/with_app.rb
2 assets
@@ -1 +1 @@
-Subproject commit d97c718fcbac86d7c8f63c8dceedae78e7bc5425
+Subproject commit 9d88f7f0e3db1be5d2d5846fbfeb7b94ee988182
View
13 config/assets.yml
@@ -73,6 +73,13 @@ rails3:
path: "assets/ruby/rails3"
command: "bundle exec rake db:migrate --trace && bundle exec rails server thin -p $PORT"
+# Lifecycle apps:
+worker:
+ memory: 512
+ path: "assets/lifecycle/worker"
+ command: "bundle exec ruby main.rb"
+ no_url: true
+
#-
sinatra_gem_groups:
memory: 512
@@ -324,12 +331,6 @@ standalone_simple_ruby_app:
path: "assets/standalone/simple_ruby_app"
no_url: true
-standalone_simple_ruby19_app:
- command: "ruby simple.rb"
- memory: 512
- path: "assets/standalone/simple_ruby_app"
- no_url: true
-
standalone_java_app:
command: "bin/hello-cloud"
memory: 512
View
71 spec/apps/lifecycle_spec.rb
@@ -2,43 +2,54 @@
require "spec_helper"
include BVT::Spec
-describe "Simple::Lifecycle" do
+describe "App lifecycle" do
before(:all) { @session = BVT::Harness::CFSession.new }
- after(:each) do
- show_crashlogs
- @session.cleanup!
- end
+ describe "app serving web requests" do
+ after(:each) do
+ show_crashlogs
+ @session.cleanup!
+ end
- it "create/start/stop/delete application" do
- # create app
- app = create_push_app("simple_app2")
- app.should_not == nil
+ it "create/start/stop/delete application" do
+ # create app
+ app = create_push_app("simple_app2")
+ app.should_not == nil
- # start app
- app.start
- hash_all = app.stats["0"]
- hash_all[:state].should == "RUNNING"
+ # start app
+ app.start
+ hash_all = app.stats["0"]
+ hash_all[:state].should == "RUNNING"
- # stop app
- app.stop
- app.stats == {}
+ # stop app
+ app.stop
+ app.stats == {}
- # delete app
- len = @session.apps.length
- app.delete
- @session.apps.length.should == len - 1
+ # delete app
+ len = @session.apps.length
+ app.delete
+ @session.apps.length.should == len - 1
+ end
end
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- # reconsider how to tes
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- it "is able to run an app that does not bind to ports" do
- app = create_push_app("standalone_simple_ruby_app")
- app.logs =~ /running version/
+ describe "app acting as a background worker (no bound uris)" do
+ with_app "worker"
+
+ def check_logs(app, match)
+ logs = nil
+ 15.times do
+ logs = app.logs
+ return if logs.include?(match)
+ sleep(2)
+ end
+ raise "Could not find '#{match}' in '#{logs}'"
+ end
+
+ it "continues to run" do
+ check_logs(app, "running for 5 secs")
+ check_logs(app, "running for 10 secs")
+ check_logs(app, "running for 15 secs")
+ check_logs(app, "running for 20 secs")
+ end
end
end
View
14 spec/apps/ruby_spec.rb
@@ -5,12 +5,6 @@
describe "Ruby" do
before(:all) { @session = BVT::Harness::CFSession.new }
- def self.with_app(app_asset_name)
- before(:all) { @app = create_push_app(app_asset_name) }
- after(:all) { @session.cleanup! }
- define_method(:app) { @app }
- end
-
describe "ruby 1.8" do
with_app "ruby18"
@@ -61,12 +55,4 @@ def self.with_app(app_asset_name)
res.to_str.should == "ok"
end
end
-
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- # crashlogs
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!=
end
View
3 spec/spec_helper.rb
@@ -65,17 +65,20 @@ def show_crashlogs
RSpec.configure do |config|
include BVT::Harness::ColorHelpers
+
config.before(:suite) do
target = BVT::Harness::RakeHelper.get_target
target_without_http = target.split('//')[-1]
config = BVT::Harness::RakeHelper.get_config
profile_file = File.join(BVT::Harness::VCAP_BVT_HOME, "profile.#{target_without_http}.yml")
+
unless File.exists? profile_file
BVT::Harness::RakeHelper.get_user
BVT::Harness::RakeHelper.get_user_passwd
user = BVT::Harness::RakeHelper.get_config['user']
BVT::Harness::RakeHelper.check_environment(user)
end
+
$vcap_bvt_profile_file ||= profile_file
profile = YAML.load_file($vcap_bvt_profile_file)
BVT::Harness::VCAP_BVT_SYSTEM_SERVICES = profile[:services]
View
11 spec/support/with_app.rb
@@ -0,0 +1,11 @@
+module WithAppHelper
+ def with_app(app_asset_name, opts={})
+ before(:all) { @app = create_push_app(app_asset_name) }
+ after(:all) { @session.cleanup! } unless opts[:debug]
+ define_method(:app) { @app }
+ end
+end
+
+RSpec.configure do |config|
+ config.extend(WithAppHelper)
+end

0 comments on commit 559544e

Please sign in to comment.