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 |
| 31 | import requests |
| 32 | import time |
| 33 | import json |
| 34 | |
| 35 | class onboarding_exchange(): |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 36 | ONOS_INSTANCES = 3 |
| 37 | V_INF1 = 'veth0' |
| 38 | device_id = 'of:' + get_mac() |
| 39 | TEST_IP = '8.8.8.8' |
| 40 | HOST = "10.1.0.1" |
| 41 | USER = "vagrant" |
| 42 | PASS = "vagrant" |
| 43 | head_node = os.getenv('HEAD_NODE', 'prod') |
| 44 | HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node |
| 45 | test_path = os.path.dirname(os.path.realpath(__file__)) |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 46 | |
| 47 | @classmethod |
| 48 | def setUpClass(cls): |
| 49 | OnboardingServiceUtils.setUp() |
| 50 | |
| 51 | @classmethod |
| 52 | def tearDownClass(cls): |
| 53 | OnboardingServiceUtils.tearDown() |
| 54 | |
| 55 | def cliEnter(self, controller = None): |
| 56 | retries = 0 |
| 57 | while retries < 30: |
| 58 | self.cli = OnosCliDriver(controller = controller, connect = True) |
| 59 | if self.cli.handle: |
| 60 | break |
| 61 | else: |
| 62 | retries += 1 |
| 63 | time.sleep(2) |
| 64 | |
| 65 | def cliExit(self): |
| 66 | self.cli.disconnect() |
| 67 | |
| 68 | def onos_shutdown(self, controller = None): |
| 69 | status = True |
| 70 | self.cliEnter(controller = controller) |
| 71 | try: |
| 72 | self.cli.shutdown(timeout = 10) |
| 73 | except: |
| 74 | log.info('Graceful shutdown of ONOS failed for controller: %s' %controller) |
| 75 | status = False |
| 76 | |
| 77 | self.cliExit() |
| 78 | return status |
| 79 | |
| 80 | def test_exampleservice_health(self): |
| 81 | """ |
| 82 | Algo: |
| 83 | 1. Login to compute node VM |
| 84 | 2. Get all exampleservice |
| 85 | 3. Ping to all exampleservice |
| 86 | 4. Verifying Ping success |
| 87 | """ |
| 88 | status = OnboardingServiceUtils.health_check() |
| 89 | assert_equal(status, True) |
| 90 | |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 91 | def test_exampleservice_for_login(self): |
| 92 | if self.on_podd is False: |
| 93 | return |
| 94 | exampleservices = OnboardingServiceUtils.get_exampleservices() |
| 95 | exampleservice_access_status = map(lambda exampleservice: exampleservice.check_access(), exampleservices) |
| 96 | status = filter(lambda st: st == False, exampleservice_access_status) |
| 97 | assert_equal(len(status), 0) |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 98 | |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 99 | def test_exampleservice_for_default_route_through_testclient(self): |
| 100 | if self.on_podd is False: |
| 101 | return |
| 102 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 103 | cmd = "sudo lxc exec testclient -- route | grep default" |
| 104 | status, output = ssh_agent.run_cmd(cmd) |
| 105 | assert_equal(status, True) |
| 106 | |
| 107 | def test_exampleservice_for_service_access_through_testclient(self): |
| 108 | if self.on_podd is False: |
| 109 | return |
| 110 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 111 | cmd = "lxc exec testclient -- ping -c 3 8.8.8.8" |
| 112 | status, output = ssh_agent.run_cmd(cmd) |
| 113 | assert_equal( status, True) |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 114 | |
| 115 | def test_exampleservice_for_apache_service(self): |
| 116 | pass |
| 117 | |
Chetan Gaonker | c685393 | 2017-04-24 22:16:37 +0000 | [diff] [blame] | 118 | def test_exampleservice_for_tenant_message(self): |
| 119 | pass |
| 120 | |
| 121 | def test_exampleservice_for_service_message(self): |
| 122 | pass |
| 123 | |
Chetan Gaonker | c1a4c8a | 2017-04-13 00:24:44 +0000 | [diff] [blame] | 124 | def test_exampleservice_using__curl(self): |
| 125 | pass |