From 58b917c9ba27cbdd83573c85368b8c5408f7b08d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ma=C3=ABl=20Madon?= <mael.madon@irit.fr>
Date: Wed, 12 Jul 2023 08:38:18 +0200
Subject: [PATCH] test: easy_bf and easy_bf_fast now behave almost the same
 (little difference in the order they give to jobs that arrive simultaneously)

---
 test/helper.py               | 14 +++++++++++++-
 test/test_broker.py          |  5 +----
 test/test_schedulers_mono.py |  5 +----
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/test/helper.py b/test/helper.py
index 7f6579a..12dd71f 100644
--- a/test/helper.py
+++ b/test/helper.py
@@ -5,6 +5,7 @@ import subprocess
 import filecmp
 from collections import namedtuple
 from os.path import abspath
+import pandas as pd
 
 
 empty_workload = abspath('test/workloads/static/empty.json')
@@ -79,4 +80,15 @@ def assert_expected_behavior(test_file) :
         assert filecmp.cmp(expected, obtained), f"\
         Files {expected} and {obtained} should be equal but are not.\n\
         Run `diff {expected} {obtained}` to investigate why.\n\
-        Run `cp {obtained} {expected}` to override the expected file with the obtained."
\ No newline at end of file
+        Run `cp {obtained} {expected}` to override the expected file with the obtained."
+
+def assert_same_outputs(expected, obtained):
+    """Test that the relevent columns of the _jobs.csv are identical"""
+    cols = ["job_id", "submission_time", "final_state", "starting_time", "execution_time"]
+
+    df_o = pd.read_csv(obtained)[cols]
+    df_e = pd.read_csv(expected)[cols]
+    
+    assert df_o.equals(df_e), f"\
+        Files {expected} and {obtained} should be equal but are not.\n\
+        Run `diff {expected} {obtained}` to investigate why."
\ No newline at end of file
diff --git a/test/test_broker.py b/test/test_broker.py
index 5da510c..a6092d9 100644
--- a/test/test_broker.py
+++ b/test/test_broker.py
@@ -32,10 +32,7 @@ def test_easy_bf_fast(platform_monoC, workload_static):
 
     expected = 'test-out/' + test_name_easy + '/_jobs.csv'
     obtained = 'test-out/' +  test_name_easy_fast + '/_jobs.csv'
-    assert filecmp.cmp(expected, obtained), f"\
-        Files {expected} and {obtained} should be equal but are not.\n\
-        Run `diff {expected} {obtained}` to investigate why.\n\
-        Run `cp {obtained} {expected}` to override the expected file with the obtained."
+    assert_same_outputs(expected, obtained)
 
 
 def test_broker_multi(platform_multiC, workload_static, sched_multi):
diff --git a/test/test_schedulers_mono.py b/test/test_schedulers_mono.py
index d268d5b..643747c 100755
--- a/test/test_schedulers_mono.py
+++ b/test/test_schedulers_mono.py
@@ -65,7 +65,4 @@ def test_easy_bf_fast(platform_monoC, workload_static):
     test_easy = f'easy_bf-{platform_monoC.name}-{workload_static.name}'
     obtained = f'test-out/{test_name}/_jobs.csv'
     expected = f'test-out/{test_easy}/_jobs.csv'
-    assert filecmp.cmp(expected, obtained), f"\
-        Files {expected} and {obtained} should be equal but are not.\n\
-        Run `diff {expected} {obtained}` to investigate why.\n\
-        Run `cp {obtained} {expected}` to override the expected file with the obtained."
+    assert_same_outputs(expected, obtained)
\ No newline at end of file
-- 
GitLab