Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2016-present Ciena Corporation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | import unittest |
| 17 | import os,sys |
| 18 | import keystoneclient.v2_0.client as ksclient |
| 19 | import keystoneclient.apiclient.exceptions |
| 20 | import neutronclient.v2_0.client as nclient |
| 21 | import neutronclient.common.exceptions |
| 22 | from novaclient import client as nova_client |
| 23 | from neutronclient.v2_0 import client as neutron_client |
| 24 | import neutronclient.v2_0.client as neutronclient |
| 25 | from nose.tools import assert_equal |
| 26 | from CordTestUtils import get_mac, log_test |
| 27 | from OnosCtrl import OnosCtrl |
| 28 | from OnosFlowCtrl import OnosFlowCtrl |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 29 | from OnboardingServiceUtils import OnboardingServiceUtils |
| 30 | from SSHTestAgent import SSHTestAgent |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 31 | from CordTestUtils import running_on_pod |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 32 | import requests |
| 33 | import time |
| 34 | import json |
| 35 | |
| 36 | class onboarding_exchange(): |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 37 | ONOS_INSTANCES = 3 |
| 38 | V_INF1 = 'veth0' |
| 39 | device_id = 'of:' + get_mac() |
| 40 | TEST_IP = '8.8.8.8' |
| 41 | HOST = "10.1.0.1" |
| 42 | USER = "vagrant" |
| 43 | PASS = "vagrant" |
| 44 | head_node = os.getenv('HEAD_NODE', 'prod') |
| 45 | HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node |
| 46 | test_path = os.path.dirname(os.path.realpath(__file__)) |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 47 | on_pod = running_on_pod() |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 48 | |
| 49 | @classmethod |
| 50 | def setUpClass(cls): |
| 51 | OnboardingServiceUtils.setUp() |
| 52 | |
| 53 | @classmethod |
| 54 | def tearDownClass(cls): |
| 55 | OnboardingServiceUtils.tearDown() |
| 56 | |
| 57 | def cliEnter(self, controller = None): |
| 58 | retries = 0 |
| 59 | while retries < 30: |
| 60 | self.cli = OnosCliDriver(controller = controller, connect = True) |
| 61 | if self.cli.handle: |
| 62 | break |
| 63 | else: |
| 64 | retries += 1 |
| 65 | time.sleep(2) |
| 66 | |
| 67 | def cliExit(self): |
| 68 | self.cli.disconnect() |
| 69 | |
| 70 | def onos_shutdown(self, controller = None): |
| 71 | status = True |
| 72 | self.cliEnter(controller = controller) |
| 73 | try: |
| 74 | self.cli.shutdown(timeout = 10) |
| 75 | except: |
| 76 | log.info('Graceful shutdown of ONOS failed for controller: %s' %controller) |
| 77 | status = False |
| 78 | |
| 79 | self.cliExit() |
| 80 | return status |
| 81 | |
| 82 | def test_exampleservice_health(self): |
| 83 | """ |
| 84 | Algo: |
| 85 | 1. Login to compute node VM |
| 86 | 2. Get all exampleservice |
| 87 | 3. Ping to all exampleservice |
| 88 | 4. Verifying Ping success |
| 89 | """ |
| 90 | status = OnboardingServiceUtils.health_check() |
| 91 | assert_equal(status, True) |
| 92 | |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 93 | def test_exampleservice_for_login(self): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 94 | if self.on_pod is False: |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 95 | return |
| 96 | exampleservices = OnboardingServiceUtils.get_exampleservices() |
| 97 | exampleservice_access_status = map(lambda exampleservice: exampleservice.check_access(), exampleservices) |
| 98 | status = filter(lambda st: st == False, exampleservice_access_status) |
| 99 | assert_equal(len(status), 0) |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 100 | |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 101 | def test_exampleservice_for_default_route_through_testclient(self): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 102 | if self.on_pod is False: |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 103 | return |
| 104 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 105 | cmd = "sudo lxc exec testclient -- route | grep default" |
| 106 | status, output = ssh_agent.run_cmd(cmd) |
| 107 | assert_equal(status, True) |
| 108 | |
| 109 | def test_exampleservice_for_service_access_through_testclient(self): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 110 | if self.on_pod is False: |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 111 | return |
| 112 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 113 | cmd = "lxc exec testclient -- ping -c 3 8.8.8.8" |
| 114 | status, output = ssh_agent.run_cmd(cmd) |
| 115 | assert_equal( status, True) |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 116 | |
| 117 | def test_exampleservice_for_apache_service(self): |
| 118 | pass |
| 119 | |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 120 | def test_exampleservice_for_tenant_message(self): |
| 121 | pass |
| 122 | |
| 123 | def test_exampleservice_for_service_message(self): |
| 124 | pass |
| 125 | |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 126 | def test_exampleservice_using__curl(self): |
| 127 | pass |