diff options
author | Oguzhan Ozmen <oozmen@bloomberg.net> | 2023-11-22 21:37:00 +0100 |
---|---|---|
committer | Oguzhan Ozmen <oozmen@bloomberg.net> | 2023-11-23 06:26:23 +0100 |
commit | 48e189fe0ec6c0ace23ddaed09ef3f936e8c2a6f (patch) | |
tree | 668d9e3d3b1ea6840fe0d86a3ffa2fb86d783f23 /src/test/rgw | |
parent | rgw/lc: [non-functional change] use const expr to represent seconds in a day (diff) | |
download | ceph-48e189fe0ec6c0ace23ddaed09ef3f936e8c2a6f.tar.xz ceph-48e189fe0ec6c0ace23ddaed09ef3f936e8c2a6f.zip |
rgw/lc: adjust timing if the configured end work-time is less than the start-time
LC work time is given in the form of "HH:MM-HH:MM"; the first part
represents the "start_time" and the next "end_time". "should_work"
function decides, given the current time, whether the LC worker can resume.
It essentially checks whether the current time is within start and end times.
Since there's no "date" (month/day/year) notion taken into account, a work time
whose end_time (i.e., hour field) is less than start_time is not properly
handled by "should_work". For example, "14:00-13:59" would normally mean to
start LC processing at 2PM local time and allowing it to run for 24 hours. So,
given such a work time range, "should_work" must return true for any given
current_time. However, without this adjustment, it always returns false.
The fix simply adds a "next day" adjustment if the end_time is
configured to be less than the configured start_time.
Fixes https://tracker.ceph.com/issues/63613
Signed-off-by: Oguzhan Ozmen <oozmen@bloomberg.net>
Diffstat (limited to 'src/test/rgw')
-rw-r--r-- | src/test/rgw/test_rgw_lc.cc | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/src/test/rgw/test_rgw_lc.cc b/src/test/rgw/test_rgw_lc.cc index 2943094c6d0..d10b482cbfc 100644 --- a/src/test/rgw/test_rgw_lc.cc +++ b/src/test/rgw/test_rgw_lc.cc @@ -235,13 +235,13 @@ TEST_F(LCWorkTimeTests, ShouldWorkCustomWorkTimeEndTimeInTheNextDay) std::unordered_map<std::string, bool> test_values_to_expectations = { {"01/01/23 13:59:00", false}, {"01/01/23 13:59:59", false}, - {"01/01/24 14:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 17:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 23:59:59", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 00:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 00:59:59", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 01:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 01:00:59", false}, // should have been true, expected to fail due to tracker issue #63613 + {"01/01/24 14:00:00", true}, // used-to-fail + {"01/01/24 17:00:00", true}, // used-to-fail + {"01/01/24 23:59:59", true}, // used-to-fail + {"01/01/23 00:00:00", true}, // used-to-fail + {"01/01/23 00:59:59", true}, // used-to-fail + {"01/01/23 01:00:00", true}, // used-to-fail + {"01/01/23 01:00:59", true}, // used-to-fail {"01/01/23 01:01:00", false}, {"01/01/23 05:00:00", false}, {"01/01/23 12:00:00", false}, @@ -255,21 +255,22 @@ TEST_F(LCWorkTimeTests, ShouldWorkCustomWorkTimeEndTimeInTheNextDay24Hours) { cct->_conf->rgw_lifecycle_work_time = "14:00-13:59"; + // all of the below cases used-to-fail std::unordered_map<std::string, bool> test_values_to_expectations = { - {"01/01/23 00:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 00:00:01", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 00:01:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 01:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 12:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 13:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 13:59:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 13:59:59", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 14:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 14:00:01", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 14:01:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 16:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 23:59:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 23:59:59", false}, // should have been true, expected to fail due to tracker issue #63613 + {"01/01/23 00:00:00", true}, + {"01/01/23 00:00:01", true}, + {"01/01/23 00:01:00", true}, + {"01/01/24 01:00:00", true}, + {"01/01/24 12:00:00", true}, + {"01/01/24 13:00:00", true}, + {"01/01/24 13:59:00", true}, + {"01/01/24 13:59:59", true}, + {"01/01/23 14:00:00", true}, + {"01/01/23 14:00:01", true}, + {"01/01/23 14:01:00", true}, + {"01/01/23 16:00:00", true}, + {"01/01/23 23:59:00", true}, + {"01/01/23 23:59:59", true}, }; run_should_work_test(test_values_to_expectations); @@ -281,12 +282,12 @@ TEST_F(LCWorkTimeTests, ShouldWorkCustomWorkTimeEndTimeInTheNextDayIrregularMins std::unordered_map<std::string, bool> test_values_to_expectations = { {"01/01/23 22:14:59", false}, - {"01/01/23 22:15:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 00:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 01:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/24 02:00:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 03:33:00", false}, // should have been true, expected to fail due to tracker issue #63613 - {"01/01/23 03:33:59", false}, // should have been true, expected to fail due to tracker issue #63613 + {"01/01/23 22:15:00", true}, // used-to-fail + {"01/01/24 00:00:00", true}, // used-to-fail + {"01/01/24 01:00:00", true}, // used-to-fail + {"01/01/24 02:00:00", true}, // used-to-fail + {"01/01/23 03:33:00", true}, // used-to-fail + {"01/01/23 03:33:59", true}, // used-to-fail {"01/01/23 03:34:00", false}, {"01/01/23 04:00:00", false}, {"01/01/23 12:00:00", false}, |