From 319a0d3d869c6829136ec9bf99a028bfeebf38c1 Mon Sep 17 00:00:00 2001
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
Date: Thu, 5 Oct 2023 14:36:19 -0300
Subject: [PATCH] upstream ci: Use a single random seed for spliting tests

Dependind on how long it took for the jobs to start, a different seed
would be used to group tests and tests could either repeat or not be
selected at all.

By using a seed based on the day the test run reduces the chance of
using different random seeds, and still allow for the tests to be
executed in a different order.

The execution in different order is important to identify tests that
work or fail only if executed after other tests.
---
 tests/azure/templates/galaxy_script.yml  | 1 +
 tests/azure/templates/playbook_fast.yml  | 1 +
 tests/azure/templates/playbook_tests.yml | 1 +
 3 files changed, 3 insertions(+)

diff --git a/tests/azure/templates/galaxy_script.yml b/tests/azure/templates/galaxy_script.yml
index cd95c658..a00dd0a5 100644
--- a/tests/azure/templates/galaxy_script.yml
+++ b/tests/azure/templates/galaxy_script.yml
@@ -67,6 +67,7 @@ jobs:
         --color=yes \
         --splits=${{ parameters.number_of_groups }} \
         --group=${{ parameters.group_number }} \
+        --randomly-seed=$(date "+%Y%m%d") \
         --junit-xml=TEST-results-group-${{ parameters.group_number }}.xml
     displayName: Run playbook tests
     env:
diff --git a/tests/azure/templates/playbook_fast.yml b/tests/azure/templates/playbook_fast.yml
index ce187a3c..2629b3e5 100644
--- a/tests/azure/templates/playbook_fast.yml
+++ b/tests/azure/templates/playbook_fast.yml
@@ -72,6 +72,7 @@ jobs:
         --suppress-no-test-exit-code \
         --splits=${{ parameters.number_of_groups }} \
         --group=${{ parameters.group_number }} \
+        --randomly-seed=$(date "+%Y%m%d") \
         --junit-xml=TEST-results-group-${{ parameters.group_number }}.xml
       then
         [ $? -eq 5 ] && true || false
diff --git a/tests/azure/templates/playbook_tests.yml b/tests/azure/templates/playbook_tests.yml
index ce320002..c65c955f 100644
--- a/tests/azure/templates/playbook_tests.yml
+++ b/tests/azure/templates/playbook_tests.yml
@@ -69,6 +69,7 @@ jobs:
         --color=yes \
         --splits=${{ parameters.number_of_groups }} \
         --group=${{ parameters.group_number }} \
+        --randomly-seed=$(date "+%Y%m%d") \
         --junit-xml=TEST-results-group-${{ parameters.group_number }}.xml
     displayName: Run playbook tests
     env:
-- 
GitLab