]>
Commit | Line | Data |
---|---|---|
f91f0fd5 TL |
1 | """ |
2 | immutable object cache thrash task | |
3 | """ | |
4 | import contextlib | |
5 | import logging | |
6 | ||
7 | from teuthology import misc as teuthology | |
8 | from teuthology import contextutil | |
9 | from teuthology.orchestra import run | |
10 | ||
11 | DEFAULT_KILL_DAEMON_TIME = 2 | |
12 | DEFAULT_DEAD_TIME = 30 | |
13 | DEFAULT_LIVE_TIME = 120 | |
14 | ||
15 | log = logging.getLogger(__name__) | |
16 | ||
17 | @contextlib.contextmanager | |
18 | def thrashes_immutable_object_cache_daemon(ctx, config): | |
19 | """ | |
20 | thrashes immutable object cache daemon. | |
21 | It can test reconnection feature of RO cache when RO daemon crash | |
22 | TODO : replace sleep with better method. | |
23 | """ | |
24 | log.info("thrashes immutable object cache daemon") | |
25 | ||
26 | # just thrash one rbd client. | |
27 | client, client_config = list(config.items())[0] | |
28 | (remote,) = ctx.cluster.only(client).remotes.keys() | |
29 | client_config = client_config if client_config is not None else dict() | |
30 | kill_daemon_time = client_config.get('kill_daemon_time', DEFAULT_KILL_DAEMON_TIME) | |
31 | dead_time = client_config.get('dead_time', DEFAULT_DEAD_TIME) | |
32 | live_time = client_config.get('live_time', DEFAULT_LIVE_TIME) | |
33 | ||
34 | for i in range(kill_daemon_time): | |
35 | log.info("ceph-immutable-object-cache crash....") | |
36 | remote.run( | |
37 | args=[ | |
38 | 'sudo', 'killall', '-s', '9', 'ceph-immutable-object-cache', run.Raw('||'), 'true', | |
39 | ] | |
40 | ) | |
41 | # librbd shoud normally run when ceph-immutable-object-cache | |
42 | remote.run( | |
43 | args=[ | |
44 | 'sleep', '{dead_time}'.format(dead_time=dead_time), | |
45 | ] | |
46 | ) | |
47 | # librbd should reconnect daemon | |
48 | log.info("startup ceph-immutable-object-cache") | |
49 | remote.run( | |
50 | args=[ | |
51 | 'ceph-immutable-object-cache', '-b', | |
52 | ] | |
53 | ) | |
54 | remote.run( | |
55 | args=[ | |
56 | 'sleep', '{live_time}'.format(live_time=live_time), | |
57 | ] | |
58 | ) | |
59 | try: | |
60 | yield | |
61 | finally: | |
62 | log.info("cleanup") | |
63 | ||
64 | @contextlib.contextmanager | |
65 | def task(ctx, config): | |
66 | """ | |
67 | This is task for testing immutable_object_cache thrash. | |
68 | """ | |
69 | assert isinstance(config, dict), \ | |
70 | "task immutable_object_cache_thrash only supports a dictionary for configuration" | |
71 | ||
72 | managers = [] | |
73 | config = teuthology.replace_all_with_clients(ctx.cluster, config) | |
74 | managers.append( | |
75 | lambda: thrashes_immutable_object_cache_daemon(ctx=ctx, config=config) | |
76 | ) | |
77 | ||
78 | with contextutil.nested(*managers): | |
79 | yield |