Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Merge "add unit tests for mysql unprovision"
Browse files Browse the repository at this point in the history
  • Loading branch information
EagleChen authored and Gerrit Code Review committed Nov 27, 2012
2 parents 189b4ae + e273848 commit e9e0965
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ng/mysql/lib/mysql_service/without_warden.rb
Expand Up @@ -39,9 +39,11 @@ def pre_send_announcement_internal

def handle_provision_exception(provisioned_service)
delete_database(provisioned_service) if provisioned_service
@pool_mutex.synchronize { @pools.delete(provisioned_service.name) }
end

def help_unprovision(provisioned_service)
@pool_mutex.synchronize { @pools.delete(provisioned_service.name) }
if not provisioned_service.destroy
@logger.error("Could not delete service: #{provisioned_service.errors.inspect}")
raise MysqlError.new(MysqError::MYSQL_LOCAL_DB_ERROR)
Expand Down
30 changes: 30 additions & 0 deletions ng/mysql/spec/mysql_node_spec.rb
Expand Up @@ -304,6 +304,36 @@ def new_instance
end
end

it "should change variables back after unprovision" do
EM.run do
class << @node
attr_reader :free_ports
end if @node.use_warden

pool_size = @node.pools.size
free_port_size = @node.free_ports.size if @node.use_warden

db = @node.provision(@default_plan, nil, @default_version)
@node.pools.size.should == (pool_size + 1)
@node.pools.should have_key(db["name"])
@node.mysqlProvisionedService.get(db["name"]).should_not == nil
if @node.use_warden
@node.free_ports.should_not include(db["port"])
@node.free_ports.size.should == (free_port_size - 1)
end

@node.unprovision(db["name"], [])
@node.pools.size.should == pool_size
@node.pools.should_not have_key(db["name"])
@node.mysqlProvisionedService.get(db["name"]).should == nil
if @node.use_warden
@node.free_ports.size.should == free_port_size
@node.free_ports.should include(db["port"])
end
EM.stop
end
end

it "should not be possible to access one database using null or wrong credential" do
EM.run do
plan = "free"
Expand Down

0 comments on commit e9e0965

Please sign in to comment.