Coverage for mlos_bench/mlos_bench/tests/tunables/tunable_group_update_test.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-06 00:35 +0000

1# 

2# Copyright (c) Microsoft Corporation. 

3# Licensed under the MIT License. 

4# 

5""" 

6Tests for checking the is_updated flag for tunable groups. 

7""" 

8 

9from mlos_bench.tunables.tunable_groups import TunableGroups 

10 

11_TUNABLE_VALUES = { 

12 "kernel_sched_migration_cost_ns": 8888, 

13 "kernel_sched_latency_ns": 9999, 

14} 

15 

16 

17def test_tunable_group_update(tunable_groups: TunableGroups) -> None: 

18 """ 

19 Test that updating a tunable group raises the is_updated flag. 

20 """ 

21 tunable_groups.assign(_TUNABLE_VALUES) 

22 assert tunable_groups.is_updated() 

23 

24 

25def test_tunable_group_update_twice(tunable_groups: TunableGroups) -> None: 

26 """ 

27 Test that updating a tunable group with the same values do *NOT* raises the is_updated flag. 

28 """ 

29 tunable_groups.assign(_TUNABLE_VALUES) 

30 assert tunable_groups.is_updated() 

31 

32 tunable_groups.reset() 

33 assert not tunable_groups.is_updated() 

34 

35 tunable_groups.assign(_TUNABLE_VALUES) 

36 assert not tunable_groups.is_updated() 

37 

38 

39def test_tunable_group_update_kernel(tunable_groups: TunableGroups) -> None: 

40 """ 

41 Test that the is_updated flag is set only for the affected covariant group. 

42 """ 

43 tunable_groups.assign(_TUNABLE_VALUES) 

44 assert tunable_groups.is_updated() 

45 assert tunable_groups.is_updated(["kernel"]) 

46 assert not tunable_groups.is_updated(["boot", "provision"]) 

47 

48 

49def test_tunable_group_update_boot(tunable_groups: TunableGroups) -> None: 

50 """ 

51 Test that the is_updated flag is set only for the affected covariant group. 

52 """ 

53 tunable_groups.assign(_TUNABLE_VALUES) 

54 assert tunable_groups.is_updated() 

55 assert not tunable_groups.is_updated(["boot"]) 

56 

57 tunable_groups.reset() 

58 tunable_groups["idle"] = "mwait" 

59 assert tunable_groups.is_updated() 

60 assert tunable_groups.is_updated(["boot"]) 

61 assert not tunable_groups.is_updated(["kernel"])