blob: 17c0b6f7b6d8474e71cff1861c4ff5867be5d2cd [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
A R Karthick19771192017-04-25 14:57:05 -070031from CordTestUtils import running_on_pod
Chetan Gaonkerc1a4c8a2017-04-13 00:24:44 +000032import requests
33import time
34import json
35
36class onboarding_exchange():
Chetan Gaonkerc6853932017-04-24 22:16:37 +000037 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 Karthick19771192017-04-25 14:57:05 -070047 on_pod = running_on_pod()
Chetan Gaonkerc1a4c8a2017-04-13 00:24:44 +000048
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 Gaonkerc6853932017-04-24 22:16:37 +000093 def test_exampleservice_for_login(self):
A R Karthick19771192017-04-25 14:57:05 -070094 if self.on_pod is False:
Chetan Gaonkerc6853932017-04-24 22:16:37 +000095 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 Gaonkerc1a4c8a2017-04-13 00:24:44 +0000100
Chetan Gaonkerc6853932017-04-24 22:16:37 +0000101 def test_exampleservice_for_default_route_through_testclient(self):
Chetan Gaonker4cff4432017-05-01 17:56:56 +0000102 if self.on_pod is False:
Chetan Gaonkerc6853932017-04-24 22:16:37 +0000103 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 Karthick19771192017-04-25 14:57:05 -0700110 if self.on_pod is False:
Chetan Gaonkerc6853932017-04-24 22:16:37 +0000111 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 Gaonkerc1a4c8a2017-04-13 00:24:44 +0000116
117 def test_exampleservice_for_apache_service(self):
118 pass
119
Chetan Gaonkerc6853932017-04-24 22:16:37 +0000120 def test_exampleservice_for_tenant_message(self):
121 pass
122
123 def test_exampleservice_for_service_message(self):
124 pass
125
Chetan Gaonker4cff4432017-05-01 17:56:56 +0000126 def test_exampleservice_using_curl(self):
Chetan Gaonkerc1a4c8a2017-04-13 00:24:44 +0000127 pass