Example #1
0
def uuid1mc():
    '''
    This is v1 with random MAC ("v1mc"). This is a hybrid between version 1 & version 4.

    Version 1 UUIDs use the network card's MAC address (which unless spoofed, should be unique),
    plus a timestamp, plus the usual bit-twiddling to generate the UUID.

    Version 4 UUIDs Generate a random UUID.

    uuid1mc() is deliberately generating v1 UUIDs with a random broadcast MAC address (this is allowed by the v1 spec).
    The resulting v1 UUID is time dependant (like regular v1), but lacks all host-specific information (like v4).
    It's also much closer to v4 in it's collision-resistance:
        v1mc = 60 bits of time + 61 random bits = 121 unique bits; v4 = 122 random bits.

    Note: somebody reported that ran into trouble using UUID1 in Amazon EC2 instances.
    He use UUID1 for a database upgrade script where he generated ~120k UUIDs within a couple of minutes.
    The UUID collision led to violation of a primary key constraint.
    He suspect poor clock resolution and switching to UUID4 solved it for him.

    '''
    #return uuid1(_int_from_bytes(urandom(6), "big") | 0x010000000000)
    node = _system_random.getrandbits(
        8
    )  #6 and not 8, because this function round up to bits / 8 and rounded up
    # NOTE: The constant here is required by the UUIDv1 spec...
    return _uuid1(node | 0x010000000000)
Example #2
0
    def __init__(self,
                 galaxy_instance,
                 workflow_loader,
                 suite,
                 filter=None,
                 output_folder=".",
                 enable_logger=None,
                 enable_debug=None,
                 disable_cleanup=None,
                 disable_assertions=None):
        """
        Create an instance of :class:`WorkflowTestSuite`.

        :type galaxy_url: str
        :param galaxy_url: url of your Galaxy server instance.  If ``none``, the environment variable
            ``GALAXY_URL`` is used. An error is raised when such a variable cannot be found.

        :type galaxy_api_key: str
        :param galaxy_api_key: an API key from your Galaxy server instance.  If ``none``, the environment variable
            ``GALAXY_API_KEY`` is used. An error is raised when such a variable cannot be found.
        """

        super(WorkflowTestSuiteRunner, self).__init__()
        self._uuid = str(_uuid1())
        self._suite = suite
        self._workflows = {}
        self._workflow_runners = []
        self._workflow_test_results = []
        self._galaxy_instance = None

        # log file handler
        self._file_handler = None
        # initialize the galaxy instance
        self._galaxy_instance = galaxy_instance
        # initialize the workflow loader
        self._workflow_loader = workflow_loader

        self.disable_cleanup = suite.disable_cleanup
        self.disable_assertions = suite.disable_assertions
        self.enable_logger = suite.enable_logger
        self.enable_debug = suite.enable_debug

        _update_config(self,
                       output_folder=output_folder,
                       enable_logger=enable_logger,
                       enable_debug=enable_debug,
                       disable_cleanup=disable_cleanup,
                       disable_assertions=disable_assertions)

        for test_config in suite.workflow_tests.values():
            test_config.disable_assertions = False
            if not filter or len(filter) == 0 or test_config.name in filter:
                runner = self._create_test_runner(
                    test_config,
                    enable_logger=enable_logger,
                    enable_debug=enable_debug,
                    disable_cleanup=disable_cleanup,
                    disable_assertions=disable_assertions)
                self.addTest(runner)
Example #3
0
    def uuid(self):
        """
        Get the current UUID or generate a new one.

        :type update: bool
        :param update: ``True`` to force the generation of a new UUID

        :rtype: str
        :return: a generated UUID
        """
        if not self._uuid:
            self._uuid = self._test_suite_runner.uuid if self._test_suite_runner is not None else str(
                _uuid1())
        return self._uuid
Example #4
0
    def __init__(self,
                 name=None,
                 base_path=".",
                 workflow_filename="workflow.ga",
                 inputs=None,
                 params=None,
                 expected_outputs=None,
                 output_folder=None,
                 disable_cleanup=False,
                 disable_assertions=False,
                 enable_logger=False,
                 enable_debug=False):

        # init properties
        self._base_path = None
        self._filename = None
        self._inputs = {}
        self._params = {}
        self._expected_outputs = {}

        self.enable_logger = enable_logger
        self.enable_debug = enable_debug

        # set parameters
        self.name = str(_uuid1()) if not name else name
        self.set_base_path(base_path)
        self.set_filename(workflow_filename)
        if inputs is not None:
            self.set_inputs(inputs)
        if params is not None:
            self.set_params(params)
        if expected_outputs is not None:
            self.set_expected_outputs(expected_outputs)
        self.output_folder = _os.path.join(self.DEFAULT_OUTPUT_FOLDER, self.name) \
            if output_folder is None else output_folder
        self.disable_cleanup = disable_cleanup
        self.disable_assertions = disable_assertions
Example #5
0
def new_guid():
    return str(_uuid1())