Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add config check to detect duplicate forwarding class ID.
Currently forwarding class id has to be unique across each entry, adding a config check for same. Closes-bug:#1598675 Change-Id: I320539b6d1c93e285de388cfa5dfe41eee4084bb
- Loading branch information
Showing
2 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# | ||
# Copyright (c) 2013,2014 Juniper Networks, Inc. All rights reserved. | ||
# | ||
import gevent | ||
import os | ||
import sys | ||
import socket | ||
import errno | ||
import uuid | ||
import logging | ||
import coverage | ||
|
||
import cgitb | ||
cgitb.enable(format='text') | ||
|
||
import testtools | ||
from testtools.matchers import Equals, MismatchError, Not, Contains | ||
from testtools import content, content_type, ExpectedException | ||
import unittest | ||
import re | ||
import json | ||
import copy | ||
import inspect | ||
import pycassa | ||
import kombu | ||
import requests | ||
|
||
from vnc_api.vnc_api import * | ||
import vnc_api.gen.vnc_api_test_gen | ||
from vnc_api.gen.resource_test import * | ||
import cfgm_common | ||
|
||
sys.path.append('../common/tests') | ||
from test_utils import * | ||
import test_common | ||
import test_case | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(logging.DEBUG) | ||
|
||
class TestForwardingClassId(test_case.ApiServerTestCase): | ||
def __init__(self, *args, **kwargs): | ||
ch = logging.StreamHandler() | ||
ch.setLevel(logging.DEBUG) | ||
logger.addHandler(ch) | ||
super(TestForwardingClassId, self).__init__(*args, **kwargs) | ||
|
||
def test_requested_fc_id(self): | ||
fc1 = ForwardingClass(name = "fc1", | ||
forwarding_class_id = 1) | ||
fc1_id = self._vnc_lib.forwarding_class_create(fc1) | ||
logger.debug('Created Forwarding class with ID 1') | ||
|
||
test_fc = ForwardingClass(name = "test_fc", | ||
forwarding_class_id = 1) | ||
try: | ||
self._vnc_lib.forwarding_class_create(test_fc) | ||
self.assertTrue(False, 'Forwarding class updated' | ||
'with duplicate ID... Test failed!!') | ||
logger.debug(' Test failed! got id 1') | ||
except: | ||
logger.debug(' Test passed for FC id 1') | ||
|
||
|
||
fc2 = ForwardingClass(name = "fc2", | ||
forwarding_class_id = 2) | ||
fc2_id = self._vnc_lib.forwarding_class_create(fc2) | ||
logger.debug('Created Forwarding class with ID 2') | ||
|
||
fc1.forwarding_class_id = 2 | ||
try: | ||
self._vnc_lib.forwarding_class_update(fc1); | ||
self.assertTrue(False, 'Forwarding class updated' | ||
'with duplicate ID... Test failed!!') | ||
except: | ||
logger.debug(' Test passed for FC id 2') | ||
|
||
gevent.sleep(0.1) | ||
#cleanup | ||
logger.debug('Cleaning up FC test case') | ||
self._vnc_lib.forwarding_class_delete(id=fc1_id) | ||
self._vnc_lib.forwarding_class_delete(id=fc2_id) | ||
logger.debug('Cleaned up FC test case') | ||
#end | ||
|
||
#end class TestForwardingClass | ||
|
||
if __name__ == '__main__': | ||
ch = logging.StreamHandler() | ||
ch.setLevel(logging.DEBUG) | ||
logger.addHandler(ch) | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters