Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add rails console case using old vmc client

Change-Id: I409867d093188bf61b50508842414253567643b1
Signed-off-by: michael zhang <zhangcheng@rbcon.com>
Reviewed-on: http://reviews.cloudfoundry.org/6929
Tested-by: CI Master <cf-ci@rbcon.com>
Reviewed-by: Pin Xie <pxie@vmware.com>
  • Loading branch information...
commit ee374b106a9f84aa54c8684fd0979179e4473c37 1 parent 875f5bc
michael zhang authored
View
2  Gemfile
@@ -11,6 +11,8 @@ gem "bson_ext"
gem "yajl-ruby"
gem "nokogiri"
gem "fuubar"
+gem "vmc"
+gem "cli"
gem "progressbar", "~> 0.11.0"
group :ci do
View
16 Gemfile.lock
@@ -1,6 +1,7 @@
GEM
remote: http://rubygems.org/
specs:
+ addressable (2.2.8)
bson (1.6.2)
bson_ext (1.6.2)
bson (~> 1.6.2)
@@ -11,6 +12,7 @@ GEM
rubyzip (~> 0.9.5)
ci_reporter (1.6.4)
builder (>= 2.1.2)
+ cli (1.1.1)
curb (0.8.0)
diff-lcs (1.1.3)
fuubar (1.0.0)
@@ -25,6 +27,7 @@ GEM
nokogiri (1.5.2)
progressbar (0.11.0)
rake (0.9.2.2)
+ rb-readline (0.4.2)
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (2.10.0)
@@ -38,8 +41,19 @@ GEM
rspec-mocks (2.10.1)
ruby-progressbar (0.0.10)
rubyzip (0.9.8)
+ terminal-table (1.4.5)
+ uuidtools (2.1.2)
vcap_logging (1.0.0)
rake
+ vmc (0.3.18)
+ addressable (~> 2.2.6)
+ interact (~> 0.4.0)
+ json_pure (< 1.7.0, >= 1.5.1)
+ rb-readline (~> 0.4.2)
+ rest-client (< 1.7.0, >= 1.6.1)
+ rubyzip (~> 0.9.4)
+ terminal-table (~> 1.4.2)
+ uuidtools (~> 2.1.0)
yajl-ruby (1.1.0)
PLATFORMS
@@ -49,6 +63,7 @@ DEPENDENCIES
bson_ext
cfoundry (~> 0.2.0)
ci_reporter
+ cli
curb
fuubar
interact
@@ -58,4 +73,5 @@ DEPENDENCIES
rake
rspec
vcap_logging (>= 1.0)
+ vmc
yajl-ruby
View
7 config/assets.yml
@@ -388,9 +388,16 @@ java_app_with_startup_delay:
rails_console_test_app:
framework: "rails3"
+ runtime: "ruby18"
memory: 256
path: "assets/rails3/app_rails_service"
+rails_console_19_test_app:
+ framework: "rails3"
+ runtime: "ruby19"
+ memory: 256
+ path: "assets/rails3/hello_vcap"
+
vblob_app:
framework: "sinatra"
runtime: "ruby19"
View
145 spec/simple/rails_console/ruby18_rails3_spec.rb
@@ -0,0 +1,145 @@
+require "harness"
+require "spec_helper"
+require "vmc"
+require "cli"
+
+describe BVT::Spec::Simple::RailsConsole::Ruby18Rails3 do
+ include BVT::Spec, BVT::Harness
+
+ before(:all) do
+ @session = BVT::Harness::CFSession.new
+ @client = VMC::Client.new(@session.TARGET)
+ @token = @client.login(@session.email, @session.passwd)
+ @console_cmd = VMC::Cli::Command::Apps.new
+ @console_cmd.client(@client)
+ end
+
+ after(:each) do
+ @session.cleanup!
+ end
+
+ def run_console(appname)
+ #Console may not be available immediately after app start
+ #if system is under heavy load. Try a few times.
+ 3.times do
+ begin
+ local_console_port = @console_cmd.console appname, false
+ creds = @console_cmd.console_credentials appname
+ prompt = @console_cmd.console_login(creds, local_console_port)
+ @console_response = [prompt]
+ break
+ rescue VMC::Cli::CliExit
+ sleep 1
+ end
+ end
+ end
+
+ it "rails test console", :p1 => true do
+ app = create_push_app("rails_console_test_app")
+ manifest = {}
+ manifest["console"] = true
+ app.update!(manifest)
+
+ @console_cmd.restart(app.name)
+
+ run_console(app.name)
+
+ expected_results = ["irb():001:0> "]
+ expected_results.should == @console_response
+
+ @console_response = @console_cmd.send_console_command("app.class")
+ expected_results = ("app.class,=> ActionDispatch::Integration::Session,irb" +
+ "():002:0> ").split(",")
+ expected_results.should == @console_response
+
+ @console_cmd.close_console if @console_cmd
+ end
+
+ it "rails test console tab completion" do
+ app = create_push_app("rails_console_test_app")
+ manifest = {}
+ manifest["console"] = true
+ app.update!(manifest)
+
+ @console_cmd.restart(app.name)
+
+ run_console(app.name)
+
+ expected_results = ["irb():001:0> "]
+ expected_results.should == @console_response
+
+ @console_cmd.console_tab_completion_data("puts")
+ @console_tab_response = @console_cmd.console_tab_completion_data("puts")
+ expected_results = ["puts"]
+ expected_results.should == @console_tab_response
+
+ @console_cmd.close_console if @console_cmd
+ end
+
+ it "rails test console stdout redirect" do
+ app = create_push_app("rails_console_test_app")
+ manifest = {}
+ manifest["console"] = true
+ app.update!(manifest)
+
+ @console_cmd.restart(app.name)
+
+ run_console(app.name)
+
+ expected_results = ["irb():001:0> "]
+ expected_results.should == @console_response
+
+ @console_response = @console_cmd.send_console_command("puts 'hi'")
+ expected_results = ("puts 'hi',hi,=> nil,irb():002:0> ").split(",")
+ expected_results.should == @console_response
+
+ @console_cmd.close_console if @console_cmd
+ end
+
+ it "rails test console rake tasks" do
+ app = create_push_app("rails_console_test_app")
+ manifest = {}
+ manifest["console"] = true
+ app.update!(manifest)
+
+ @console_cmd.restart(app.name)
+
+ run_console(app.name)
+
+ expected_results = ["irb():001:0> "]
+ expected_results.should == @console_response
+
+ @console_response = @console_cmd.send_console_command("`rake routes`")
+ matched = false
+ @console_response.each do |response|
+ matched = true if response=~ /#{Regexp.escape(':action=>\"hello\"')}/
+ end
+ matched.should == true
+
+ @console_cmd.close_console if @console_cmd
+ end
+
+ it "Rails Console runs tasks with correct ruby 1.8 version in path" do
+ app = create_push_app("rails_console_test_app")
+ manifest = {}
+ manifest["console"] = true
+ app.update!(manifest)
+
+ @console_cmd.restart(app.name)
+
+ run_console(app.name)
+
+ expected_results = ["irb():001:0> "]
+ expected_results.should == @console_response
+
+ @console_response = @console_cmd.send_console_command("`ruby --version`")
+ matched = false
+ @console_response.each do |response|
+ matched = true if response=~ /#{Regexp.escape("ruby 1.8")}/
+ end
+ matched.should == true
+
+ @console_cmd.close_console if @console_cmd
+ end
+
+end
View
82 spec/simple/rails_console/ruby19_rails3_spec.rb
@@ -0,0 +1,82 @@
+require "harness"
+require "spec_helper"
+require "vmc"
+require "cli"
+
+describe BVT::Spec::Simple::RailsConsole::Ruby19Rails3 do
+ include BVT::Spec, BVT::Harness
+
+ before(:all) do
+ @session = BVT::Harness::CFSession.new
+ @client = VMC::Client.new(@session.TARGET)
+ @token = @client.login(@session.email, @session.passwd)
+ @console_cmd = VMC::Cli::Command::Apps.new
+ @console_cmd.client(@client)
+ end
+
+ after(:each) do
+ @session.cleanup!
+ end
+
+ def run_console(appname)
+ #Console may not be available immediately after app start
+ #if system is under heavy load. Try a few times.
+ 3.times do
+ begin
+ local_console_port = @console_cmd.console appname, false
+ creds = @console_cmd.console_credentials appname
+ prompt = @console_cmd.console_login(creds, local_console_port)
+ @console_response = [prompt]
+ break
+ rescue VMC::Cli::CliExit
+ sleep 1
+ end
+ end
+ end
+
+ it "rails test console rake tasks with ruby 1.9" do
+ app = create_push_app("rails_console_19_test_app")
+ manifest = {}
+ manifest["console"] = true
+ app.update!(manifest)
+
+ @console_cmd.restart(app.name)
+
+ run_console(app.name)
+
+ expected_results = ["irb():001:0> "]
+ expected_results.should == @console_response
+
+ @console_response = @console_cmd.send_console_command("`rake routes`")
+ matched = false
+ @console_response.each do |response|
+ matched = true if response=~ /#{Regexp.escape(':action=>\"index\"')}/
+ end
+ matched.should == true
+
+ @console_cmd.close_console if @console_cmd
+ end
+
+ it "Rails Console runs tasks with correct ruby 1.9 version in path", :p1 => true do
+ app = create_push_app("rails_console_19_test_app")
+ manifest = {}
+ manifest["console"] = true
+ app.update!(manifest)
+
+ @console_cmd.restart(app.name)
+
+ run_console(app.name)
+
+ expected_results = ["irb():001:0> "]
+ expected_results.should == @console_response
+
+ @console_response = @console_cmd.send_console_command("`ruby --version`")
+ matched = false
+ @console_response.each do |response|
+ matched = true if response=~ /#{Regexp.escape("ruby 1.9")}/
+ end
+ matched.should == true
+
+ @console_cmd.close_console if @console_cmd
+ end
+end
View
5 spec/spec_helper.rb
@@ -95,6 +95,11 @@ class Ruby19Sinatra; end
module FileRange
class Ruby19Sinatra; end
end
+
+ module RailsConsole
+ class Ruby18Rails3; end
+ class Ruby19Rails3; end
+ end
end
MYSQL_MANIFEST = {"vendor"=>"mysql", "version"=>"5.1"}
Please sign in to comment.
Something went wrong with that request. Please try again.