Permalink
Browse files

Add BVT for elasticsearch as a service

Change-Id: If9e1713ded5d8bd60ae618defa67e7bfd834a0e8
  • Loading branch information...
frhwang committed Jun 12, 2012
1 parent ac00cc4 commit c3bdcf5184acc3daf1d2087816bd734474e3a8ed
@@ -0,0 +1,13 @@
+Feature: elasticsearch service binding and app deployment
+
+ In order to use elasticsearch service in cloud foundry
+ As the VMC user
+ I want to deploy my app against elasticsearch service
+
+ @creates_elasticsearch_service @create_elasticsearch_app
+ Scenario: deploy simple elasticsearch application
+ Given I am registered
+ Given I have provisioned an elasticsearch service
+ Given I have deployed an elasticsearch application that is bound to this service
+ When I add a document in my elasticsearch service through my application
+ Then I should be able to get it
@@ -0,0 +1,35 @@
+# Simple elasticsearch Application that uses the elasticsearch text search service
+
+Given /^I have provisioned an elasticsearch service$/ do
+ pending unless find_service 'elasticsearch'
+ @elasticsearch_service = provision_elasticsearch_service @token
+ @elasticsearch_service.should_not == nil
+end
+
+Given /^I have deployed an elasticsearch application that is bound to this service$/ do
+ @app = create_app ELASTICSEARCH_APP, @token
+ attach_provisioned_service @app, @elasticsearch_service, @token
+ upload_app @app, @token
+ start_app @app, @token
+ expected_health = 1.0
+ health = poll_until_done @app, expected_health, @token
+ health.should == expected_health
+end
+
+When /^I add a document in my elasticsearch service through my application$/ do
+ uri = get_uri(@app, "es/save")
+ @elasticsearch_doc_id = "foo"
+ response = post_uri(uri, "id=#{@elasticsearch_doc_id}&message=bar")
+ response.response_code.should == 200
+ response.body_str.include?('"ok":true').should == true
+ response.close
+end
+
+Then /^I should be able to get it$/ do
+ uri = get_uri(@app, "es/get/#{@elasticsearch_doc_id}")
+ response = get_uri_contents uri
+ response.should_not == nil
+ response.response_code.should == 200
+ response.body_str.include?('"exists":true').should == true
+ response.close
+end
View
@@ -65,6 +65,7 @@
SPRING_APP_WITH_JAVAEE_NS = "javaee-namespace-app"
AUTO_RECONFIG_ANNOTATION_APP="auto-reconfig-annotation-app"
MEMCACHED_APP = "memcached_app"
+ELASTICSEARCH_APP = "elasticsearch_app"
class Fixnum
def to_json(options = nil)
@@ -200,6 +201,7 @@ def cleanup
delete_app_internal(VBLOB_APP)
delete_app_internal(SERVICE_QUOTA_APP)
delete_app_internal(MEMCACHED_APP)
+ delete_app_internal(ELASTICSEARCH_APP)
delete_services(all_my_services) unless @registered_user or !get_login_token
# This used to delete the entire user, but that now requires admin
# privs so it was removed, as was the delete_user method. See the
@@ -774,6 +776,17 @@ def provision_redis_service token
}
end
+ def provision_elasticsearch_service token
+ name = "#{@namespace}#{@app || 'elasticsearch_app'}elasticsearch"
+ @client.create_service(:elasticsearch, name)
+ service_manifest = {
+ :vendor=>"elasticsearch",
+ :tier=>"free",
+ :version=>"0.19",
+ :name=>name
+ }
+ end
+
def postgresql_name name
"#{@namespace}postgresql_#{name}"
end
@@ -230,3 +230,11 @@
delete_service @memcached_service[:name] if @memcached_service
end
+# elasticsearch
+After("@creates_elasticsearch_app") do |scenario|
+ delete_app @app, @token if @app
+end
+
+After("@creates_elasticsearch_service") do |scenario|
+ delete_service @elasticsearch_service[:name] if @elasticsearch_service
+end
@@ -267,6 +267,11 @@ neo4j_app:
memory: 128
path: "assets/sinatra/neo4j_app"
+elasticsearch_app:
+ framework: "http://b20nine.com/unknown"
+ memory: 64
+ path: "assets/sinatra/elasticsearch_app"
+
simple_wsgi_app:
framework: "wsgi"
memory: 64

0 comments on commit c3bdcf5

Please sign in to comment.