Add tacker http monitor test
Adding vnf test to verify http monitoring Co-Authored-By: gong yong sheng <gong.yongsheng@99cloud.net> Co-Authored-By: Santosh Kodicherla <ksantosh.cs@gmail.com> Change-Id: I89580646fe1a873d8a8a75d57165f971d481e992 Closes-Bug: 1513591
This commit is contained in:
parent
c59d7000f6
commit
baa1584c30
|
@ -0,0 +1,54 @@
|
|||
template_name: http-ping
|
||||
description: http-ping-cirros-example
|
||||
|
||||
service_properties:
|
||||
Id: cirros-vnfd-http-moniotring
|
||||
vendor: canonical
|
||||
version: 1
|
||||
|
||||
vdus:
|
||||
vdu1:
|
||||
id: vdu1
|
||||
vm_image: cirros-0.3.4-x86_64-uec
|
||||
instance_type: m1.tiny
|
||||
user_data_format: RAW
|
||||
user_data: |
|
||||
#!/bin/sh
|
||||
cd /tmp
|
||||
rm -f httpsrv.sh
|
||||
cat > httpsrv.sh << EOL
|
||||
eth0_ip=$(ifconfig eth0|grep 'inet addr'|awk -F: '{print $2}'| awk '{print $1}')
|
||||
while true; do echo -e "HTTP/1.0 200 OK\r\n\r\nWelcome to $eth0_ip" | sudo nc -l -p 80 ; done&
|
||||
EOL
|
||||
sudo chmod +x httpsrv.sh
|
||||
sudo ./httpsrv.sh &
|
||||
sleep 150
|
||||
cat > kill.sh << EOL
|
||||
cat <<'EOF' > kill.sh
|
||||
pid = `ps -ef | grep httpsrv | grep exe | grep -v grep | awk '{print $1}'`
|
||||
echo "killing $pid"
|
||||
kill -9 $pid
|
||||
EOF
|
||||
sudo chmod +x kill.sh
|
||||
|
||||
network_interfaces:
|
||||
management:
|
||||
network: net_mgmt
|
||||
management: true
|
||||
|
||||
placement_policy:
|
||||
availability_zone: nova
|
||||
|
||||
monitoring_policy:
|
||||
http_ping:
|
||||
monitoring_params:
|
||||
monitoring_delay: 60
|
||||
retry: 5
|
||||
timeout: 10
|
||||
port: 80
|
||||
actions:
|
||||
failure: respawn
|
||||
|
||||
config:
|
||||
param0: key0
|
||||
param1: key1
|
|
@ -17,6 +17,7 @@ import time
|
|||
from oslo_config import cfg
|
||||
from tempest_lib.tests import base
|
||||
|
||||
from tacker.tests import constants
|
||||
from tacker import version
|
||||
from tackerclient.v1_0 import client as tacker_client
|
||||
|
||||
|
@ -94,3 +95,22 @@ class BaseTackerTest(base.TestCase):
|
|||
self.assertIsNotNone(vnf_instance['vnf']['instance_id'])
|
||||
self.assertEqual(vnf_instance['vnf']['vnfd_id'], vnfd_instance[
|
||||
'vnfd']['id'])
|
||||
|
||||
def verify_vnf_restart(self, vnfd_instance, vnf_instance):
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual(vnf_current_status, 'ACTIVE')
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
|
||||
vnf_current_status = self.wait_until_vnf_dead(vnf_id,
|
||||
constants.VNF_CIRROS_DEAD_TIMEOUT,
|
||||
constants.DEAD_SLEEP_TIME)
|
||||
self.assertEqual(vnf_current_status, 'DEAD')
|
||||
vnf_current_status = self.wait_until_vnf_active(vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual(vnf_current_status, 'ACTIVE')
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
from oslo_config import cfg
|
||||
|
||||
from tacker.tests import constants
|
||||
from tacker.tests.functional.vnfd import base
|
||||
from tacker.tests.utils import read_file
|
||||
|
||||
|
@ -22,7 +23,7 @@ CONF = cfg.CONF
|
|||
VNF_CIRROS_CREATE_TIMEOUT = 120
|
||||
|
||||
|
||||
class VnfTestJSON(base.BaseTackerTest):
|
||||
class VnfTestCreate(base.BaseTackerTest):
|
||||
def test_create_delete_vnf_no_monitoring(self):
|
||||
data = dict()
|
||||
data['tosca'] = read_file('sample_cirros_vnf_no_monitoring.yaml')
|
||||
|
@ -35,22 +36,17 @@ class VnfTestJSON(base.BaseTackerTest):
|
|||
|
||||
##Create vnf with vnfd_id
|
||||
vnfd_id = vnfd_instance['vnfd']['id']
|
||||
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name':
|
||||
"test_vnf_with_cirros_no_monitoring"}}
|
||||
vnf_name = 'test_vnf_with_cirros_no_monitoring'
|
||||
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
|
||||
vnf_instance = self.client.create_vnf(body = vnf_arg)
|
||||
self.assertIsNotNone(vnf_instance)
|
||||
self.assertIsNotNone(vnf_instance['vnf']['id'])
|
||||
self.assertIsNotNone(vnf_instance['vnf']['instance_id'])
|
||||
self.assertEqual(vnf_instance['vnf']['vnfd_id'], vnfd_instance[
|
||||
'vnfd']['id'])
|
||||
|
||||
self.validate_vnf_instance(vnfd_instance, vnf_instance)
|
||||
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
sleep_time = 5
|
||||
vnf_current_status = self.wait_until_vnf_active(vnf_id,
|
||||
VNF_CIRROS_CREATE_TIMEOUT,
|
||||
sleep_time)
|
||||
self.assertEqual(vnf_current_status,
|
||||
'ACTIVE')
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
self.assertEqual(vnf_current_status, 'ACTIVE')
|
||||
self.assertIsNotNone(self.client.show_vnf(vnf_id)['vnf']['mgmt_url'])
|
||||
|
||||
##Delete vnf_instance with vnf_id
|
||||
|
|
|
@ -12,20 +12,15 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
from tacker.tests import constants
|
||||
from tacker.tests.functional.vnfd import base
|
||||
from tacker.tests.utils import read_file
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
class VnfTestPingMonitor(base.BaseTackerTest):
|
||||
|
||||
class VnfTestJSON(base.BaseTackerTest):
|
||||
def test_create_delete_vnf_monitoring(self):
|
||||
def _test_vnf_with_monitoring(self, vnfd_file, vnf_name):
|
||||
data = dict()
|
||||
data['tosca'] = read_file(
|
||||
'sample_vnfd_no_param_monitoring_respawn.yaml')
|
||||
data['tosca'] = read_file(vnfd_file)
|
||||
toscal = data['tosca']
|
||||
tosca_arg = {'vnfd': {'attributes': {'vnfd': toscal}}}
|
||||
|
||||
|
@ -35,42 +30,33 @@ class VnfTestJSON(base.BaseTackerTest):
|
|||
|
||||
##Create vnf with vnfd_id
|
||||
vnfd_id = vnfd_instance['vnfd']['id']
|
||||
vnf_name = 'test_vnf_with_user_data_respawn'
|
||||
|
||||
vnf_arg = {'vnf': {'vnfd_id': vnfd_id, 'name': vnf_name}}
|
||||
|
||||
vnf_instance = self.client.create_vnf(body = vnf_arg)
|
||||
self.assertIsNotNone(vnf_instance)
|
||||
self.assertIsNotNone(vnf_instance['vnf']['id'])
|
||||
self.assertIsNotNone(vnf_instance['vnf']['instance_id'])
|
||||
self.assertEqual(vnf_instance['vnf']['vnfd_id'], vnfd_instance[
|
||||
'vnfd']['id'])
|
||||
|
||||
##Verify vnf is in ACTIVE state, then DEAD state and back ACTIVE again
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
vnf_current_status = self.wait_until_vnf_active(vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
|
||||
self.assertEqual(vnf_current_status, 'ACTIVE')
|
||||
vnf_current_status = self.wait_until_vnf_dead(vnf_id,
|
||||
constants.VNF_CIRROS_DEAD_TIMEOUT,
|
||||
constants.DEAD_SLEEP_TIME)
|
||||
self.assertEqual(vnf_current_status, 'DEAD')
|
||||
vnf_current_status = self.wait_until_vnf_active(vnf_id,
|
||||
constants.VNF_CIRROS_CREATE_TIMEOUT,
|
||||
constants.ACTIVE_SLEEP_TIME)
|
||||
|
||||
self.assertEqual(vnf_current_status, 'ACTIVE')
|
||||
##Verify vnf goes from ACTIVE->DEAD->ACTIVE states
|
||||
self.verify_vnf_restart(vnfd_instance, vnf_instance)
|
||||
|
||||
##Delete vnf_instance with vnf_id
|
||||
vnf_id = vnf_instance['vnf']['id']
|
||||
try:
|
||||
self.client.delete_vnf(vnf_id)
|
||||
except Exception:
|
||||
assert False, "vnf Delete failed after the monitor test"
|
||||
assert False, ("Failed to delete vnf %s after the monitor test" %
|
||||
vnf_id)
|
||||
|
||||
##Delete vnfd_instance
|
||||
try:
|
||||
self.client.delete_vnfd(vnfd_id)
|
||||
except Exception:
|
||||
assert False, "vnfd Delete failed after the monitor test"
|
||||
assert False, ("Failed to delete vnfd %s after the monitor test" %
|
||||
vnfd_id)
|
||||
|
||||
def test_create_delete_vnf_monitoring(self):
|
||||
self._test_vnf_with_monitoring(
|
||||
'sample_vnfd_no_param_monitoring_respawn.yaml',
|
||||
'ping monitor vnf')
|
||||
|
||||
def test_create_delete_vnf_http_monitoring(self):
|
||||
self._test_vnf_with_monitoring(
|
||||
'sample_cirros_http_monitoring.yaml',
|
||||
'http monitor vnf')
|
||||
|
|
|
@ -20,7 +20,7 @@ from tacker.tests.utils import read_file
|
|||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class VnfdTestJSON(base.BaseTackerTest):
|
||||
class VnfdTestCreate(base.BaseTackerTest):
|
||||
def test_create_list_delete_vnfd(self):
|
||||
data = dict()
|
||||
data['tosca'] = read_file('sample_cirros_vnf.yaml')
|
||||
|
|
Loading…
Reference in New Issue