4
4
#
5
5
6
6
7
+ from time import sleep
7
8
import pytest
8
9
9
10
18
19
CORE_SIZE = 4096
19
20
20
21
21
- @pytest .mark .xfail (reason = "Data corruption when switching from D2C" )
22
22
def test_d2c_io (pyocf_ctx ):
23
23
"""
24
24
Start cache in D2C
@@ -46,7 +46,8 @@ def test_d2c_io(pyocf_ctx):
46
46
d2c_data .write (b"a" * CORE_SIZE , CORE_SIZE )
47
47
d2c_io .set_data (d2c_data )
48
48
49
- cache .attach_device (cache_device )
49
+ c = cache .attach_device_async (cache_device )
50
+ sleep (1 )
50
51
51
52
wt_io = vol .new_io (queue , 0 , CORE_SIZE , IoDir .WRITE , 0 , 0 )
52
53
wt_data = Data (CORE_SIZE )
@@ -55,18 +56,27 @@ def test_d2c_io(pyocf_ctx):
55
56
56
57
wt_completion = Sync (wt_io ).submit ()
57
58
assert int (wt_completion .results ["err" ]) == 0
58
- assert cache .get_stats ()["req" ]["wr_full_misses" ]["value" ] == 1
59
59
60
60
d2c_completion = Sync (d2c_io ).submit ()
61
61
assert int (d2c_completion .results ["err" ]) == 0
62
- assert cache .get_stats ()["req" ]["wr_pt" ]["value" ] == 1
62
+
63
+ c .wait ()
64
+
65
+ if c .results ["error" ]:
66
+ raise OcfError (
67
+ f"Attaching cache device failed" ,
68
+ c .results ["error" ],
69
+ )
70
+
71
+ assert cache .get_stats ()["req" ]["wr_pt" ]["value" ] == 2
63
72
64
73
read_io = vol .new_io (queue , 0 , CORE_SIZE , IoDir .READ , 0 , 0 )
65
74
read_data = Data (CORE_SIZE )
66
75
read_io .set_data (read_data )
67
76
68
77
read_completion = Sync (read_io ).submit ()
69
78
assert int (read_completion .results ["err" ]) == 0
79
+ assert cache .get_stats ()["req" ]["rd_full_misses" ]["value" ] == 1
70
80
71
81
cache .stop ()
72
82
0 commit comments