added fixtures for drs ineligible error and listing cg's and completed tests
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/0346c30f Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/0346c30f Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/0346c30f Branch: refs/heads/trunk Commit: 0346c30f26764f7cb63b71e6c321eed7c0b22f22 Parents: c32aa10 Author: mitch <[email protected]> Authored: Thu Nov 1 11:37:12 2018 -0400 Committer: mitch <[email protected]> Committed: Thu Nov 1 11:37:12 2018 -0400 ---------------------------------------------------------------------- libcloud/test/compute/test_nttcis.py | 2 +- .../fixtures/nttcis/list_consistency_groups.xml | 25 ++++++++++++++ libcloud/test/drs/test_nttcis.py | 35 ++++++++++++++++---- 3 files changed, 55 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/0346c30f/libcloud/test/compute/test_nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_nttcis.py b/libcloud/test/compute/test_nttcis.py index b223ea6..61a4756 100644 --- a/libcloud/test/compute/test_nttcis.py +++ b/libcloud/test/compute/test_nttcis.py @@ -798,7 +798,7 @@ def test_ex_list_network_domains_ALLFILTERS(driver): def test_ex_list_vlans(driver): vlans = driver.ex_list_vlans() - assert vlans[0].name == "Primary" + assert vlans[0].name == "Primary" def test_ex_list_vlans_ALLFILTERS(driver): http://git-wip-us.apache.org/repos/asf/libcloud/blob/0346c30f/libcloud/test/drs/fixtures/nttcis/list_consistency_groups.xml ---------------------------------------------------------------------- diff --git a/libcloud/test/drs/fixtures/nttcis/list_consistency_groups.xml b/libcloud/test/drs/fixtures/nttcis/list_consistency_groups.xml new file mode 100644 index 0000000..8b1a936 --- /dev/null +++ b/libcloud/test/drs/fixtures/nttcis/list_consistency_groups.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<consistencyGroups xmlns="urn:didata.com:api:cloud:types" pageNumber="1" pageCount="1" totalCount="1" pageSize="250"> + <consistencyGroup id="3710c093-7dcc-4a21-bd07-af9f4d93b6b5"> + <name>sdk_test2_cg</name> + <description>A test consistency group</description> + <journal sizeGb="100" extentCount="1"/> + <source datacenterId="NADRAASLAB01" networkDomainId="f9d6a249-c922-4fa1-9f0f-de5b452c4026"> + <networkDomainName>DRS-ProdEng-East-ND1</networkDomainName> + </source> + <target datacenterId="NADRAASLAB02" networkDomainId="e46c8815-193f-402d-b8a5-682eaa646fb2"> + <networkDomainName>DRS-ProdEng-West-ND1</networkDomainName> + </target> + <serverPair id="de9f0a6b-db84-4ffa-aacf-796f694c29f2" state="NORMAL"> + <sourceServer id="032f3967-00e4-4780-b4ef-8587460f9dd4" primaryNicIpv4="192.168.12.8" primaryNicIpv6="2607:f480:111:1426:3dc9:25dc:4985:81b2"> + <name>src-sdk-test</name> + </sourceServer> + <targetServer id="aee58575-38e2-495f-89d3-854e6a886411" primaryNicIpv4="192.168.22.7" primaryNicIpv6="2607:f480:211:1159:2dff:40ed:ee7c:4738"> + <name>tgt-sdk-test</name></targetServer></serverPair> + <createTime>2018-10-31T16:02:05.000Z</createTime> + <operationStatus>DRS_MODE</operationStatus> + <drsInfrastructure enabled="true" status="ACTIVE" updateTime="2018-11-01T14:20:01.000Z"/> + <drsStatusCheckFailureCount>0</drsStatusCheckFailureCount> + <state>NORMAL</state> + </consistencyGroup> +</consistencyGroups> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/libcloud/blob/0346c30f/libcloud/test/drs/test_nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/test/drs/test_nttcis.py b/libcloud/test/drs/test_nttcis.py index a90f9e2..c460c74 100644 --- a/libcloud/test/drs/test_nttcis.py +++ b/libcloud/test/drs/test_nttcis.py @@ -27,13 +27,20 @@ def driver(): def test_ineligible_server(driver): - exception_msg = driver.create_consistency_group( - "sdk_test2_cg", "100", "032f3967-00e4-4780-b4ef-8587460f9dd4", - "aee58575-38e2-495f-89d3-854e6a886411", - description="A test consistency group") + NttCisMockHttp.type = 'INPROGRESS' + with pytest.raises(NttCisAPIException) as excinfo: + driver.create_consistency_group( + "sdk_test2_cg", "100", "032f3967-00e4-4780-b4ef-8587460f9dd4", + "aee58575-38e2-495f-89d3-854e6a886411", + description="A test consistency group") + assert excinfo.value.msg == 'The drsEligible flag for target Server ' \ + 'aee58575-38e2-495f-89d3-854e6a886411 must be set.' - assert exception_msg == 'The drsEligible flag for target Server aee58575-38e2-495f-89d3-854e6a886411 must be set.' +def test_list_consistency_groups(driver): + cgs = driver.list_consistency_groups() + assert isinstance(cgs, list) + assert hasattr(cgs[0], 'serverPair') class NttCisMockHttp(MockHttp): @@ -44,8 +51,24 @@ class NttCisMockHttp(MockHttp): body = self.fixtures.load('oec_0_9_myaccount.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) - def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_createConsistencyGroup(self, method, url, body, headers): + def _oec_0_9_myaccount_INPROGRESS(self, method, url, body, headers): + body = self.fixtures.load('oec_0_9_myaccount.xml') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + + def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_createConsistencyGroup_INPROGRESS(self, + method, + url, + body, + headers): body = self.fixtures.load( 'drs_ineligible.xml' ) + return (httplib.BAD_REQUEST, body, {}, httplib.responses[httplib.OK]) + + def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_consistencyGroup_consistencyGroup(self, + method, + url, + body, + headers): + body = self.fixtures.load("list_consistency_groups.xml") return (httplib.OK, body, {}, httplib.responses[httplib.OK]) \ No newline at end of file
