|
7 | 7 | from time import sleep |
8 | 8 |
|
9 | 9 | from teuthology.exceptions import CommandFailedError |
| 10 | +from teuthology.contextutil import safe_while |
10 | 11 |
|
11 | 12 | from tasks.cephfs.cephfs_test_case import CephFSTestCase, classhook |
12 | 13 | from tasks.cephfs.filesystem import FileLayout, FSMissing |
|
16 | 17 |
|
17 | 18 | log = logging.getLogger(__name__) |
18 | 19 |
|
| 20 | +class TestLabeledPerfCounters(CephFSTestCase): |
| 21 | + CLIENTS_REQUIRED = 2 |
| 22 | + MDSS_REQUIRED = 1 |
| 23 | + |
| 24 | + def test_per_client_labeled_perf_counters(self): |
| 25 | + """ |
| 26 | + That the per-client labelled perf counters depict the clients |
| 27 | + performaing IO. |
| 28 | + """ |
| 29 | + def get_counters_for(filesystem, client_id): |
| 30 | + dump = self.fs.rank_tell(["counter", "dump"]) |
| 31 | + per_client_metrics_key = f'mds_client_metrics-{filesystem}' |
| 32 | + counters = [c["counters"] for \ |
| 33 | + c in dump[per_client_metrics_key] if c["labels"]["client"] == client_id] |
| 34 | + return counters[0] |
| 35 | + |
| 36 | + # sleep a bit so that we get updated clients... |
| 37 | + sleep(10) |
| 38 | + |
| 39 | + # lookout for clients... |
| 40 | + dump = self.fs.rank_tell(["counter", "dump"]) |
| 41 | + |
| 42 | + fs_suffix = dump["mds_client_metrics"][0]["labels"]["fs_name"] |
| 43 | + self.assertGreaterEqual(dump["mds_client_metrics"][0]["counters"]["num_clients"], 2) |
| 44 | + |
| 45 | + per_client_metrics_key = f'mds_client_metrics-{fs_suffix}' |
| 46 | + mount_a_id = f'client.{self.mount_a.get_global_id()}' |
| 47 | + mount_b_id = f'client.{self.mount_b.get_global_id()}' |
| 48 | + |
| 49 | + clients = [c["labels"]["client"] for c in dump[per_client_metrics_key]] |
| 50 | + self.assertIn(mount_a_id, clients) |
| 51 | + self.assertIn(mount_b_id, clients) |
| 52 | + |
| 53 | + # write workload |
| 54 | + self.mount_a.create_n_files("test_dir/test_file", 1000, sync=True) |
| 55 | + with safe_while(sleep=1, tries=30, action=f'wait for counters - {mount_a_id}') as proceed: |
| 56 | + counters_dump_a = get_counters_for(fs_suffix, mount_a_id) |
| 57 | + while proceed(): |
| 58 | + if counters_dump_a["total_write_ops"] > 0 and counters_dump_a["total_write_size"] > 0: |
| 59 | + return True |
| 60 | + |
| 61 | + # read from the other client |
| 62 | + for i in range(100): |
| 63 | + self.mount_b.open_background(basename=f'test_dir/test_file_{i}', write=False) |
| 64 | + with safe_while(sleep=1, tries=30, action=f'wait for counters - {mount_b_id}') as proceed: |
| 65 | + counters_dump_b = get_counters_for(fs_suffix, mount_b_id) |
| 66 | + while proceed(): |
| 67 | + if counters_dump_b["total_read_ops"] > 0 and counters_dump_b["total_read_size"] > 0: |
| 68 | + return True |
| 69 | + |
| 70 | + self.fs.teardown() |
| 71 | + |
19 | 72 | class TestAdminCommands(CephFSTestCase): |
20 | 73 | """ |
21 | 74 | Tests for administration command. |
|
0 commit comments