Skip to content

test: add snap schedule tests#34552

Merged
batrick merged 6 commits intoceph:masterfrom
vshankar:wip-snap-sched-tests
Nov 18, 2020
Merged

test: add snap schedule tests#34552
batrick merged 6 commits intoceph:masterfrom
vshankar:wip-snap-sched-tests

Conversation

@vshankar
Copy link
Contributor

No description provided.

@vshankar vshankar added cephfs Ceph File System DNM labels Apr 14, 2020
@vshankar vshankar requested review from a team and jan--f April 14, 2020 13:20
@vshankar
Copy link
Contributor Author

@jan--f The following changes would be required to run these tests:

diff --git a/src/pybind/mgr/snap_schedule/module.py b/src/pybind/mgr/snap_schedule/module.py
index 79ea24b8c4..e39fd1e398 100644
--- a/src/pybind/mgr/snap_schedule/module.py
+++ b/src/pybind/mgr/snap_schedule/module.py
@@ -3,6 +3,7 @@ Copyright (C) 2019 SUSE
 
 LGPL2.1.  See file COPYING.
 """
+import json
 import errno
 import sqlite3
 from .fs.schedule import SnapSchedClient, Schedule
@@ -75,7 +76,7 @@ class Module(MgrModule):
             return e.to_tuple()
         if not scheds:
             return -1, '', f'SnapSchedule for {path} not found'
-        return 0, str([str(sched) for sched in scheds]), ''
+        return 0, json.dumps([[sched[1], sched[2]] for sched in scheds]), ''

and

diff --git a/src/pybind/mgr/snap_schedule/fs/schedule.py b/src/pybind/mgr/snap_schedule/fs/schedule.py
index 4f528f21cf..8ac4026c1d 100644
--- a/src/pybind/mgr/snap_schedule/fs/schedule.py
+++ b/src/pybind/mgr/snap_schedule/fs/schedule.py
@@ -71,7 +71,7 @@ class Schedule(object):
         self.last_run = None
 
     def __str__(self):
-        return f'''{self.rel_path}: {self.schedule}; {self.retention}'''
+        return f'''{self.path}: {self.schedule}; {self.retention}'''
 
     def report(self):
         import pprint
@@ -223,7 +223,7 @@ class SnapSchedClient(CephfsClient):
             log.info(f'finally branch')
             self.refresh_snap_timers(fs_name)
             log.info(f'calling prune')
-            self.prune_snapshots(fs_name, path, retention)
+            #self.prune_snapshots(fs_name, path, retention)
 
     def prune_snapshots(self, fs_name, path, retention):
         log.debug('Pruning snapshots')

@vshankar
Copy link
Contributor Author

@jan--f Note that in the diffs mentioned previously I had commented out the call to prune_snapshots() -- without this the snaps were getting purged every minute. I suspected the prune-every-minute test code that you had but taking out the purge-every-minute thing in get_prune_set() didn't work -- I think get_prune_set() was returning an empty set thereby deleting a snap that was just created.

Another interesting thing that I saw when running test_snap_schedule -- snippet from the manager log below:

2020-04-14T04:45:22.942-0400 7f5a2e9bc700  0 [snap_schedule DEBUG snap_schedule.fs.schedule] Will snapshot snap_test_dir13 in fs cephfs in 38s
2020-04-14T04:46:01.074-0400 7f5a0d83a700  0 [snap_schedule DEBUG snap_schedule.fs.schedule] Will snapshot snap_test_dir13 in fs cephfs in 119s

The test schedules a snap every 2 minutes, but the first snap is scheduled in 38 odd seconds for some reason (the test expects the snap to show up in about 98 seconds (1m + 38s)). Also, this happens once in a while (I checked if there were any stale snap schedules, but there were none). And similar with multiple snap schedules per path ( test_multi_snap_schedule test) as below:

2020-04-14T04:50:28.320-0400 7fe38b690700  0 [snap_schedule DEBUG snap_schedule.fs.schedule] Will snapshot snap_test_dir14 in fs cephfs in 92s
2020-04-14T04:50:28.808-0400 7fe38b690700  0 [snap_schedule DEBUG snap_schedule.fs.schedule] Will snapshot snap_test_dir14 in fs cephfs in 32s
2020-04-14T04:51:00.923-0400 7fe369ccd700  0 [snap_schedule DEBUG snap_schedule.fs.schedule] Will snapshot snap_test_dir14 in fs cephfs in 60s
2020-04-14T04:52:00.983-0400 7fe3654c4700  0 [snap_schedule DEBUG snap_schedule.fs.schedule] Will snapshot snap_test_dir14 in fs cephfs in 120s

The timings look a bit off to me...

@jan--f
Copy link
Contributor

jan--f commented Apr 16, 2020

thanks @vshankar I'll look into these issue. I haven't yet paid to close attention to the timings, mostly cause I still need to add proper support for start argument to delay snapshots till a given start time. Timezones are also still an open question. I'll bring this up on our next standup.

@jan--f
Copy link
Contributor

jan--f commented Apr 16, 2020

The mentioned issues should be fixed in #29489

@vshankar
Copy link
Contributor Author

The mentioned issues should be fixed in #29489

will take a look

@vshankar
Copy link
Contributor Author

@jan--f -- test_multi_snap_schedule still fails with the latest push for PR #29489

The test schedules multiple snaps schedules (2m and 3m) on a directory, but the snaps get scheduled every 2m.

2020-04-23T09:05:44.791-0400 7f205d2ed700  0 [snap_schedule DEBUG snap_schedule.fs.schedule] Will snapshot snap_test_dir1 in fs cephfs in 120s
2020-04-23T09:05:45.259-0400 7f205d2ed700  0 [snap_schedule DEBUG snap_schedule.fs.schedule] Will snapshot snap_test_dir1 in fs cephfs in 119s

@ukernel
Copy link
Contributor

ukernel commented Apr 23, 2020

Is 'ceph mgr module enable snap_schedule' supported already in master branch? I tried the command, it return -ENOENT

@jan--f
Copy link
Contributor

jan--f commented Apr 23, 2020

@ukernel not yet, the module PR is #29489

@ukernel
Copy link
Contributor

ukernel commented Apr 23, 2020

does the snap_schedule module remove old snapshots. If yes, it's better to add a test case

@jan--f
Copy link
Contributor

jan--f commented Apr 23, 2020

does the snap_schedule module remove old snapshots. If yes, it's better to add a test case

It does indeed and I'll add tests for that. I'm in the final stages for the mgr module and will add more tests once this is stabilized.

@vshankar vshankar force-pushed the wip-snap-sched-tests branch 2 times, most recently from 3dc0ff0 to 1e99730 Compare April 23, 2020 16:54
retention = set([s[1] for s in spec])
return (schedule, retention)

def seconds_upto_next_schedule(time_from, timo):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: this routine would not be required w/ @jan--f latest changes to PR #29489

@vshankar
Copy link
Contributor Author

@jan--f please use the latest update from this for the tests...

@stale
Copy link

stale bot commented Jun 23, 2020

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@stale stale bot added the stale label Jun 23, 2020
@vshankar vshankar force-pushed the wip-snap-sched-tests branch from 1e99730 to 4d1612a Compare August 20, 2020 11:04
@stale stale bot removed the stale label Aug 20, 2020
@vshankar vshankar changed the title [WIP]: add snap schedule tests test: add snap schedule tests Aug 20, 2020
@vshankar vshankar marked this pull request as ready for review August 21, 2020 14:03
Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rebase. @vshankar please run this test through teuthology when ready and post the results.

@vshankar
Copy link
Contributor Author

vshankar commented Sep 1, 2020

Let's rebase. @vshankar please run this test through teuthology when ready and post the results.

ack

@vshankar vshankar force-pushed the wip-snap-sched-tests branch from 4d1612a to 0823c15 Compare September 2, 2020 10:46
@vshankar
Copy link
Contributor Author

What's the motivation for storing the allow_minute_snaps flag on a per schedule basis in the DB?

Looking at the changes, I don't seem to recall with acuracy for reason to store it in the db.

I think we shouldn't store this in the DB, as that would make for a strange UI. Say a user unsets the option for the mgr module but has schedules in the DB with this option. Keeping this as a runtime module option makes more sense to me. We'd need to add some better error handling for the case of minute granularity snapshots in the DB and the option turned off. But I think just skipping those schedules plus logging it should be least surprising?

Probably. However, I won't be able to get to looking at it (and fixing) this week. Sorry for that! I'll try to get to it next week. In case you want to give it a shot, that'll be great (since this blocks the octopus backport).

@jan--f
Copy link
Contributor

jan--f commented Oct 29, 2020

@vshankar I have my proposed changes up at https://github.com/jan--f/ceph/tree/wip-snap-sched-tests

Maybe we can re-use this PR to keep the discussion here?

@vshankar
Copy link
Contributor Author

@vshankar I have my proposed changes up at https://github.com/jan--f/ceph/tree/wip-snap-sched-tests

I'll take a look. Thx!

Maybe we can re-use this PR to keep the discussion here?

Sure.

@vshankar
Copy link
Contributor Author

vshankar commented Nov 2, 2020

@vshankar I have my proposed changes up at https://github.com/jan--f/ceph/tree/wip-snap-sched-tests

Look OK. I'll test out the changes tomorrow.

@vshankar
Copy link
Contributor Author

vshankar commented Nov 3, 2020

Look OK. I'll test out the changes tomorrow.

tests run fine. I will pull your changes in this PR and post the test results.

We should be able to get this merged pretty soon.

@vshankar vshankar force-pushed the wip-snap-sched-tests branch from 000fccb to 8a9ee82 Compare November 4, 2020 08:35
@vshankar
Copy link
Contributor Author

vshankar commented Nov 4, 2020

jenkins test make check

@vshankar
Copy link
Contributor Author

vshankar commented Nov 4, 2020

@vshankar
Copy link
Contributor Author

vshankar commented Nov 6, 2020

jenkins test make check

1 similar comment
@jan--f
Copy link
Contributor

jan--f commented Nov 12, 2020

jenkins test make check

@vshankar vshankar force-pushed the wip-snap-sched-tests branch from 8a9ee82 to 1804a4a Compare November 16, 2020 05:58
@vshankar
Copy link
Contributor Author

@batrick @jan--f make check fixed. please take a look

@batrick
Copy link
Member

batrick commented Nov 17, 2020

@vshankar this needs rebased. fs:basic_functional no longer exists.

@vshankar
Copy link
Contributor Author

@vshankar this needs rebased. fs:basic_functional no longer exists.

ack -- I'll push an update.

Copy link
Member

@batrick batrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also run through testing.

Otherwise LGTM.

vshankar and others added 6 commits November 17, 2020 01:15
Next commit introduces a module option to allow minute granularity
snapshots.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
Thsi allows setting and scheduling snapshots with minute granularity. If
the option is unset, adding these will fail and scheduling for them will
be skipped.

Signed-off-by: Jan Fajerski <jfajerski@suse.com>
For easiness in parsing for tests.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
... mostly as an aid for debugging.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
Signed-off-by: Venky Shankar <vshankar@redhat.com>
@vshankar vshankar force-pushed the wip-snap-sched-tests branch from 1804a4a to a8c8b3a Compare November 17, 2020 13:41
@batrick
Copy link
Member

batrick commented Nov 17, 2020

jenkins test api

@batrick
Copy link
Member

batrick commented Nov 17, 2020

@vshankar please run through QA for the snap schedule tests whenever you're ready.

@vshankar
Copy link
Contributor Author

@vshankar please run through QA for the snap schedule tests whenever you're ready.

sure -- will post the link.

@vshankar
Copy link
Contributor Author

@batrick batrick merged commit cfabba6 into ceph:master Nov 18, 2020
@vshankar vshankar deleted the wip-snap-sched-tests branch November 18, 2020 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cephfs Ceph File System needs-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants