diff options
author | dcorbacho <dparracorbacho@piotal.io> | 2020-11-18 14:27:41 +0000 |
---|---|---|
committer | dcorbacho <dparracorbacho@piotal.io> | 2020-11-18 14:27:41 +0000 |
commit | f23a51261d9502ec39df0f8db47ba6b22aa7659f (patch) | |
tree | 53dcdf46e7dc2c14e81ee960bce8793879b488d3 /workflow_sources/test/util.star | |
parent | afa2c2bf6c7e0e9b63f4fb53dc931c70388e1c82 (diff) | |
parent | 9f6d64ec4a4b1eeac24d7846c5c64fd96798d892 (diff) | |
download | rabbitmq-server-git-stream-timestamp-offset.tar.gz |
Merge remote-tracking branch 'origin/master' into stream-timestamp-offsetstream-timestamp-offset
Diffstat (limited to 'workflow_sources/test/util.star')
-rw-r--r-- | workflow_sources/test/util.star | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/workflow_sources/test/util.star b/workflow_sources/test/util.star new file mode 100644 index 0000000000..2c6d348564 --- /dev/null +++ b/workflow_sources/test/util.star @@ -0,0 +1,58 @@ +def is_unique(l): + return len(l) == len(set(l)) +end + +def merge(dicts): + r = {} + for d in dicts: + r.update(**d) + end + return r +end + +def name(suites): + if len(suites) == 1: + return suites[0].name + else: + return suites[0].name + "-plus-" + str(len(suites) - 1) + "-more" + end +end + +def sum(ints): + s = 0 + for i in ints: + s += i + end + return s +end + +def partition(target, groups, suites): + if len(suites) == 0: + return groups + end + group = [] + rest = [] + for suite in sorted(suites, key=lambda suite: suite.time): + if sum([suite2.time for suite2 in group]) + suite.time <= target: + group.append(suite) + else: + rest.append(suite) + end + end + return partition(target, groups + [group], rest) +end + +def group_by_time(suites): + longest = max([suite.time for suite in suites]) + groups = partition(longest, [], suites) + return [{"name": name(suites), "suites": [suite.name for suite in suites]} for suites in groups] +end + +# Used when we don't actually want multiple ct-suites per job +def group_by_one(suites): + return [{"name": suite.name, "suites": [suite.name]} for suite in suites] +end + +def to_build_args(d): + return ",".join(['{0}={1}'.format(k,d[k]) for k in d.keys()]) +end |