def test_host_tests_with_packages_in_distribution_perpackage(self):
        """Test distribution perpackage - host_tests"""

        expected_cmd_1 = ['conductor', 
                        '-u', 'http://image/url/image.bin', 
                        '-f', '-testsuite=testrunner-tests',
                        '-t', "foo", '-m', '30',
                        '-o']
        expected_cmd_2 = ['conductor', 
                        '-u', 'http://image/url/image.bin', 
                        '-f', '-testsuite=testrunner-tests',
                        '-t', "bar", '-m', '30',
                        '-o']

        distribution_model = "perpackage"
        image_url = 'http://image/url/image.bin'
        test_list = {'host':"foo,bar"}
        testrun_id = "" 
        storage_address = "" 
        test_filter = "-testsuite=testrunner-tests"  
        timeout = "30"
        rootstrap = ""

        commands = get_commands(distribution_model, 
                                image_url,
                                rootstrap,
                                test_list,
                                testrun_id,
                                storage_address,
                                test_filter,
                                timeout)
        
        self.assertEquals(len(commands), 2)
        self.assertEquals(commands[0].command, expected_cmd_1)
        self.assertEquals(commands[1].command, expected_cmd_2)
    def test_device_and_host_tests_no_flasher(self):
        """Check conductor command with packages for device and host, without flasherurl."""

        expected_cmds = ['conductor', 
                          '-u', 'http://image/url/image.bin',
                          '-f', '-testsuite=testrunner-tests',
                          '-t', "foo,bar,baz", '-m', '20',
                          ';',
                          'conductor',
                          '-u', 'http://image/url/image.bin', 
                          '-f', '-testsuite=testrunner-tests',
                          '-t', "foo,bar,baz", '-m', '20',
                          '-o']


        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_list = {'device':"foo,bar,baz",'host':"foo,bar,baz"}
        testrun_id = "" 
        storage_address = "" 
        test_filter = "-testsuite=testrunner-tests"  
        timeout = "20"
        rootstrap = ""

        cmds = get_commands(distribution_model,
                            image_url,
                            rootstrap,
                            test_list,
                            testrun_id,
                            storage_address,
                            test_filter,
                            timeout)
        
        self.assertEquals(cmds[0].command, expected_cmds)
    def test_device_tests_with_one_testplan(self):
        """Test device test plan based - one test plan"""

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_plan = StringIO("hulapaloo")
        test_plan.name = "testplan.xml"
        test_list = {'hw_testplans': [test_plan]}
        testrun_id = "" 
        storage_address = "" 
        test_filter = ""  
        timeout = "30"
        rootstrap = ""
        commands = get_commands(distribution_model, 
                                image_url, 
                                rootstrap,
                                test_list,
                                testrun_id,
                                storage_address,
                                test_filter,
                                timeout)

        expected_cmds = ['conductor', 
                          '-u', 'http://image/url/image.bin', 
                          '-m', '30', '-p', 'testplan.xml']


        self.assertEquals(len(commands), 1)
        self.assertEquals(commands[0].command, expected_cmds)
    def test_chroot_tests(self):
        """Check conductor command with test packages for chroot"""

        expected_cmds = ['conductor',
                          '-u', 'http://image/url/image.bin', 
                          '-f', '-testsuite=testrunner-tests',
                          '-t', "foo,bar,baz", '-m', '20',
                          '--chrooted', "--rootstrapurl=url_to_rootstrap"]

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_list = {'chroot':"foo,bar,baz"}
        testrun_id = "" 
        storage_address = "" 
        test_filter = "-testsuite=testrunner-tests"
        timeout = "20"
        rootstrap = "url_to_rootstrap"

        cmds = get_commands(distribution_model, 
                            image_url,
                            rootstrap,
                            test_list,
                            testrun_id,
                            storage_address,
                            test_filter,
                            timeout)

        self.assertEquals(cmds[0].command, expected_cmds)
Exemple #5
0
    def test_device_tests_with_packages_using_resume(self):
        """Check conductor command with test packages for device and resume
        functionality"""

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_list = {'device': "foo,bar,baz"}
        testrun_id = ""
        storage_address = ""
        test_filter = "-testsuite=testrunner-tests"
        timeout = "30"
        rootstrap = ""

        expected_cmds = [
            'conductor', '-u', 'http://image/url/image.bin', '-f',
            '-testsuite=testrunner-tests', '-t', "foo,bar,baz", '-m', '30',
            '--resume'
        ]

        cmds = get_commands(distribution_model,
                            image_url,
                            rootstrap,
                            test_list,
                            testrun_id,
                            storage_address,
                            test_filter,
                            timeout,
                            resume=True)

        self.assertEquals(cmds[0].command, expected_cmds)
    def test_custom_distribution_models(self):
        """Check that custom distribution models can be used"""
        self.model_called = 0

        def custom_model1(test_list, options):
            self.model_called = 1
            return ["asdf"]

        distribution_model = "custom1"
        image_url = 'http://image/url/image.bin'
        test_list = {'device':"foo,bar,baz"}
        testrun_id = "" 
        storage_address = "" 
        test_filter = "-testsuite=testrunner-tests"
        timeout = "60"
        rootstrap = ""

        expected_cmds = ["asdf"]
        
        cmds = get_commands(distribution_model, 
                            image_url,
                            rootstrap,
                            test_list,
                            testrun_id,
                            storage_address,
                            test_filter,
                            timeout,
                            custom_distribution_model = custom_model1)

        self.assertEquals(cmds, expected_cmds)
Exemple #7
0
    def test_host_tests_with_multiple_testplans_perpackage(self):
        """Test host test plan based - one test plan"""

        distribution_model = "perpackage"
        image_url = 'http://image/url/image.bin'
        test_plan = StringIO("hulapaloo")
        test_plan.name = "testplan.xml"
        test_plan2 = StringIO("hulapaloo2")
        test_plan2.name = "testplan2.xml"
        test_list = {'host_testplans': [test_plan, test_plan2]}
        testrun_id = ""
        storage_address = ""
        test_filter = ""
        timeout = "30"
        rootstrap = ""
        commands = get_commands(distribution_model, image_url, rootstrap,
                                test_list, testrun_id, storage_address,
                                test_filter, timeout)

        expected_cmd_1 = [
            'conductor', '-u', 'http://image/url/image.bin', '-m', '30', '-p',
            'testplan.xml', '-o'
        ]
        expected_cmd_2 = [
            'conductor', '-u', 'http://image/url/image.bin', '-m', '30', '-p',
            'testplan2.xml', '-o'
        ]

        self.assertEquals(len(commands), 2)
        self.assertEquals(commands[0].command, expected_cmd_1)
        self.assertEquals(commands[1].command, expected_cmd_2)
Exemple #8
0
    def test_device_and_host_tests_with_flasher(self):
        """
        Check conductor command with packages for device and host,
        with flasher URL.
        """

        expected_cmds = [
            'conductor', '-u', 'http://image/url/image.bin', '-f',
            '-testsuite=testrunner-tests', '--flasherurl', "asdfasdf/asdf",
            '-t', "foo,bar,baz", '-m', '60', ';', 'conductor', '-u',
            'http://image/url/image.bin', '-f', '-testsuite=testrunner-tests',
            '--flasherurl', "asdfasdf/asdf", '-t', "foo,bar,baz", '-m', '60',
            '-o'
        ]

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_list = {'device': "foo,bar,baz", 'host': "foo,bar,baz"}
        testrun_id = ""
        storage_address = ""
        test_filter = "-testsuite=testrunner-tests"
        timeout = "60"
        flasher = "asdfasdf/asdf"
        rootstrap = ""

        cmds = get_commands(distribution_model, image_url, rootstrap,
                            test_list, testrun_id, storage_address,
                            test_filter, timeout, flasher)

        self.assertEquals(cmds[0].command, expected_cmds)
Exemple #9
0
    def test_host_tests_with_packages_in_distribution_perpackage(self):
        """Test distribution perpackage - host_tests"""

        expected_cmd_1 = [
            'conductor', '-u', 'http://image/url/image.bin', '-f',
            '-testsuite=testrunner-tests', '-t', "foo", '-m', '30', '-o'
        ]
        expected_cmd_2 = [
            'conductor', '-u', 'http://image/url/image.bin', '-f',
            '-testsuite=testrunner-tests', '-t', "bar", '-m', '30', '-o'
        ]

        distribution_model = "perpackage"
        image_url = 'http://image/url/image.bin'
        test_list = {'host': "foo,bar"}
        testrun_id = ""
        storage_address = ""
        test_filter = "-testsuite=testrunner-tests"
        timeout = "30"
        rootstrap = ""

        commands = get_commands(distribution_model, image_url, rootstrap,
                                test_list, testrun_id, storage_address,
                                test_filter, timeout)

        self.assertEquals(len(commands), 2)
        self.assertEquals(commands[0].command, expected_cmd_1)
        self.assertEquals(commands[1].command, expected_cmd_2)
Exemple #10
0
    def test_custom_distribution_models(self):
        """Check that custom distribution models can be used"""
        self.model_called = 0

        def custom_model1(test_list, options):
            self.model_called = 1
            return ["asdf"]

        distribution_model = "custom1"
        image_url = 'http://image/url/image.bin'
        test_list = {'device': "foo,bar,baz"}
        testrun_id = ""
        storage_address = ""
        test_filter = "-testsuite=testrunner-tests"
        timeout = "60"
        rootstrap = ""

        expected_cmds = ["asdf"]

        cmds = get_commands(distribution_model,
                            image_url,
                            rootstrap,
                            test_list,
                            testrun_id,
                            storage_address,
                            test_filter,
                            timeout,
                            custom_distribution_model=custom_model1)

        self.assertEquals(cmds, expected_cmds)
    def test_device_tests_with_no_packages(self):
        """Check conductor command without test packages for device"""

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_list = {}
        testrun_id = "" 
        storage_address = "" 
        test_filter = "-testsuite=testrunner-tests"  
        timeout = "20"
        rootstrap = ""

        expected_cmds = ['conductor', 
                          '-u', 'http://image/url/image.bin', 
                          '-f', '-testsuite=testrunner-tests', '-m', '20']
        
        cmds = get_commands(distribution_model, 
                            image_url,
                            rootstrap,
                            test_list,
                            testrun_id,
                            storage_address,
                            test_filter,
                            timeout)
        
        self.assertEquals(cmds[0].command, expected_cmds)
    def test_device_tests_with_packages_using_resume(self):
        """Check conductor command with test packages for device and resume
        functionality"""

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_list = {'device':"foo,bar,baz"}
        testrun_id = ""
        storage_address = ""
        test_filter = "-testsuite=testrunner-tests"
        timeout = "30"
        rootstrap = ""

        expected_cmds = ['conductor',
                         '-u', 'http://image/url/image.bin',
                         '-f', '-testsuite=testrunner-tests',
                         '-t', "foo,bar,baz", '-m', '30', '--resume']
        
        cmds = get_commands(distribution_model, 
                            image_url,
                            rootstrap,
                            test_list,
                            testrun_id,
                            storage_address,
                            test_filter,
                            timeout,
                            resume=True)
        
        self.assertEquals(cmds[0].command, expected_cmds)
    def test_host_tests_with_multiple_testplans_perpackage(self):
        """Test host test plan based - one test plan"""

        distribution_model = "perpackage"
        image_url = 'http://image/url/image.bin'
        test_plan = StringIO("hulapaloo")
        test_plan.name = "testplan.xml"
        test_plan2 = StringIO("hulapaloo2")
        test_plan2.name = "testplan2.xml"
        test_list = {'host_testplans': [test_plan, test_plan2]}
        testrun_id = "" 
        storage_address = "" 
        test_filter = ""  
        timeout = "30"
        rootstrap = ""
        commands = get_commands(distribution_model, 
                                image_url,
                                rootstrap,
                                test_list,
                                testrun_id,
                                storage_address,
                                test_filter,
                                timeout)

        expected_cmd_1 = ['conductor', 
                          '-u', 'http://image/url/image.bin', 
                          '-m', '30', '-p', 'testplan.xml', '-o']
        expected_cmd_2 = ['conductor', 
                          '-u', 'http://image/url/image.bin', 
                          '-m', '30', '-p', 'testplan2.xml', '-o']


        self.assertEquals(len(commands), 2)
        self.assertEquals(commands[0].command, expected_cmd_1)
        self.assertEquals(commands[1].command, expected_cmd_2)
    def test_mixed_tests_with_multiple_testplans_and_pkgs(self):
        """Test host test plan based - one test plan"""

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_plan = StringIO("hulapaloo")
        test_plan.name = "testplan.xml"
        test_plan2 = StringIO("hulapaloo2")
        test_plan2.name = "testplan2.xml"
        test_list = {'host_testplans': [test_plan], 'hw_testplans' : [test_plan2],
                     'device':"foo,bar",'host':"baz,yaz"}
        testrun_id = "" 
        storage_address = "" 
        test_filter = ""  
        timeout = "30"
        rootstrap = ""
        commands = get_commands(distribution_model, 
                                image_url, 
                                rootstrap,
                                test_list,
                                testrun_id,
                                storage_address,
                                test_filter,
                                timeout)

        expected_cmd_1 = ['conductor', 
                          '-u', 'http://image/url/image.bin',
                          '-t', "foo,bar", '-m', '30',
                          ';',
                          'conductor',
                          '-u', 'http://image/url/image.bin',
                          '-t', "baz,yaz", '-m', '30',
                          '-o']

        expected_cmd_2 = ['conductor', 
                          '-u', 'http://image/url/image.bin', 
                          '-m', '30', '-p', 'testplan2.xml']
        expected_cmd_3 = ['conductor', 
                          '-u', 'http://image/url/image.bin', 
                          '-m', '30', '-p', 'testplan.xml', '-o']


        self.assertEquals(len(commands), 3)
        self.assertEquals(commands[0].command, expected_cmd_1)
        self.assertEquals(commands[1].command, expected_cmd_2)
        self.assertEquals(commands[2].command, expected_cmd_3)
Exemple #15
0
    def test_mixed_tests_with_multiple_testplans_and_pkgs(self):
        """Test host test plan based - one test plan"""

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_plan = StringIO("hulapaloo")
        test_plan.name = "testplan.xml"
        test_plan2 = StringIO("hulapaloo2")
        test_plan2.name = "testplan2.xml"
        test_list = {
            'host_testplans': [test_plan],
            'hw_testplans': [test_plan2],
            'device': "foo,bar",
            'host': "baz,yaz"
        }
        testrun_id = ""
        storage_address = ""
        test_filter = ""
        timeout = "30"
        rootstrap = ""
        commands = get_commands(distribution_model, image_url, rootstrap,
                                test_list, testrun_id, storage_address,
                                test_filter, timeout)

        expected_cmd_1 = [
            'conductor', '-u', 'http://image/url/image.bin', '-t', "foo,bar",
            '-m', '30', ';', 'conductor', '-u', 'http://image/url/image.bin',
            '-t', "baz,yaz", '-m', '30', '-o'
        ]

        expected_cmd_2 = [
            'conductor', '-u', 'http://image/url/image.bin', '-m', '30', '-p',
            'testplan2.xml'
        ]
        expected_cmd_3 = [
            'conductor', '-u', 'http://image/url/image.bin', '-m', '30', '-p',
            'testplan.xml', '-o'
        ]

        self.assertEquals(len(commands), 3)
        self.assertEquals(commands[0].command, expected_cmd_1)
        self.assertEquals(commands[1].command, expected_cmd_2)
        self.assertEquals(commands[2].command, expected_cmd_3)
Exemple #16
0
    def test_device_tests_with_no_packages(self):
        """Check conductor command without test packages for device"""

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_list = {}
        testrun_id = ""
        storage_address = ""
        test_filter = "-testsuite=testrunner-tests"
        timeout = "20"
        rootstrap = ""

        expected_cmds = [
            'conductor', '-u', 'http://image/url/image.bin', '-f',
            '-testsuite=testrunner-tests', '-m', '20'
        ]

        cmds = get_commands(distribution_model, image_url, rootstrap,
                            test_list, testrun_id, storage_address,
                            test_filter, timeout)

        self.assertEquals(cmds[0].command, expected_cmds)
Exemple #17
0
    def test_chroot_tests(self):
        """Check conductor command with test packages for chroot"""

        expected_cmds = [
            'conductor', '-u', 'http://image/url/image.bin', '-f',
            '-testsuite=testrunner-tests', '-t', "foo,bar,baz", '-m', '20',
            '--chrooted', "--rootstrapurl=url_to_rootstrap"
        ]

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_list = {'chroot': "foo,bar,baz"}
        testrun_id = ""
        storage_address = ""
        test_filter = "-testsuite=testrunner-tests"
        timeout = "20"
        rootstrap = "url_to_rootstrap"

        cmds = get_commands(distribution_model, image_url, rootstrap,
                            test_list, testrun_id, storage_address,
                            test_filter, timeout)

        self.assertEquals(cmds[0].command, expected_cmds)
Exemple #18
0
    def test_device_tests_with_one_testplan(self):
        """Test device test plan based - one test plan"""

        distribution_model = "default"
        image_url = 'http://image/url/image.bin'
        test_plan = StringIO("hulapaloo")
        test_plan.name = "testplan.xml"
        test_list = {'hw_testplans': [test_plan]}
        testrun_id = ""
        storage_address = ""
        test_filter = ""
        timeout = "30"
        rootstrap = ""
        commands = get_commands(distribution_model, image_url, rootstrap,
                                test_list, testrun_id, storage_address,
                                test_filter, timeout)

        expected_cmds = [
            'conductor', '-u', 'http://image/url/image.bin', '-m', '30', '-p',
            'testplan.xml'
        ]

        self.assertEquals(len(commands), 1)
        self.assertEquals(commands[0].command, expected_cmds)
def primed_taskrunner(testrun_uuid, execution_timeout, distribution_model, 
                      device_properties, image, rootstrap, hw_packages,
                      host_packages, chroot_packages, hw_testplans,
                      host_testplans, emmc, testfilter, flasher, use_libssh2,
                      resume, custom_distribution_model, flasher_options,
                      extended_options): 

    """
    Get a Taskrunner loaded with Tasks and ready to Run

    @type testrun_uuid: C{str}
    @param testrun_uuid: The unique identifier for the testrun

    @type execution_timeout: C{int}
    @param execution_timeout: The execution timeout in minutes

    @type distribution_model: C{str}
    @param distribution_model: The name of the distribution_model

    @type device_properties : C{dict}
    @param device_properties : A dictionary of device properties 
                               this testrun requires

    @type image: C{str}
    @param image: The URL of the image

    @type rootstrap : C{str}
    @param rootstrap: Url to the chroot rootstrap

    @type hw_packages : C{list} of C{str}
    @param hw_packages: The hardware packages

    @type host_packages : C{list} of C{str}
    @param host_packages: The host packages
    
    @type hw_testplans : C{list} of C{str}
    @param hw_testplans: The hardware test plans

    @type host_testplans : C{list} of C{str}
    @param host_testplans: The host test plans

    @type emmc : C{str}
    @param emmc: Url to the additional content image (memory card image)
      
    @type testfilter: C{str}
    @param testfilter: The test filter string for testrunner-lite

    @type flasher: C{str}
    @param flasher: The URL of the flasher

    @type use_libssh2: C{boolean}
    @param use_libssh2: Use testrunner-lite libssh2 support

    @type resume:  C{boolean}
    @param resume: Use testrunner-lite resume functionality

    @type custom_distribution_model: C{callable}
    @param custom_distribution_model: A callable matching the default models
                                      in default_distribution_models.py

    @type flasher_options : C{string}
    @param flasher_options : Custom flasher options

    @type extended_options : C{dict}
    @param extended_options : A dictionary of extended ots testrun options

    @rtype: C{Taskrunner}
    @return: A loaded Taskrunner 
    """

    routing_key = get_routing_key(device_properties)
    taskrunner = taskrunner_factory(routing_key, execution_timeout, 
                                    testrun_uuid)
    test_list = dict()

    if hw_packages:
        test_list['device'] = ",".join(hw_packages)
    if host_packages:
        test_list['host'] = ",".join(host_packages)

    if hw_testplans:
        test_list['hw_testplans'] = hw_testplans
    if host_testplans:
        test_list['host_testplans'] = host_testplans

    if chroot_packages:
        test_list['chroot'] = ",".join(chroot_packages)

    # Server deals with minutes, conductor uses seconds, 
    execution_timeout = int(execution_timeout)*60

    cmds = get_commands(distribution_model,
                        image,
                        rootstrap,
                        test_list,
                        testrun_uuid,
                        _storage_address(),
                        testfilter,
                        execution_timeout,
                        flasher,
                        custom_distribution_model,
                        use_libssh2,
                        resume,
                        flasher_options,
                        extended_options)
    
    if len(cmds) == 0:
        raise AllocatorException("No commands created!")


    for cmd in cmds:
        LOG.info("Added cmd '%s' to taskrunner" % (" ".join(cmd.command)))
        taskrunner.add_task(cmd)
    return taskrunner