@@ -39,17 +39,18 @@ func TestCancelJob(t *testing.T) {
39
39
})
40
40
defer done ()
41
41
42
- disk := BlockDevice {Device : device }
43
- err := disk . CancelJob (d , defaultTestTimeout )
42
+ job := BlockJob {Device : device }
43
+ err := job . Cancel (d , defaultTestTimeout )
44
44
if err != nil {
45
45
t .Error (err )
46
46
}
47
47
}
48
48
49
49
func TestCommit (t * testing.T ) {
50
50
const (
51
- device = "drive-virtio-disk0 "
51
+ device = "inserted[node-name] before commit "
52
52
overlay = "/tmp/foo.img"
53
+ jobID = "made-up-job-id-for-the-commit"
53
54
)
54
55
d , done := testDomain (t , func (cmd qmp.Command ) (interface {}, error ) {
55
56
if want , got := "block-commit" , cmd .Execute ; want != got {
@@ -66,20 +67,24 @@ func TestCommit(t *testing.T) {
66
67
t .Fatalf ("unexpected device:\n - want: %q\n - got: %q" ,
67
68
want , got )
68
69
}
70
+ if want , got := jobID , args ["job-id" ]; want != got {
71
+ t .Fatalf ("unexpected job-id:\n - want: %q\n - got: %q" ,
72
+ want , got )
73
+ }
69
74
70
75
return success {}, nil
71
76
})
72
77
defer done ()
73
78
74
- disk := BlockDevice {Device : device }
75
- err := disk .Commit (d , overlay , defaultTestTimeout )
79
+ disk := BlockDevice {}
80
+ disk .Inserted .NodeName = device
81
+ err := disk .Commit (d , overlay , jobID , defaultTestTimeout )
76
82
if err != nil {
77
83
t .Error (err )
78
84
}
79
85
}
80
86
81
87
func TestCommitActiveBlockJob (t * testing.T ) {
82
- const device = "drive-virtio-disk0"
83
88
d , done := testDomain (t , func (_ qmp.Command ) (interface {}, error ) {
84
89
return failure {
85
90
Error : map [string ]string {
@@ -89,8 +94,8 @@ func TestCommitActiveBlockJob(t *testing.T) {
89
94
})
90
95
defer done ()
91
96
92
- disk := BlockDevice {Device : device }
93
- err := disk .Commit (d , "/tmp/foo" , defaultTestTimeout )
97
+ disk := BlockDevice {}
98
+ err := disk .Commit (d , "/tmp/foo" , "job-id" , defaultTestTimeout )
94
99
if err == nil {
95
100
t .Errorf ("expected blockcommit with active blockjob to fail" )
96
101
}
@@ -103,8 +108,8 @@ func TestCommitBlockJobError(t *testing.T) {
103
108
d .m .(* testMonitor ).eventErrors = true
104
109
defer done ()
105
110
106
- disk := BlockDevice {Device : "test" }
107
- err := disk .Commit (d , "/tmp/foo" , defaultTestTimeout )
111
+ disk := BlockDevice {}
112
+ err := disk .Commit (d , "/tmp/foo" , "job-id" , defaultTestTimeout )
108
113
if err == nil {
109
114
t .Error ("expected block job error to cause failure" )
110
115
}
@@ -118,7 +123,7 @@ func TestCommitTimeout(t *testing.T) {
118
123
defer done ()
119
124
120
125
disk := BlockDevice {Device : "test" }
121
- err := disk .Commit (d , "/tmp/foo" , 0 )
126
+ err := disk .Commit (d , "/tmp/foo" , "job-id" , 0 )
122
127
if err == nil {
123
128
t .Error ("expected timeout" )
124
129
}
@@ -142,8 +147,8 @@ func TestJobComplete(t *testing.T) {
142
147
})
143
148
defer done ()
144
149
145
- disk := BlockDevice {Device : device }
146
- err := disk . CompleteJob (d , defaultTestTimeout )
150
+ job := BlockJob {Device : device }
151
+ err := job . Complete (d , defaultTestTimeout )
147
152
if err != nil {
148
153
t .Error (err )
149
154
}
@@ -156,8 +161,8 @@ func TestJobCompleteEventError(t *testing.T) {
156
161
d .m .(* testMonitor ).eventErrors = true
157
162
defer done ()
158
163
159
- disk := BlockDevice {Device : "test" }
160
- err := disk . CompleteJob (d , defaultTestTimeout )
164
+ job := BlockJob {Device : "test" }
165
+ err := job . Complete (d , defaultTestTimeout )
161
166
if err == nil {
162
167
t .Error ("expected block job error to cause failure" )
163
168
}
@@ -170,8 +175,8 @@ func TestJobCompleteTimeout(t *testing.T) {
170
175
d .m .(* testMonitor ).eventTimeout = true
171
176
defer done ()
172
177
173
- disk := BlockDevice {Device : "test" }
174
- err := disk . CompleteJob (d , 0 )
178
+ job := BlockJob {Device : "test" }
179
+ err := job . Complete (d , 0 )
175
180
if err == nil {
176
181
t .Error ("expected timeout" )
177
182
}
@@ -229,8 +234,9 @@ func TestMirrorRelativePath(t *testing.T) {
229
234
230
235
func TestSnapshot (t * testing.T ) {
231
236
const (
232
- device = "drive-virtio-disk0"
233
- overlay = "/tmp/foo.img"
237
+ device = "drive-virtio-disk0"
238
+ overlay = "/tmp/foo.img"
239
+ nodeName = "my-node"
234
240
)
235
241
d , done := testDomain (t , func (cmd qmp.Command ) (interface {}, error ) {
236
242
if want , got := "blockdev-snapshot-sync" , cmd .Execute ; want != got {
@@ -239,7 +245,7 @@ func TestSnapshot(t *testing.T) {
239
245
}
240
246
241
247
args , _ := cmd .Args .(map [string ]interface {})
242
- if want , got := device , args ["device " ]; want != got {
248
+ if want , got := device , args ["node-name " ]; want != got {
243
249
t .Fatalf ("unexpected device:\n - want: %q\n - got: %q" ,
244
250
want , got )
245
251
}
@@ -249,12 +255,18 @@ func TestSnapshot(t *testing.T) {
249
255
want , got )
250
256
}
251
257
258
+ if want , got := nodeName , args ["snapshot-node-name" ]; want != got {
259
+ t .Fatalf ("unexpected target:\n - want: %q\n - got: %q" ,
260
+ want , got )
261
+ }
262
+
252
263
return success {}, nil
253
264
})
254
265
defer done ()
255
266
256
- disk := BlockDevice {Device : device }
257
- err := disk .Snapshot (d , overlay )
267
+ disk := BlockDevice {}
268
+ disk .Inserted .NodeName = device
269
+ err := disk .Snapshot (d , overlay , "my-node" )
258
270
if err != nil {
259
271
t .Error (err )
260
272
}
0 commit comments