Page MenuHomeDevCentral

D28.diff
No OneTemporary

D28.diff

diff --git a/tests/prod-environment-behaves-correctly/EtherpadTest.php b/tests/prod-environment-behaves-correctly/EtherpadTest.php
new file mode 100644
--- /dev/null
+++ b/tests/prod-environment-behaves-correctly/EtherpadTest.php
@@ -0,0 +1,26 @@
+<?php
+
+require 'traits/assertHttp.php';
+
+class EtherpadTest extends PHPUnit_Framework_TestCase {
+ use assertHttp;
+
+ public function testEtherpadIsLive () {
+ $this->assertHttpResponseCode(200, 'http://pad.nasqueron.org', 'Etherpad looks down.');
+ $this->assertHttpResponseCode(200, 'https://pad.nasqueron.org/', "Etherpad HTTPS issue.");
+ $this->assertHttpResponseCode(200, 'http://pad.wolfplex.be', "Etherpad doesn't reply to pad.wolfplex.be vhost.");
+ $this->assertHttpResponseCode(404, 'http://pad.nasqueron.org/notexisting', 'A 404 code were expected for a not existing Etherpad page.');
+ $this->assertHttpResponseCode(200, 'http://pad.nasqueron.org/metrics', "ep_ether-o-meter plugin doesn't seem installed.");
+ }
+
+ public function testWolfplexApiWorks () {
+ //Reported by philectro - 09:42 < philectro> hey tous les pad ont disparu :o
+
+ $url = "http://www.wolfplex.be/pad/";
+ $this->assertHttpResponseCode(200, $url);
+
+ $stringOnlyAvailableWhenApiWorks = '<li><a href="/pad/';
+ $currentContent = file_get_contents($url);
+ $this->assertContains($stringOnlyAvailableWhenApiWorks, $currentContent, "On Ysul, /home/wolfplex.org/logs/api.log could help. But more probably, you reinstalled the Etherpad container without restoring the API key. Move the former APIKEY.txt file to /opt/etherpad-lite or, if lost, update Wolfplex API credentials with the new API key.");
+ }
+}
diff --git a/tests/prod-environment-behaves-correctly/Makefile b/tests/prod-environment-behaves-correctly/Makefile
new file mode 100644
--- /dev/null
+++ b/tests/prod-environment-behaves-correctly/Makefile
@@ -0,0 +1,7 @@
+###
+### Nasqueron ops tests
+### We use PHPUnit to test several parts of our infrastructure.
+###
+
+test:
+ phpunit .
diff --git a/tests/prod-environment-behaves-correctly/traits/assertHttp.php b/tests/prod-environment-behaves-correctly/traits/assertHttp.php
new file mode 100644
--- /dev/null
+++ b/tests/prod-environment-behaves-correctly/traits/assertHttp.php
@@ -0,0 +1,31 @@
+<?php
+
+trait assertHttp {
+ /**
+ * Asserts the HTTP response code of an URL matches the expected code
+ *
+ * @param int $expectedCode the expected HTTP response code
+ * @param string $url the URL to check
+ * @param string $comment the comment to output if the test fails [facultative]
+ */
+ private function assertHttpResponseCode ($expectedCode, $url, $comment = '') {
+ $actualCode = $this->getHttpResponseCode($url);
+ return $this->assertEquals($expectedCode, $actualCode, $comment);
+ }
+
+ /**
+ * Gets the HTTP response code of the specified URL
+ *
+ * @param string $url
+ * @return int the HTTP response code
+ */
+ private function getHttpResponseCode ($url) {
+ $ch = curl_init($url);
+ curl_setopt($ch, CURLOPT_USERAGENT, "Nasqueron-Ops-Tests");
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_exec($ch);
+ $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+ curl_close($ch);
+ return $code;
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 23:43 (21 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2249923
Default Alt Text
D28.diff (3 KB)

Event Timeline