Permalink
Browse files

Memcached Updates

 - Reduce capacity when provisioning instances on startup
 - Updated gems
 - Fixed unit tests, commented out tests expected to fail because sasl was disabled

Change-Id: I30005b6569dec99b5fb231723696328ab203af79
  • Loading branch information...
1 parent 577f7e8 commit 6dfdbc0d5a3b2fda367288e0d9b3b96f16a534b9 Harshawardhan Gadgil committed May 23, 2012
@@ -95,7 +95,7 @@ GEM
rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0)
rspec-mocks (~> 2.10.0)
- rspec-core (2.10.0)
+ rspec-core (2.10.1)
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
@@ -119,15 +119,15 @@ GEM
uuid (2.3.5)
macaddr (~> 1.0)
uuidtools (2.1.2)
- vcap_common (1.0.11)
+ vcap_common (1.0.12)
eventmachine (~> 0.12.11.cloudfoundry.3)
nats (~> 0.4.22.beta.8)
posix-spawn (~> 0.3.6)
thin (~> 1.3.1)
yajl-ruby (~> 0.8.3)
vcap_logging (1.0.1)
rake
- vcap_services_base (0.1.9)
+ vcap_services_base (0.1.10)
curb (~> 0.7.16)
datamapper (~> 1.1.0)
do_sqlite3 (~> 0.10.3)
@@ -16,6 +16,6 @@ port_range:
memcached_log_dir: /var/vcap/sys/log/memcached
max_clients: 500
memcached_timeout: 2
-sasl_enabled: true
+sasl_enabled: false
# z_interval: 30
@@ -6,7 +6,7 @@ module Services
module Memcached
module Common
def service_name
- "MaaS"
+ "MemcachedaaS"
end
end
end
@@ -251,6 +251,7 @@ def start_provisioned_instances
@logger.debug("Start provisioned instance....")
ProvisionedService.all.each do |instance|
+ @capacity -= capacity_unit
@logger.debug("instance : #{instance.inspect}")
@free_ports_mutex.synchronize do
@free_ports.delete(instance.port)
@@ -41,8 +41,7 @@ class Node
:memcached_log_dir => "/tmp/memcached_log",
:command_rename_prefix => "protect-command",
:max_clients => 100,
- :memcached_memory => 16,
- :sasl_enabled => true
+ :memcached_memory => 16
}
FileUtils.mkdir_p(@options[:base_dir])
FileUtils.mkdir_p(@options[:memcached_log_dir])
@@ -178,17 +177,19 @@ class Node
memcached.get("test_key").should be_nil
end
- it "should not allow null credentials to access the instance" do
- hostname = get_hostname(@credentials)
- memcached = Dalli::Client.new(hostname)
- expect {memcached.get("test_key")}.should raise_error(RuntimeError)
- end
+# - These tests require sasl to be enabled, commenting them out for now if later on we decide
+# to enable sasl
+# it "should not allow null credentials to access the instance" do
+# hostname = get_hostname(@credentials)
+# memcached = Dalli::Client.new(hostname)
+# expect {memcached.get("test_key")}.should raise_error(RuntimeError)
+# end
- it "should not allow wrong credentials to access the instance" do
- hostname, username, password = get_connect_info(@credentials)
- memcached = Dalli::Client.new(hostname, username: username, password: 'wrong_password')
- expect {memcached.get("test_key")}.should raise_error(RuntimeError)
- end
+# it "should not allow wrong credentials to access the instance" do
+# hostname, username, password = get_connect_info(@credentials)
+# memcached = Dalli::Client.new(hostname, username: username, password: 'wrong_password')
+# expect {memcached.get("test_key")}.should raise_error(RuntimeError)
+# end
it "should delete the provisioned instance port in free port list when finish a provision" do
@node.free_ports.include?(@credentials["port"]).should == false
@@ -283,19 +284,21 @@ class Node
memcached.get("test_key").should be_nil
end
- it "should not allow null credentials to access the instance" do
- hostname = get_hostname(@binding_credentials)
- memcached = Dalli::Client.new(hostname)
- expect {memcached.get("test_key")}.should raise_error(RuntimeError)
- end
+# - These tests require sasl to be enabled, commenting them out for now if later on we decide
+# to enable sasl
+# it "should not allow null credentials to access the instance" do
+# hostname = get_hostname(@binding_credentials)
+# memcached = Dalli::Client.new(hostname)
+# expect {memcached.get("test_key")}.should raise_error(RuntimeError)
+# end
- it "should not allow wrong credentials to access the instance" do
- hostname = get_hostname(@binding_credentials)
- username = @binding_credentials['user']
- password = @binding_credentials['password']
- memcached = Dalli::Client.new(hostname, username: username, password: 'wrong_password')
- expect {memcached.get("test_key")}.should raise_error(RuntimeError)
- end
+# it "should not allow wrong credentials to access the instance" do
+# hostname = get_hostname(@binding_credentials)
+# username = @binding_credentials['user']
+# password = @binding_credentials['password']
+# memcached = Dalli::Client.new(hostname, username: username, password: 'wrong_password')
+# expect {memcached.get("test_key")}.should raise_error(RuntimeError)
+# end
it "should send binding message when finish a binding" do
@binding_credentials["hostname"].should be
@@ -338,17 +341,17 @@ class Node
memcached = []
# Create max_clients connections
hostname, username, password = get_connect_info(@credentials)
- for i in 1..(@options[:max_clients]-31)
+ for i in 1..(@options[:max_clients]-30)
memcached[i] = Dalli::Client.new(hostname, username: username, password: password)
memcached[i].set("foo", 1)
end
# The max_clients + 1 connection will raise exception
expect do
Dalli::Client.new(hostname, username: username, password: password).set("foo", 1)
- end.should raise_error(Dalli::DalliError)
+ end.should raise_error(Dalli::RingError)
# Close the max_clients connections
- for i in 1..(@options[:max_clients] - 31)
+ for i in 1..(@options[:max_clients] - 30)
memcached[i].close
end
# Now the new connection will be successful
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 6dfdbc0

Please sign in to comment.