Esempio n. 1
0
def history_model(test_list, options):
    """
    Test package distribution based on history.

    @type test_list: C{list}
    @param test_list: List of test packages

    @type options: C{Options}
    @param options: Testrun options in an ots.server.hub.options object
    
    @rtype: C{list}
    @return: List of conductor_commands 

    """

    commands = []
    
    req_options = REQUEST_OPTIONS
    
    max_runtime = int(req_options.get("target_execution_time", DEFAULT_RUNTIME))
    max_groups = int(req_options.get("max_worker_amount", DEFAULT_GROUPS))
    
    if not test_list:
        raise ValueError("test_list not defined for distribution model")

    if 'device' in test_list:
        test_packages = test_list['device'].split(",")
        test_history = get_test_package_history(test_packages)
        LOG.debug(test_history)
        package_groups = group_packages(test_history, max_runtime, max_groups)
        LOG.debug(package_groups)
        for group in package_groups:
            options['test_packages'] = string.join(group, ",")
            cmd = conductor_command(options, 
                                    host_testing = False,
                                    chroot_testing = False)
            commands.append(Task(cmd))
        
        # Rest groups are for host based packages
        max_groups = max_groups - len(package_groups)

    # If we have host based packages
    # Lets use rest of the groups for them
    if 'host' in test_list:
        test_packages = test_list['host'].split(",")
        test_history = get_test_package_history(test_packages)
        LOG.debug(test_history)
        if max_groups <= 0:
            max_groups = 1
        LOG.debug(max_groups)
        package_groups = group_packages(test_history, max_runtime, max_groups)
        LOG.debug(package_groups)
        for group in package_groups:
            options['test_packages'] = string.join(group, ",")
            cmd = conductor_command(options, 
                                    host_testing = True,
                                    chroot_testing = False)
            commands.append(Task(cmd))

    return commands
Esempio n. 2
0
 def testPackagesUnknown(self):
     
     test_packages = {"test-package1" : 30,
                      "test-package2" : 30,
                      "test-package3" : None}
     
     groups = group_packages(test_packages, 61, 2)
     self.assertTrue(len(groups) == 2)
     self.assertEquals(groups[1][0], "test-package3")
Esempio n. 3
0
 def testPackagesNormal(self):
     
     test_packages = {"test-package1" : 10,
                      "test-package2" : 20,
                      "test-package3" : 30}
     
     groups = group_packages(test_packages, 30, 2)
     
     self.assertTrue(len(groups) == 2)
     self.assertEquals(groups[0][0], "test-package3")
Esempio n. 4
0
    def testPackagesUnknown(self):

        test_packages = {
            "test-package1": 30,
            "test-package2": 30,
            "test-package3": None
        }

        groups = group_packages(test_packages, 61, 2)
        self.assertTrue(len(groups) == 2)
        self.assertEquals(groups[1][0], "test-package3")
Esempio n. 5
0
    def testPackagesNormal(self):

        test_packages = {
            "test-package1": 10,
            "test-package2": 20,
            "test-package3": 30
        }

        groups = group_packages(test_packages, 30, 2)

        self.assertTrue(len(groups) == 2)
        self.assertEquals(groups[0][0], "test-package3")
Esempio n. 6
0
 def testNotEnoughGroups(self):
     
     test_packages = {"test-package1" : 31,
                      "test-package2" : 32,
                      "test-package3" : 33,
                      "test-package4" : 34,
                      "test-package5" : 35,
                      "test-package6" : 36,
                      "test-package7" : 37,
                      }
     
     groups = group_packages(test_packages, 61, 2)
     self.assertTrue(len(groups) == 2)
     self.assertEquals(groups[0][0], "test-package7")
Esempio n. 7
0
    def testNotEnoughGroups(self):

        test_packages = {
            "test-package1": 31,
            "test-package2": 32,
            "test-package3": 33,
            "test-package4": 34,
            "test-package5": 35,
            "test-package6": 36,
            "test-package7": 37,
        }

        groups = group_packages(test_packages, 61, 2)
        self.assertTrue(len(groups) == 2)
        self.assertEquals(groups[0][0], "test-package7")
Esempio n. 8
0
 def testMultipleNone(self):
     
     test_packages = {"test-package1" : 120,
                      "test-package2" : 32,
                      "test-package3" : 33,
                      "test-package4" : None,
                      "test-package5" : 35,
                      "test-package6" : None,
                      "test-package7" : 37,
                      }
     
     groups = group_packages(test_packages, 120, 5)
     self.assertTrue(len(groups) == 4)
     self.assertTrue(len(groups[3]) == 2)
     self.assertEquals(groups[0][0], "test-package1")
     self.assertEquals(groups[3][0], "test-package4")
     self.assertEquals(groups[3][1], "test-package6")
Esempio n. 9
0
    def testMultipleNone(self):

        test_packages = {
            "test-package1": 120,
            "test-package2": 32,
            "test-package3": 33,
            "test-package4": None,
            "test-package5": 35,
            "test-package6": None,
            "test-package7": 37,
        }

        groups = group_packages(test_packages, 120, 5)
        self.assertTrue(len(groups) == 4)
        self.assertTrue(len(groups[3]) == 2)
        self.assertEquals(groups[0][0], "test-package1")
        self.assertEquals(groups[3][0], "test-package4")
        self.assertEquals(groups[3][1], "test-package6")