Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Fix multiservers deployments issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen committed Mar 23, 2015
1 parent 00a933f commit 87a592c
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 4 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,18 @@

Rocketeer follows the [Semantic Versioning 2.0](http://semver.org/spec/v2.0.0.html) spec.

## [2.1.3] - 2015-03-23

### Fixed
- Fixed an issue with multiservers deployments

## [2.1.2] - 2015-03-10

### Fixed
- Fixed an issue prevent using a custom command clas
- Fixed commands run in folders not working with LocalConnection
- Fixed port and key not being passed to rsync

## [2.1.2] - 2015-03-10

### Fixed
Expand Down Expand Up @@ -370,6 +382,7 @@ Rocketeer follows the [Semantic Versioning 2.0](http://semver.org/spec/v2.0.0.ht
- Added config file
- Added `deploy:setup` and `deploy:deploy` commands

[2.1.3]: https://github.com/rocketeers/rocketeer/compare/2.1.2...2.1.3
[2.1.2]: https://github.com/rocketeers/rocketeer/compare/2.1.1...2.1.2
[2.1.1]: https://github.com/rocketeers/rocketeer/compare/2.1.0...2.1.1
[2.1.0]: https://github.com/rocketeers/rocketeer/compare/2.0.6...2.1.0
Expand Down
4 changes: 0 additions & 4 deletions src/Rocketeer/Services/Connections/ConnectionsHandler.php
Expand Up @@ -70,10 +70,6 @@ class ConnectionsHandler
*/
public function getHandle($connection = null, $server = null, $stage = null)
{
if ($this->handle) {
return $this->handle;
}

// Get identifiers
$connection = $connection ?: $this->getConnection();
$server = $server ?: $this->getServer();
Expand Down
83 changes: 83 additions & 0 deletions tests/Services/Connections/ConnectionsHandlerTest.php
Expand Up @@ -15,6 +15,15 @@

class ConnectionsHandlerTest extends RocketeerTestCase
{
public function setUp()
{
parent::setUp();

$this->username = 'Anahkiasen';
$this->password = 'foobar';
$this->host = 'some.host';
}

////////////////////////////////////////////////////////////////////
//////////////////////////////// TESTS /////////////////////////////
////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -220,10 +229,84 @@ public function testAlwaysReturnsArrayIfNoCredentialsFound()
$this->assertEquals([], $this->connections->getServerCredentials());
}

public function testCanHaveMultipleServerConnections()
{
$this->swapConfig(array(
'rocketeer::connections' => array(
'production-multiserver' => array(
'servers' => $this->mockRuntimeMultiserverConnection()
),
),
));
$this->mockCommand(array(
'on' => 'production-multiserver'
));
$this->credentials->getServerCredentials();

$credentials = $this->connections->getServerCredentials('production-multiserver', 0);
$this->assertEquals(array(
'host' => "10.1.1.1",
'username' => $this->username,
'password' => '',
'keyphrase' => '',
'key' => '',
'agent' => true,
'agent-forward' => true,
'db_role' => false
), $credentials);
// also check handle generation as handles are used for connection cache keying in RemoteHandler
$this->assertEquals("production-multiserver/0", $this->connections->getHandle("production-multiserver", 0));

$credentials = $this->connections->getServerCredentials('production-multiserver', 1);
$this->assertEquals(array(
'host' => "10.1.1.2",
'username' => $this->username,
'password' => '',
'keyphrase' => '',
'key' => '',
'agent' => true,
'agent-forward' => true,
'db_role' => false
), $credentials);
$this->assertEquals("production-multiserver/1", $this->connections->getHandle("production-multiserver", 1));

$credentials = $this->connections->getServerCredentials('production-multiserver', 2);
$this->assertEquals(array(
'host' => "10.1.1.3",
'username' => $this->username,
'password' => '',
'keyphrase' => '',
'key' => '',
'agent' => true,
'agent-forward' => true,
'db_role' => false
), $credentials);
$this->assertEquals("production-multiserver/2", $this->connections->getHandle("production-multiserver", 2));
}

////////////////////////////////////////////////////////////////////
//////////////////////////////// HELPERS ///////////////////////////
////////////////////////////////////////////////////////////////////

/**
* Mock a set of runtime injected credentials
*/
protected function mockRuntimeMultiserverConnection()
{
return array_map(
function ($ip) {
return [
'host' => $ip,
'username' => $this->username,
'agent' => true,
'agent-forward' => true,
'db_role' => false
];
},
['10.1.1.1', '10.1.1.2', '10.1.1.3']
);
}

/**
* Make the config return specific SCM config.
*
Expand Down

0 comments on commit 87a592c

Please sign in to comment.