Whenever changing our Apaches configuration, we want to run integration tests to make sure nothing is going to broke. The repo is operations/apaches-config.git
Jeff Green has written a test suite that is sitting somewhere on the cluster.
Tim Starling posted on https://gerrit.wikimedia.org/r/#/c/15720/ a way to test our Apache configurations:
I tested redirects.conf with apache itself:
redirect-test-server.sh:
#!/bin/bash apache2 -d . \ -f redirect-test.conf \ -X
redirect-test.conf:
# vim: syn=apache LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so Listen 8080 ErrorLog /dev/stderr PidFile apache2.pid NameVirtualHost * <VirtualHost *> ServerName default DocumentRoot /nonexistent </VirtualHost> Include redirects.conf
redirect-test.php
<?php while (( $line = readline( '> ' ) ) !== false ) { $url = trim( $line ); if ( !preg_match( '/^http:\/\//', $url ) ) { $url = 'http://' . $url; } $c = curl_init( $url ); curl_setopt_array( $c, array( CURLOPT_HEADER => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_PROXY => 'localhost:8080', ) ); $result = curl_exec( $c ); $info = curl_getinfo( $c ); if ( $info['http_code'] == 301 || $info['http_code'] == 302 ) { $m = false; preg_match( '/Location: (.*)\\n/', $result, $m ); echo "-> {$m[1]}\n"; } else { echo $info['http_code'] . "\n"; } readline_add_history( $line ); }
We could use a vagrant machine to load the Apache conf and then run the above script.
See Also: T57857