summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/congress/test-webapp/www/proxy/index.php93
-rw-r--r--tests/dmz.sh7
-rw-r--r--tests/reserved_subnet.sh9
-rw-r--r--tests/smtp_ingress.sh10
4 files changed, 70 insertions, 49 deletions
diff --git a/components/congress/test-webapp/www/proxy/index.php b/components/congress/test-webapp/www/proxy/index.php
index 39d54d3..ca23b92 100644
--- a/components/congress/test-webapp/www/proxy/index.php
+++ b/components/congress/test-webapp/www/proxy/index.php
@@ -23,12 +23,15 @@ if ($method == 'OPTIONS') {
exit();
}
+$url = "http://CONGRESS_HOST:1789".$_GET['~url'];
+$body = file_get_contents('php://input');
+$token = "";
+$responseCode = "";
+$response = "";
+$type = "";
-if (file_exists("/tmp/os_token")) {
- $token = file_get_contents("/tmp/os_token");
- file_put_contents("/tmp/".date('ymd').".log", "proxy.php, auth token=".$token."\n",FILE_APPEND);
-}
-else {
+function get_token() {
+ global $token;
$url = "http://KEYSTONE_HOST:5000/v2.0/tokens";
$curlop = curl_init();
curl_setopt($curlop, CURLOPT_URL, $url);
@@ -40,49 +43,61 @@ else {
$body = '{"auth": {"tenantName": "OS_TENANT_NAME", "passwordCredentials": {"username": "OS_USERNAME", "password": "OS_PASSWORD"}}}';
curl_setopt($curlop, CURLOPT_POSTFIELDS, $body);
$req_time=time();
- $result = file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$url.", ".$type.", ".$body."\n",FILE_APPEND);
- if ($result === false) $response = "PHP error in index.php";
+ file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$url.", ".$type.", ".$body."\n",FILE_APPEND);
$response = curl_exec($curlop);
$body = substr($response, $header_size);
- $result = file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$responseCode.", ".$type.", ".$header.", ".$body."\n",FILE_APPEND);
- if ($result === false) $response = "PHP error in index.php";
+ file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$responseCode.", ".$type.", ".$header.", ".$body."\n",FILE_APPEND);
$response = json_decode($body);
$token = $response->access->token->id;
file_put_contents("/tmp/os_token",$token);
}
-$url = "http://CONGRESS_HOST:1789".$_GET['~url'];
-$curlop = curl_init();
-curl_setopt($curlop, CURLOPT_URL, $url);
-curl_setopt($curlop, CURLOPT_CUSTOMREQUEST, $method);
-curl_setopt($curlop, CURLOPT_HTTPHEADER, array("X-Auth-Token: '.$token'"));
-//curl_setopt($curlop, CURLINFO_HEADER_OUT, 0);
-curl_setopt($curlop, CURLOPT_RETURNTRANSFER, 1);
-curl_setopt($curlop, CURLOPT_SSL_VERIFYPEER, false);
-curl_setopt($curlop, CURLINFO_HEADER_OUT, true);
+function send_request($method,$url,$body) {
+ global $token, $responseCode, $response, $type;
+ $curlop = curl_init();
+ curl_setopt($curlop, CURLOPT_URL, $url);
+ curl_setopt($curlop, CURLOPT_CUSTOMREQUEST, $method);
+ curl_setopt($curlop, CURLOPT_HTTPHEADER, array("X-Auth-Token: ".$token));
+ //curl_setopt($curlop, CURLINFO_HEADER_OUT, 0);
+ curl_setopt($curlop, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curlop, CURLOPT_SSL_VERIFYPEER, false);
+ curl_setopt($curlop, CURLINFO_HEADER_OUT, true);
+ if ($method == "POST") {
+ curl_setopt($curlop, CURLOPT_HTTPHEADER, array("Content-Type: application/json","X-Auth-Token: ".$token));
+ curl_setopt($curlop, CURLOPT_POSTFIELDS, $body);
+ }
+ $response = curl_exec($curlop);
+ $req_time=time();
+ $info = curl_getinfo($curlop);
+ file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$url.", ".$type.", ".$body."\n",FILE_APPEND);
+ $responseCode=curl_getinfo($curlop,CURLINFO_HTTP_CODE);
+ $header_size = curl_getinfo($response, CURLINFO_HEADER_SIZE);
+ $header = substr($response, 0, $header_size);
+ $type = curl_getinfo($curlop,CURLINFO_CONTENT_TYPE);
+ $body = substr($response, $header_size);
+ file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$responseCode.", ".$type.", ".$header.", ".$body."\n",FILE_APPEND);
+ curl_close($curlop);
+}
-if ($method == "POST") {
- curl_setopt($curlop, CURLOPT_HTTPHEADER, array("Content-Type: application/json","X-Auth-Token: '.$token'"));
- $body = file_get_contents('php://input');
- curl_setopt($curlop, CURLOPT_POSTFIELDS, $body);
+function send_response($response) {
+ // header("Location: ".$url);
+ header("Content-Type: ".$type);
+ header("Access-Control-Allow-Origin: *");
+ echo $response;
}
-$response = curl_exec($curlop);
-$req_time=time();
+if (file_exists("/tmp/os_token")) {
+ $token = file_get_contents("/tmp/os_token");
+ file_put_contents("/tmp/".date('ymd').".log", "proxy.php, auth token=".$token."\n",FILE_APPEND);
+}
+else {
+ get_token();
+}
-$info = curl_getinfo($curlop);
-$result = file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$url.", ".$type.", ".$body."\n",FILE_APPEND);
-if ($result === false) $response = "PHP error in index.php";
-$responseCode=curl_getinfo($curlop,CURLINFO_HTTP_CODE);
-$header_size = curl_getinfo($response, CURLINFO_HEADER_SIZE);
-$header = substr($response, 0, $header_size);
-$type = curl_getinfo($curlop,CURLINFO_CONTENT_TYPE);
-$body = substr($response, $header_size);
-$result = file_put_contents("/tmp/".date('ymd').".log", "proxy.php, ".$req_time.", ".$responseCode.", ".$type.", ".$header.", ".$body."\n",FILE_APPEND);
-if ($result === false) $response = "PHP error in index.php";
+send_request($method,$url,$body);
+if ($responseCode == '401') {
+ get_token();
+ send_request($method,$url,$body);
+}
-// header("Location: ".$url);
-header("Content-Type: ".$type);
-header("Access-Control-Allow-Origin: *");
-echo $response;
-curl_close($curlop);
+send_response($response);
diff --git a/tests/dmz.sh b/tests/dmz.sh
index ff5a5cd..f915378 100644
--- a/tests/dmz.sh
+++ b/tests/dmz.sh
@@ -37,6 +37,8 @@
pass() {
echo "Hooray!"
+ set +x #echo off
+ exit 0
}
# Use this to trigger fail() at the right places
@@ -108,8 +110,6 @@ neutron router-gateway-set test_router test_public
echo "Add router internal for internal network"
neutron router-interface-add test_router subnet=test_internal
-echo "Wait up to a minute as 'neutron router-interface-add' blocks the neutron-api for some time..."
-# add a delay since the previous command takes the neutron-api offline for a while (?)
COUNTER=1
RESULT="Failed!"
until [[ "$COUNTER" -gt 6 || "$RESULT" == "Success!" ]]; do
@@ -154,6 +154,7 @@ echo "Verify cirros1 and cirros2 IDs are in the Congress policy 'test' table 'dm
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
+ openstack congress policy row list test dmz_server
dmz_cirros1=$(openstack congress policy row list test dmz_server | awk "/ $test_cirros1_ID / { print \$2 }")
dmz_cirros2=$(openstack congress policy row list test dmz_server | awk "/ $test_cirros2_ID / { print \$2 }")
if [ "$dmz_cirros1" == "$test_cirros1_ID" ] && [ "$dmz_cirros2" == "$test_cirros2_ID" ]; then RESULT="Test Success!"; fi
@@ -167,6 +168,7 @@ echo "Verify cirros1 ID is in the Congress policy 'test' table 'dmz_placement_er
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
+ openstack congress policy row list test dmz_placement_error
dmz_cirros1=$(openstack congress policy row list test dmz_placement_error | awk "/ $test_cirros1_ID / { print \$2 }")
if [ "$dmz_cirros1" == "$test_cirros1_ID" ]; then RESULT="Test Success!"; fi
let COUNTER-=1
@@ -182,6 +184,7 @@ echo "Verify cirros1 is paused"
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
+ nova list
cirros1_status=$(nova list | awk "/ cirros1 / { print \$6 }")
if [ "$cirros1_status" == "PAUSED" ]; then RESULT="Test Success!"; fi
let COUNTER-=1
diff --git a/tests/reserved_subnet.sh b/tests/reserved_subnet.sh
index f30c3c5..7fb7da1 100644
--- a/tests/reserved_subnet.sh
+++ b/tests/reserved_subnet.sh
@@ -32,6 +32,8 @@
pass() {
echo "Hooray!"
+ set +x #echo off
+ exit 0
}
# Use this to trigger fail() at the right places
@@ -57,7 +59,7 @@ echo "Create Congress policy 'test'"
if [[ $(openstack congress policy show test | awk "/ id / { print \$4 }") ]]; then unclean; fi
openstack congress policy create test
-echo "Create reserved_subnet_error rule in policy 'test'"
+echo "Create reserved_subnet_error rules in policy 'test'"
openstack congress policy rule create test "reserved_subnet_error(x) :- neutronv2:subnets(id=x, cidr='10.7.1.0/24')" --name rsv_subnet_adm
openstack congress policy rule create test "reserved_subnet_error(x) :- neutronv2:subnets(id=x, cidr='10.7.12.0/24')" --name rsv_subnet_prv
openstack congress policy rule create test "reserved_subnet_error(x) :- neutronv2:subnets(id=x, cidr='10.7.13.0/24')" --name rsv_subnet_stg
@@ -88,6 +90,7 @@ echo "Verify test_public subnet ID is in the Congress policy 'test' table 'reser
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
+ openstack congress policy row list test reserved_subnet_error
test_public_ID=$(openstack congress policy row list test reserved_subnet_error | awk "/ $test_public_SUBNET / { print \$2 }")
if [ "$test_public_SUBNET" == "$test_public_ID" ]; then RESULT="Test Success!"
fi
@@ -101,6 +104,7 @@ echo "Verify test_internal subnet ID is in the Congress policy 'test' table 'res
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
+ openstack congress policy row list test reserved_subnet_error
test_internal_ID=$(openstack congress policy row list test reserved_subnet_error | awk "/ $test_internal_SUBNET / { print \$2 }")
if [ "$test_internal_SUBNET" == "$test_internal_ID" ]; then RESULT="Test Success!"
fi
@@ -117,6 +121,7 @@ echo "Verify test_internal subnet is deleted"
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
+ neutron subnet-list
test_internal_ID=$(neutron subnet-list | awk "/ test_internal / { print \$2 }")
if [ "$test_internal_SUBNET" != "$test_internal_ID" ]; then RESULT="Test Success!"
fi
@@ -130,6 +135,7 @@ echo "Verify test_public subnet is deleted"
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
+ neutron subnet-list
test_public_ID=$(neutron subnet-list | awk "/ test_public / { print \$2 }")
if [ "$test_public_SUBNET" != "$test_public_ID" ]; then RESULT="Test Success!"
fi
@@ -139,4 +145,3 @@ done
echo "Verify test_public subnet is deleted:" $RESULT
if [ "$RESULT" == "Test Failed!" ]; then fail; fi
pass
-set +x #echo off
diff --git a/tests/smtp_ingress.sh b/tests/smtp_ingress.sh
index a800ca2..9497276 100644
--- a/tests/smtp_ingress.sh
+++ b/tests/smtp_ingress.sh
@@ -31,13 +31,15 @@
pass() {
echo "Hooray!"
+ set +x #echo off
+ exit 0
}
# Use this to trigger fail() at the right places
# if [ "$RESULT" == "Test Failed!" ]; then fail; fi
fail() {
echo "Test Failed!"
- set +x
+ set +x #echo off
exit 1
}
@@ -105,9 +107,6 @@ neutron security-group-rule-create --direction ingress --protocol=TCP --port-ran
echo "Boot cirros1 with smtp_ingress security group"
nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=$test_internal_NET --security-groups smtp_ingress cirros1
-echo "Wait 30 seconds for Congress polling to occur at least once"
-sleep 30
-
echo "Get cirros1 instance ID"
test_cirros1_ID=$(openstack server list | awk "/ cirros1 / { print \$2 }")
@@ -115,7 +114,7 @@ echo "Verify cirros1 is in the Congress policy 'test' table 'smtp_ingress'"
COUNTER=5
RESULT="Test Failed!"
until [[ $COUNTER -eq 0 || $RESULT == "Test Success!" ]]; do
- echo "Check for presence of cirros1 ID in Congress policy 'test' table 'smtp_ingress'"
+ openstack congress policy row list test smtp_ingress
cirros1_ID=$(openstack congress policy row list test smtp_ingress | awk "/ $test_cirros1_ID / { print \$2 }")
if [ "$cirros1_ID" == "$test_cirros1_ID" ]; then RESULT="Test Success!"
fi
@@ -125,4 +124,3 @@ done
echo $RESULT
if [ "$RESULT" == "Test Failed!" ]; then fail; fi
pass
-set +x #echo off