def add_tag(request, run_ids, tags):
    """Add one or more tags to the selected test runs.

    :param run_ids: give one or more run IDs. It could be an integer, a
        string containing comma separated IDs, or a list of int each of them is
        a run ID.
    :type run_ids: int, str or list
    :param tags: tag name or a list of tag names to remove.
    :type tags: str or list
    :return: a list which is empty on success or a list of mappings with
        failure codes if a failure occured.
    :rtype: list

    Example::

        # Add tag 'foobar' to run 1
        TestPlan.add_tag(1, 'foobar')
        # Add tag list ['foo', 'bar'] to run list [1, 2]
        TestPlan.add_tag([1, 2], ['foo', 'bar'])
        # Add tag list ['foo', 'bar'] to run list [1, 2] with String
        TestPlan.add_tag('1, 2', 'foo, bar')
    """
    trs = TestRun.objects.filter(pk__in=pre_process_ids(value=run_ids))
    tags: List[str] = TestTag.string_to_list(tags)

    for tag in tags:
        t, _ = TestTag.objects.get_or_create(name=tag)
        tr: TestRun
        for tr in trs.iterator():
            tr.add_tag(tag=t)