blob: 461f961e023e9fe05c187df1121ad408fda0bf54 [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07001
2# Copyright 2017-present Open Networking Foundation
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
A R Karthick76a497a2017-04-12 10:59:39 -070017#
A R Karthick07608ef2016-08-23 16:51:19 -070018# Copyright 2016-present Ciena Corporation
19#
20# Licensed under the Apache License, Version 2.0 (the "License");
21# you may not use this file except in compliance with the License.
22# You may obtain a copy of the License at
A R Karthick76a497a2017-04-12 10:59:39 -070023#
A R Karthick07608ef2016-08-23 16:51:19 -070024# http://www.apache.org/licenses/LICENSE-2.0
A R Karthick76a497a2017-04-12 10:59:39 -070025#
A R Karthick07608ef2016-08-23 16:51:19 -070026# Unless required by applicable law or agreed to in writing, software
27# distributed under the License is distributed on an "AS IS" BASIS,
28# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29# See the License for the specific language governing permissions and
30# limitations under the License.
31#
32import unittest
33from nose.tools import *
34from nose.twistedtools import reactor, deferred
35from twisted.internet import defer
36from TestManifest import TestManifest
37from Fabric import FabricMAAS, Fabric
A R Karthick76a497a2017-04-12 10:59:39 -070038from CordTestUtils import log_test as log
A R Karthick07608ef2016-08-23 16:51:19 -070039import os
40log.setLevel('INFO')
41
42class fabric_exchange(unittest.TestCase):
43
44 node_list = []
45 fabric = None
46 FABRIC_TEST_TIMEOUT = 30
47 key_file = os.getenv('SSH_KEY_FILE', None)
48 api_key = os.getenv('MAAS_API_KEY', 'UNKNOWN')
49
50 @classmethod
51 def setUpClass(cls):
52 if cls.api_key == 'UNKNOWN':
53 return
54 maas = FabricMAAS(api_key = cls.api_key)
55 cls.node_list = maas.get_node_list()
56 cls.fabric = Fabric(cls.node_list, key_file = cls.key_file, verbose = False)
57
58 @deferred(FABRIC_TEST_TIMEOUT)
59 def test_fabric(self):
60 """Test the connectivity between the compute nodes"""
61 df = defer.Deferred()
62 def verify_fabric(df):
63 assert_not_equal(self.fabric, None)
64 failed_nodes = []
65 failed_nodes = self.fabric.ping_neighbors()
66 if failed_nodes:
67 log.info('Failed nodes: %s' %failed_nodes)
68 for node, neighbor, _ in failed_nodes:
69 log.info('Ping from node %s to neighbor %s Failed' %(node, neighbor))
70 assert_equal(len(failed_nodes), 0)
71 df.callback(0)
72 reactor.callLater(0, verify_fabric, df)
73 return df