blob: ec0efe6ab7f2d774bb608a6eb741221de3628d01 [file] [log] [blame]
Chetan Gaonkerc1a4c8a2017-04-13 00:24:44 +00001#
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#
16import unittest
17import os,sys
18import keystoneclient.v2_0.client as ksclient
19import keystoneclient.apiclient.exceptions
20import neutronclient.v2_0.client as nclient
21import neutronclient.common.exceptions
22from novaclient import client as nova_client
23from neutronclient.v2_0 import client as neutron_client
24import neutronclient.v2_0.client as neutronclient
25from nose.tools import assert_equal
26from CordTestUtils import get_mac, log_test
27from OnosCtrl import OnosCtrl
28from OnosFlowCtrl import OnosFlowCtrl
Chetan Gaonkerc1a4c8a2017-04-13 00:24:44 +000029from OnboardingServiceUtils import OnboardingServiceUtils
30from SSHTestAgent import SSHTestAgent
31import requests
32import time
33import json
34
35class onboarding_exchange():
Chetan Gaonkerc6853932017-04-24 22:16:37 +000036 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 Gaonkerc1a4c8a2017-04-13 00:24:44 +000046
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 Gaonkerc6853932017-04-24 22:16:37 +000091 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 Gaonkerc1a4c8a2017-04-13 00:24:44 +000098
Chetan Gaonkerc6853932017-04-24 22:16:37 +000099 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 Gaonkerc1a4c8a2017-04-13 00:24:44 +0000114
115 def test_exampleservice_for_apache_service(self):
116 pass
117
Chetan Gaonkerc6853932017-04-24 22:16:37 +0000118 def test_exampleservice_for_tenant_message(self):
119 pass
120
121 def test_exampleservice_for_service_message(self):
122 pass
123
Chetan Gaonkerc1a4c8a2017-04-13 00:24:44 +0000124 def test_exampleservice_using__curl(self):
125 pass