You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by shwetaag <gi...@git.apache.org> on 2015/07/31 10:36:17 UTC

[GitHub] cloudstack pull request: test case automated for list template pag...

GitHub user shwetaag opened a pull request:

    https://github.com/apache/cloudstack/pull/646

    test case automated for list template pagination

    verify list template gives same result with page size=500&page=(1,2) and page size=1000 when there are around 1000 templates .
    Moved one test case from component folder to maint folder as it requires MS restart

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shwetaag/cloudstack customer_escalations

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cloudstack/pull/646.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #646
    
----
commit d1311b90ac0764bd137f7140572a71a7b33da10c
Author: shweta agarwal <sh...@citrix.com>
Date:   2015-07-30T11:57:22Z

    test case automated for list template pagination

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: test case automated for list template pag...

Posted by shwetaag <gi...@git.apache.org>.
Github user shwetaag commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/646#discussion_r36621050
  
    --- Diff: test/integration/component/maint/test_escalation_templates.py ---
    @@ -0,0 +1,394 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you 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 marvin.cloudstackTestCase import cloudstackTestCase, unittest
    +from marvin.lib.base import (Account,
    +                             Domain, Template, Configurations,VirtualMachine,Snapshot,ServiceOffering
    +                             )
    +from marvin.lib.utils import (cleanup_resources, validateList)
    +from marvin.lib.common import (get_zone, get_template, get_builtin_template_info,update_resource_limit,list_volumes )
    +from nose.plugins.attrib import attr
    +from marvin.codes import PASS
    +from marvin.sshClient import SshClient
    +from marvin.cloudstackException import CloudstackAPIException
    +import time
    +
    +
    +class TestlistTemplates(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +
    +        testClient = super(
    +            TestlistTemplates, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
    +        cls.template = get_template(
    +                cls.apiclient,
    +                cls.zone.id,
    +                cls.testdata["ostype"]
    +            )
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +        builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id)
    +        cls.testdata["templates"]["url"] = builtin_info[0]
    +        cls.testdata["templates"]["hypervisor"] = builtin_info[1]
    +        cls.testdata["templates"]["format"] = builtin_info[2]
    +        if cls.zone.localstorageenabled:
    +            cls.storagetype = 'local'
    +            cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'local'
    +            cls.testdata["disk_offering"]["storagetype"] = 'local'
    +        else:
    +            cls.storagetype = 'shared'
    +            cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'shared'
    +            cls.testdata["disk_offering"]["storagetype"] = 'shared'
    +        cls.testdata["virtual_machine"]["hypervisor"] = cls.hypervisor
    +        cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id
    +        cls.testdata["virtual_machine"]["template"] = cls.template.id
    +        cls.testdata["custom_volume"]["zoneid"] = cls.zone.id
    +        cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offerings"]["tiny"]
    +            )
    +        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
    +        cls.cleanup = []
    +
    +        # Create 1 domain admin account
    +
    +        cls.domain = Domain.create(
    +            cls.apiclient,
    +            cls.testdata["domain"])
    +
    +        cls.account = Account.create(
    +            cls.apiclient,
    +            cls.testdata["account"],
    +            admin=True,
    +            domainid=cls.domain.id)
    +
    +        cls.debug("Created account %s in domain %s" %
    +                  (cls.account.name, cls.domain.id))
    +
    +        cls.cleanup.append(cls.account)
    +        cls.cleanup.append(cls.domain)
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            # Cleanup resources used
    +            cleanup_resources(cls.apiclient, cls.cleanup)
    +
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +    def RestartServers(self):
    +        """ Restart management server and usage server """
    +
    +        sshClient = SshClient(
    +            self.mgtSvrDetails["mgtSvrIp"],
    +            22,
    +            self.mgtSvrDetails["user"],
    +            self.mgtSvrDetails["passwd"]
    +        )
    +        command = "service cloudstack-management restart"
    +        sshClient.execute(command)
    +        return
    +
    +    def updateConfigurAndRestart(self,name, value):
    +        Configurations.update(self.apiclient,
    +                              name,value )
    +        self.RestartServers()
    +        time.sleep(self.testdata["sleep"])
    +      
    +      
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_01_CS40139_listtemplate_with_different_pagesize(self):
    +        """
    +        @Desc verify list template gives same result with pagesize=500&page=(1,2) and pagesize=1000 when
    +        there are around 1000 templates
    +        @steps:
    +        1: register around 850 templates
    +        2. call list template api with pagesize=500&page=1 and then page=2
    +        3.call list template api with pagesize=1000 & page=1
    +        4. Verify list template returns same list of template in both step 2 and 3
    +        """
    +        if self.hypervisor.lower() not in ['xenserver']:
    +            raise unittest.SkipTest("hypervisor in not xenserver")
    +            return
    +        self.updateConfigurAndRestart("default.page.size", "1000")
    +        self.debug("Updating template resource limit for account: %s" %
    +                                                self.account.name)
    +        # Set usage_template=1000 for Account 1
    +        update_resource_limit(
    +                              self.apiclient,
    +                              4, # Template
    +                              account=self.account.name,
    +                              domainid=self.domain.id,
    +                              max=1000
    +                              )
    +        
    +        self.testdata["template"]["url"]= "http://10.147.28.7/templates/DOS.vhd.bz2"
    +        self.testdata["template"]["format"]="VHD"
    +        for i in range(0, 850):
    +            template_created = Template.register(
    +                self.apiclient,
    +                self.testdata["template"],
    +                zoneid=self.zone.id,
    +                hypervisor=self.hypervisor,
    +                account=self.account.name,
    +                domainid=self.domain.id
    +            )
    +            self.assertIsNotNone(
    +                template_created,
    +                "Template creation failed"
    +            )
    +        listfirst500template = Template.list(
    --- End diff --
    
    Done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: test case automated for list template pag...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/cloudstack/pull/646


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: test case automated for list template pag...

Posted by sanju1010 <gi...@git.apache.org>.
Github user sanju1010 commented on the pull request:

    https://github.com/apache/cloudstack/pull/646#issuecomment-129424914
  
    LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: test case automated for list template pag...

Posted by shwetaag <gi...@git.apache.org>.
Github user shwetaag commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/646#discussion_r36620849
  
    --- Diff: test/integration/component/maint/test_escalation_templates.py ---
    @@ -0,0 +1,394 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you 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 marvin.cloudstackTestCase import cloudstackTestCase, unittest
    +from marvin.lib.base import (Account,
    +                             Domain, Template, Configurations,VirtualMachine,Snapshot,ServiceOffering
    +                             )
    +from marvin.lib.utils import (cleanup_resources, validateList)
    +from marvin.lib.common import (get_zone, get_template, get_builtin_template_info,update_resource_limit,list_volumes )
    +from nose.plugins.attrib import attr
    +from marvin.codes import PASS
    +from marvin.sshClient import SshClient
    +from marvin.cloudstackException import CloudstackAPIException
    +import time
    +
    +
    +class TestlistTemplates(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +
    +        testClient = super(
    +            TestlistTemplates, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
    +        cls.template = get_template(
    +                cls.apiclient,
    +                cls.zone.id,
    +                cls.testdata["ostype"]
    +            )
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +        builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id)
    +        cls.testdata["templates"]["url"] = builtin_info[0]
    +        cls.testdata["templates"]["hypervisor"] = builtin_info[1]
    +        cls.testdata["templates"]["format"] = builtin_info[2]
    +        if cls.zone.localstorageenabled:
    +            cls.storagetype = 'local'
    +            cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'local'
    +            cls.testdata["disk_offering"]["storagetype"] = 'local'
    +        else:
    +            cls.storagetype = 'shared'
    +            cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'shared'
    +            cls.testdata["disk_offering"]["storagetype"] = 'shared'
    +        cls.testdata["virtual_machine"]["hypervisor"] = cls.hypervisor
    +        cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id
    +        cls.testdata["virtual_machine"]["template"] = cls.template.id
    +        cls.testdata["custom_volume"]["zoneid"] = cls.zone.id
    +        cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offerings"]["tiny"]
    +            )
    +        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
    +        cls.cleanup = []
    +
    +        # Create 1 domain admin account
    +
    +        cls.domain = Domain.create(
    +            cls.apiclient,
    +            cls.testdata["domain"])
    +
    +        cls.account = Account.create(
    +            cls.apiclient,
    +            cls.testdata["account"],
    +            admin=True,
    +            domainid=cls.domain.id)
    +
    +        cls.debug("Created account %s in domain %s" %
    +                  (cls.account.name, cls.domain.id))
    +
    +        cls.cleanup.append(cls.account)
    +        cls.cleanup.append(cls.domain)
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            # Cleanup resources used
    +            cleanup_resources(cls.apiclient, cls.cleanup)
    +
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +    def RestartServers(self):
    +        """ Restart management server and usage server """
    +
    +        sshClient = SshClient(
    +            self.mgtSvrDetails["mgtSvrIp"],
    +            22,
    +            self.mgtSvrDetails["user"],
    +            self.mgtSvrDetails["passwd"]
    +        )
    +        command = "service cloudstack-management restart"
    +        sshClient.execute(command)
    +        return
    +
    +    def updateConfigurAndRestart(self,name, value):
    +        Configurations.update(self.apiclient,
    +                              name,value )
    +        self.RestartServers()
    +        time.sleep(self.testdata["sleep"])
    +      
    +      
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_01_CS40139_listtemplate_with_different_pagesize(self):
    +        """
    +        @Desc verify list template gives same result with pagesize=500&page=(1,2) and pagesize=1000 when
    +        there are around 1000 templates
    +        @steps:
    +        1: register around 850 templates
    +        2. call list template api with pagesize=500&page=1 and then page=2
    +        3.call list template api with pagesize=1000 & page=1
    +        4. Verify list template returns same list of template in both step 2 and 3
    +        """
    +        if self.hypervisor.lower() not in ['xenserver']:
    +            raise unittest.SkipTest("hypervisor in not xenserver")
    +            return
    +        self.updateConfigurAndRestart("default.page.size", "1000")
    +        self.debug("Updating template resource limit for account: %s" %
    +                                                self.account.name)
    +        # Set usage_template=1000 for Account 1
    +        update_resource_limit(
    +                              self.apiclient,
    +                              4, # Template
    +                              account=self.account.name,
    +                              domainid=self.domain.id,
    +                              max=1000
    +                              )
    +        
    +        self.testdata["template"]["url"]= "http://10.147.28.7/templates/DOS.vhd.bz2"
    --- End diff --
    
    Done


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: test case automated for list template pag...

Posted by sanju1010 <gi...@git.apache.org>.
Github user sanju1010 commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/646#discussion_r36072278
  
    --- Diff: test/integration/component/maint/test_escalation_templates.py ---
    @@ -0,0 +1,394 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you 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 marvin.cloudstackTestCase import cloudstackTestCase, unittest
    +from marvin.lib.base import (Account,
    +                             Domain, Template, Configurations,VirtualMachine,Snapshot,ServiceOffering
    +                             )
    +from marvin.lib.utils import (cleanup_resources, validateList)
    +from marvin.lib.common import (get_zone, get_template, get_builtin_template_info,update_resource_limit,list_volumes )
    +from nose.plugins.attrib import attr
    +from marvin.codes import PASS
    +from marvin.sshClient import SshClient
    +from marvin.cloudstackException import CloudstackAPIException
    +import time
    +
    +
    +class TestlistTemplates(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +
    +        testClient = super(
    +            TestlistTemplates, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
    +        cls.template = get_template(
    +                cls.apiclient,
    +                cls.zone.id,
    +                cls.testdata["ostype"]
    +            )
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +        builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id)
    +        cls.testdata["templates"]["url"] = builtin_info[0]
    +        cls.testdata["templates"]["hypervisor"] = builtin_info[1]
    +        cls.testdata["templates"]["format"] = builtin_info[2]
    +        if cls.zone.localstorageenabled:
    +            cls.storagetype = 'local'
    +            cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'local'
    +            cls.testdata["disk_offering"]["storagetype"] = 'local'
    +        else:
    +            cls.storagetype = 'shared'
    +            cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'shared'
    +            cls.testdata["disk_offering"]["storagetype"] = 'shared'
    +        cls.testdata["virtual_machine"]["hypervisor"] = cls.hypervisor
    +        cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id
    +        cls.testdata["virtual_machine"]["template"] = cls.template.id
    +        cls.testdata["custom_volume"]["zoneid"] = cls.zone.id
    +        cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offerings"]["tiny"]
    +            )
    +        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
    +        cls.cleanup = []
    +
    +        # Create 1 domain admin account
    +
    +        cls.domain = Domain.create(
    +            cls.apiclient,
    +            cls.testdata["domain"])
    +
    +        cls.account = Account.create(
    +            cls.apiclient,
    +            cls.testdata["account"],
    +            admin=True,
    +            domainid=cls.domain.id)
    +
    +        cls.debug("Created account %s in domain %s" %
    +                  (cls.account.name, cls.domain.id))
    +
    +        cls.cleanup.append(cls.account)
    +        cls.cleanup.append(cls.domain)
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            # Cleanup resources used
    +            cleanup_resources(cls.apiclient, cls.cleanup)
    +
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +    def RestartServers(self):
    +        """ Restart management server and usage server """
    +
    +        sshClient = SshClient(
    +            self.mgtSvrDetails["mgtSvrIp"],
    +            22,
    +            self.mgtSvrDetails["user"],
    +            self.mgtSvrDetails["passwd"]
    +        )
    +        command = "service cloudstack-management restart"
    +        sshClient.execute(command)
    +        return
    +
    +    def updateConfigurAndRestart(self,name, value):
    +        Configurations.update(self.apiclient,
    +                              name,value )
    +        self.RestartServers()
    +        time.sleep(self.testdata["sleep"])
    +      
    +      
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_01_CS40139_listtemplate_with_different_pagesize(self):
    +        """
    +        @Desc verify list template gives same result with pagesize=500&page=(1,2) and pagesize=1000 when
    +        there are around 1000 templates
    +        @steps:
    +        1: register around 850 templates
    +        2. call list template api with pagesize=500&page=1 and then page=2
    +        3.call list template api with pagesize=1000 & page=1
    +        4. Verify list template returns same list of template in both step 2 and 3
    +        """
    +        if self.hypervisor.lower() not in ['xenserver']:
    +            raise unittest.SkipTest("hypervisor in not xenserver")
    +            return
    +        self.updateConfigurAndRestart("default.page.size", "1000")
    +        self.debug("Updating template resource limit for account: %s" %
    +                                                self.account.name)
    +        # Set usage_template=1000 for Account 1
    +        update_resource_limit(
    +                              self.apiclient,
    +                              4, # Template
    +                              account=self.account.name,
    +                              domainid=self.domain.id,
    +                              max=1000
    +                              )
    +        
    +        self.testdata["template"]["url"]= "http://10.147.28.7/templates/DOS.vhd.bz2"
    --- End diff --
    
    Please don't use hard coded values.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: test case automated for list template pag...

Posted by nitt10prashant <gi...@git.apache.org>.
Github user nitt10prashant commented on the pull request:

    https://github.com/apache/cloudstack/pull/646#issuecomment-130588174
  
    LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cloudstack pull request: test case automated for list template pag...

Posted by sanju1010 <gi...@git.apache.org>.
Github user sanju1010 commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/646#discussion_r36072298
  
    --- Diff: test/integration/component/maint/test_escalation_templates.py ---
    @@ -0,0 +1,394 @@
    +# Licensed to the Apache Software Foundation (ASF) under one
    +# or more contributor license agreements.  See the NOTICE file
    +# distributed with this work for additional information
    +# regarding copyright ownership.  The ASF licenses this file
    +# to you 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 marvin.cloudstackTestCase import cloudstackTestCase, unittest
    +from marvin.lib.base import (Account,
    +                             Domain, Template, Configurations,VirtualMachine,Snapshot,ServiceOffering
    +                             )
    +from marvin.lib.utils import (cleanup_resources, validateList)
    +from marvin.lib.common import (get_zone, get_template, get_builtin_template_info,update_resource_limit,list_volumes )
    +from nose.plugins.attrib import attr
    +from marvin.codes import PASS
    +from marvin.sshClient import SshClient
    +from marvin.cloudstackException import CloudstackAPIException
    +import time
    +
    +
    +class TestlistTemplates(cloudstackTestCase):
    +
    +    @classmethod
    +    def setUpClass(cls):
    +
    +        testClient = super(
    +            TestlistTemplates, cls).getClsTestClient()
    +        cls.apiclient = testClient.getApiClient()
    +        cls.testdata = testClient.getParsedTestDataConfig()
    +        cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
    +        cls.template = get_template(
    +                cls.apiclient,
    +                cls.zone.id,
    +                cls.testdata["ostype"]
    +            )
    +        cls.hypervisor = cls.testClient.getHypervisorInfo()
    +        builtin_info = get_builtin_template_info(cls.apiclient, cls.zone.id)
    +        cls.testdata["templates"]["url"] = builtin_info[0]
    +        cls.testdata["templates"]["hypervisor"] = builtin_info[1]
    +        cls.testdata["templates"]["format"] = builtin_info[2]
    +        if cls.zone.localstorageenabled:
    +            cls.storagetype = 'local'
    +            cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'local'
    +            cls.testdata["disk_offering"]["storagetype"] = 'local'
    +        else:
    +            cls.storagetype = 'shared'
    +            cls.testdata["service_offerings"]["tiny"]["storagetype"] = 'shared'
    +            cls.testdata["disk_offering"]["storagetype"] = 'shared'
    +        cls.testdata["virtual_machine"]["hypervisor"] = cls.hypervisor
    +        cls.testdata["virtual_machine"]["zoneid"] = cls.zone.id
    +        cls.testdata["virtual_machine"]["template"] = cls.template.id
    +        cls.testdata["custom_volume"]["zoneid"] = cls.zone.id
    +        cls.service_offering = ServiceOffering.create(
    +                cls.apiclient,
    +                cls.testdata["service_offerings"]["tiny"]
    +            )
    +        cls.mgtSvrDetails = cls.config.__dict__["mgtSvr"][0].__dict__
    +        cls.cleanup = []
    +
    +        # Create 1 domain admin account
    +
    +        cls.domain = Domain.create(
    +            cls.apiclient,
    +            cls.testdata["domain"])
    +
    +        cls.account = Account.create(
    +            cls.apiclient,
    +            cls.testdata["account"],
    +            admin=True,
    +            domainid=cls.domain.id)
    +
    +        cls.debug("Created account %s in domain %s" %
    +                  (cls.account.name, cls.domain.id))
    +
    +        cls.cleanup.append(cls.account)
    +        cls.cleanup.append(cls.domain)
    +
    +    @classmethod
    +    def tearDownClass(cls):
    +        try:
    +            # Cleanup resources used
    +            cleanup_resources(cls.apiclient, cls.cleanup)
    +
    +        except Exception as e:
    +            raise Exception("Warning: Exception during cleanup : %s" % e)
    +        return
    +    def RestartServers(self):
    +        """ Restart management server and usage server """
    +
    +        sshClient = SshClient(
    +            self.mgtSvrDetails["mgtSvrIp"],
    +            22,
    +            self.mgtSvrDetails["user"],
    +            self.mgtSvrDetails["passwd"]
    +        )
    +        command = "service cloudstack-management restart"
    +        sshClient.execute(command)
    +        return
    +
    +    def updateConfigurAndRestart(self,name, value):
    +        Configurations.update(self.apiclient,
    +                              name,value )
    +        self.RestartServers()
    +        time.sleep(self.testdata["sleep"])
    +      
    +      
    +    @attr(tags=["advanced", "basic"], required_hardware="true")
    +    def test_01_CS40139_listtemplate_with_different_pagesize(self):
    +        """
    +        @Desc verify list template gives same result with pagesize=500&page=(1,2) and pagesize=1000 when
    +        there are around 1000 templates
    +        @steps:
    +        1: register around 850 templates
    +        2. call list template api with pagesize=500&page=1 and then page=2
    +        3.call list template api with pagesize=1000 & page=1
    +        4. Verify list template returns same list of template in both step 2 and 3
    +        """
    +        if self.hypervisor.lower() not in ['xenserver']:
    +            raise unittest.SkipTest("hypervisor in not xenserver")
    +            return
    +        self.updateConfigurAndRestart("default.page.size", "1000")
    +        self.debug("Updating template resource limit for account: %s" %
    +                                                self.account.name)
    +        # Set usage_template=1000 for Account 1
    +        update_resource_limit(
    +                              self.apiclient,
    +                              4, # Template
    +                              account=self.account.name,
    +                              domainid=self.domain.id,
    +                              max=1000
    +                              )
    +        
    +        self.testdata["template"]["url"]= "http://10.147.28.7/templates/DOS.vhd.bz2"
    +        self.testdata["template"]["format"]="VHD"
    +        for i in range(0, 850):
    +            template_created = Template.register(
    +                self.apiclient,
    +                self.testdata["template"],
    +                zoneid=self.zone.id,
    +                hypervisor=self.hypervisor,
    +                account=self.account.name,
    +                domainid=self.domain.id
    +            )
    +            self.assertIsNotNone(
    +                template_created,
    +                "Template creation failed"
    +            )
    +        listfirst500template = Template.list(
    --- End diff --
    
    Validate the list. Applicable to all other list operations.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---