def test_process_query_view_parity_contains(
        self,
        node_key,
        process_id,
        created_timestamp,
        asset_id,
        terminate_time,
        image_name,
        process_name,
        arguments,
    ):
        node_key = "test_process_query_view_parity_contains" + str(node_key)
        local_client = DgraphClient(DgraphClientStub("localhost:9080"))
        get_or_create_process_node(
            local_client,
            node_key,
            process_id,
            arguments,
            created_timestamp,
            asset_id,
            terminate_time,
            image_name,
            process_name,
        )

        query = ProcessQuery().with_node_key(eq=node_key)

        # Don't f**k with newlines due to a dgraph bug
        # https://github.com/dgraph-io/dgraph/issues/4694
        if len(arguments) > 3 and "\n" not in arguments:
            query.with_arguments(contains=arguments[:len(arguments) - 1])
        if len(asset_id) > 3 and "\n" not in asset_id:
            query.with_asset_id(contains=asset_id[:len(asset_id) - 1])
        if len(image_name) > 3 and "\n" not in image_name:
            query.with_image_name(contains=image_name[:len(image_name) - 1])
        if len(process_name) > 3 and "\n" not in process_name:
            query.with_process_name(contains=process_name[:len(process_name) -
                                                          1])

        queried_proc = query.query_first(local_client)

        assert queried_proc
        assert "Process" == queried_proc.get_node_type()
        assert process_id == queried_proc.get_process_id()
        assert node_key == queried_proc.node_key
        assert arguments == queried_proc.get_arguments()
        assert created_timestamp == queried_proc.get_created_timestamp()
        assert asset_id == queried_proc.get_asset_id()
        assert terminate_time == queried_proc.get_terminate_time()
        assert image_name == queried_proc.get_image_name()
        assert process_name == queried_proc.get_process_name()
Exemple #2
0
    def test_process_query_view_parity_contains(
        self,
        node_key,
        process_id,
        created_timestamp,
        terminate_time,
        image_name,
        process_name,
        arguments,
    ):
        node_key = "test_process_query_view_parity_contains" + str(node_key)
        local_client = DgraphClient(DgraphClientStub("localhost:9080"))
        get_or_create_process_node_deprecated(
            local_client,
            node_key,
            process_id,
            arguments,
            created_timestamp,
            terminate_time,
            image_name,
            process_name,
        )

        query = ProcessQuery().with_node_key(eq=node_key)

        # Don't f**k with newlines due to a dgraph bug
        # https://github.com/dgraph-io/dgraph/issues/4694
        for prop in [arguments, image_name, process_name]:
            hypothesis.assume(len(prop) > 3)
            hypothesis.assume("\n" not in prop)
            hypothesis.assume("\\" not in prop)

        # These fail because dgraph doesn't like the query
        # 	(regexp(process_name, /00\\//))
        query.with_arguments(contains=arguments[: len(arguments) - 1])
        query.with_image_name(contains=image_name[: len(image_name) - 1])
        query.with_process_name(contains=process_name[: len(process_name) - 1])

        queried_proc = query.query_first(local_client)

        assert queried_proc
        assert "Process" == queried_proc.get_node_type()
        assert process_id == queried_proc.get_process_id()
        assert node_key == queried_proc.node_key
        assert arguments == queried_proc.get_arguments()
        assert created_timestamp == queried_proc.get_created_timestamp()
        assert terminate_time == queried_proc.get_terminate_time()
        assert image_name == queried_proc.get_image_name()
        assert process_name == queried_proc.get_process_name()