diff --git a/tests/prod-environment-behaves-correctly/DevCentralDockerTest.php b/tests/prod-environment-behaves-correctly/DevCentralDockerTest.php new file mode 100644 --- /dev/null +++ b/tests/prod-environment-behaves-correctly/DevCentralDockerTest.php @@ -0,0 +1,38 @@ +markTestSkipped("No access to Docker engine."); + } + + $this->container = new DockerContainer(getenv('DOCKER_HOST'), self::DOCKER_CONTAINER); + } + + public function testInitialized () { + //TODO: test if .initialized file exists + $this->markTestIncomplete("This test will have to be implemented after container update."); + } + + public function testProcesses () { + $processes = $this->container->exec("ps auxw"); + + $expectedProcesses = [ + 'nginx: master process', + 'nginx: worker process', + 'php-fpm: master process', + 'PhabricatorTaskmasterDaemon', + 'PhabricatorBot', + ]; + + foreach ($expectedProcesses as $expectedProcess) { + $this->assertContains($expectedProcess, $processes); + } + } +} diff --git a/tests/prod-environment-behaves-correctly/DevCentralTest.php b/tests/prod-environment-behaves-correctly/DevCentralTest.php new file mode 100644 --- /dev/null +++ b/tests/prod-environment-behaves-correctly/DevCentralTest.php @@ -0,0 +1,17 @@ +assertHttpResponseCode(200, 'http://devcentral.nasqueron.org', 'DevCentral looks down.'); + $this->assertHttpResponseCode(200, 'https://devcentral.nasqueron.org', "DevCentral HTTPS issue."); + $this->assertHttpResponseCode(500, 'http://phabricator-files-for-devcentral-nasqueron.spacetechnology.net', "DevCentral alternative domain should return a 500 error code for homepage. Check phabricator.base-uri isn't empty."); + } + + public function testAphlictIsUp () { + $this->assertHttpResponseCode(405, 'http://dwellers.nasqueron.org:22281/', 'Aphlict server seems down, does aphlict container is launched in Docker engine?'); + } +} diff --git a/tests/prod-environment-behaves-correctly/EtherpadTest.php b/tests/prod-environment-behaves-correctly/EtherpadTest.php --- a/tests/prod-environment-behaves-correctly/EtherpadTest.php +++ b/tests/prod-environment-behaves-correctly/EtherpadTest.php @@ -1,6 +1,6 @@ host = $host; + $this->container = $container; + } + + /** + * Determines if a hostname is valid + * + * @return bool true if the specified name is valid; otherwise, false + */ + public static function isValidHostname ($host) { + return (bool)preg_match('/^[A-Za-z0-9\-\.]+$/', $host); + } + + /** + * Determines if a container name is valid + * + * @return bool true if the specified name is valid; otherwise, false + */ + public static function isValidContainerName ($name) { + //Source: https://github.com/ajhager/docker/commit/f63cdf0260cf6287d28a589a79d3f947def6a569 + return (bool)preg_match('@^/?[a-zA-Z0-9_-]+$@', $name); + } + + /** + * Executes the specified command in the container + * + * @param string $command the command to run + * @return string the command output + */ + public function exec ($command) { + return `ssh $this->host docker exec $this->container $command`; + } +}