-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* updating history Signed-off-by: vvb <[email protected]> * support for native serialization and deserialization Signed-off-by: vvb <[email protected]> * fixing the test for the version changes Signed-off-by: vvb <[email protected]> * restoring driver when proxy is configured. adding more tests Signed-off-by: vvb <[email protected]>
- Loading branch information
Showing
7 changed files
with
209 additions
and
15 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,22 @@ | ||
# Copyright 2017 Cisco Systems, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from ..connection.info import custom_setup, custom_teardown | ||
from ucsmsdk.ucshandle import UcsHandle | ||
|
||
|
||
def test_serialize_handle(): | ||
handle1 = custom_setup() | ||
frozen_handle = handle1.freeze() | ||
handle2 = UcsHandle.unfreeze(frozen_handle) | ||
custom_teardown(handle2) |
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,67 @@ | ||
# Copyright 2017 Cisco Systems, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from nose.tools import with_setup, assert_equal | ||
import threading | ||
from ..connection.info import custom_setup, custom_teardown | ||
|
||
handle = None | ||
|
||
|
||
def setup_module(): | ||
global handle | ||
handle = custom_setup() | ||
|
||
|
||
def teardown_module(): | ||
custom_teardown(handle) | ||
|
||
|
||
def t1_func(): | ||
from ucsmsdk.mometa.ls.LsServer import LsServer | ||
obj = LsServer("org-root", "temp_sp1") | ||
handle.add_mo(obj) | ||
|
||
|
||
def t2_func(): | ||
from ucsmsdk.mometa.ls.LsServer import LsServer | ||
obj1 = LsServer("org-root", "temp_sp2") | ||
obj2 = LsServer("org-root", "temp_sp3") | ||
handle.add_mo(obj1) | ||
handle.add_mo(obj2) | ||
|
||
|
||
@with_setup(setup_module, teardown_module) | ||
def test_test_threading_mode(): | ||
handle.set_mode_threading() | ||
|
||
t1 = threading.Thread(name="t1", target=t1_func) | ||
t2 = threading.Thread(name="t2", target=t2_func) | ||
|
||
t1.start() | ||
t2.start() | ||
|
||
t1.join() | ||
t2.join() | ||
|
||
# commit buffers should be in different contexts | ||
buf1 = handle._get_commit_buf(tag="t1") | ||
buf2 = handle._get_commit_buf(tag="t2") | ||
|
||
assert_equal(len(buf1), 1) | ||
assert_equal(len(buf2), 2) | ||
|
||
handle.commit_buffer_discard(tag="t1") | ||
handle.commit_buffer_discard(tag="t2") | ||
|
||
handle.unset_mode_threading() |
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,57 @@ | ||
# Copyright 2017 Cisco Systems, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from nose.tools import with_setup | ||
from ..connection.info import custom_setup, custom_teardown | ||
from ucsmsdk.utils.ucsbackup import backup_ucs | ||
from ucsmsdk.ucshandle import UcsHandle | ||
|
||
handle = None | ||
|
||
|
||
def setup_module(): | ||
global handle | ||
handle = custom_setup() | ||
|
||
|
||
def teardown_module(): | ||
custom_teardown(handle) | ||
|
||
|
||
def _test_ucs_backup(file_dir, file_name, backup_type): | ||
backup_ucs(handle, | ||
backup_type=backup_type, | ||
file_dir=file_dir, | ||
file_name=file_name) | ||
|
||
|
||
@with_setup(setup_module, teardown_module) | ||
def test_ucs_backup(): | ||
_test_ucs_backup(file_dir="/tmp/backup", | ||
file_name="config1.xml", | ||
backup_type="config-logical") | ||
|
||
|
||
def test_ucs_backup_after_freeze_unfreeze(): | ||
# for this test to be more meaningful there needs to be proxy server | ||
# configured | ||
h1 = custom_setup() | ||
frozen_handle = h1.freeze() | ||
h2 = UcsHandle.unfreeze(frozen_handle) | ||
|
||
# Try a download operation using new handle | ||
_test_ucs_backup(file_dir="/tmp/backup", | ||
file_name="config2.xml", | ||
backup_type="config-logical") | ||
|
||
custom_teardown(h2) |
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
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
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
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