Skip to content

Commit 55db9de

Browse files
committed
Add the unit test for blkioStats
1 parent dc17d91 commit 55db9de

File tree

3 files changed

+108
-6
lines changed

3 files changed

+108
-6
lines changed

src/main/java/com/github/dockerjava/api/model/IoRecursiveConfig.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class IoRecursiveConfig implements Serializable {
1717
private Long minor;
1818

1919
@JsonProperty("op")
20-
private Long op;
20+
private String op;
2121

2222
@JsonProperty("value")
2323
private Long value;
@@ -41,7 +41,7 @@ public Long getMinor() {
4141
/**
4242
* @see #op
4343
*/
44-
public Long getOp() {
44+
public String getOp() {
4545
return op;
4646
}
4747

@@ -51,4 +51,36 @@ public Long getOp() {
5151
public Long getValue() {
5252
return value;
5353
}
54+
55+
/**
56+
* @see #major
57+
*/
58+
public IoRecursiveConfig withMajor(Long major) {
59+
this.major = major;
60+
return this;
61+
}
62+
63+
/**
64+
* @see #minor
65+
*/
66+
public IoRecursiveConfig withMinor(Long minor) {
67+
this.minor = minor;
68+
return this;
69+
}
70+
71+
/**
72+
* @see #op
73+
*/
74+
public IoRecursiveConfig withOp(String op) {
75+
this.op = op;
76+
return this;
77+
}
78+
79+
/**
80+
* @see #value
81+
*/
82+
public IoRecursiveConfig withValue(Long value) {
83+
this.value = value;
84+
return this;
85+
}
5486
}

src/test/java/com/github/dockerjava/api/model/StatisticsTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,20 @@ public void serderJson1() throws IOException {
8484
assertThat(memoryStats.getLimit(), is(2095874048L));
8585

8686
final BlkioStatsConfig blkioStats = statistics.getBlkioStats();
87-
assertThat(blkioStats.getIoServiceBytesRecursive(), is(empty()));
88-
assertThat(blkioStats.getIoServicedRecursive(), is(empty()));
87+
assertThat(blkioStats.getIoServiceBytesRecursive(), equalTo(Arrays.asList(
88+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Read").withValue(823296L),
89+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Write").withValue(122880L),
90+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Sync").withValue(835584L),
91+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Async").withValue(110592L),
92+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Total").withValue(946176L)
93+
)));
94+
assertThat(blkioStats.getIoServicedRecursive(), equalTo(Arrays.asList(
95+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Read").withValue(145L),
96+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Write").withValue(4L),
97+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Sync").withValue(148L),
98+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Async").withValue(1L),
99+
new IoRecursiveConfig().withMajor(259L).withMinor(0L).withOp("Total").withValue(149L)
100+
)));
89101
assertThat(blkioStats.getIoQueueRecursive(), is(empty()));
90102
assertThat(blkioStats.getIoServiceTimeRecursive(), is(empty()));
91103
assertThat(blkioStats.getIoWaitTimeRecursive(), is(empty()));

src/test/resources/samples/1.27/containers/container/stats/stats1.json

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,68 @@
66
},
77
"blkio_stats":{
88
"io_service_bytes_recursive":[
9-
9+
{
10+
"major":259,
11+
"minor":0,
12+
"op":"Read",
13+
"value":823296
14+
},
15+
{
16+
"major":259,
17+
"minor":0,
18+
"op":"Write",
19+
"value":122880
20+
},
21+
{
22+
"major":259,
23+
"minor":0,
24+
"op":"Sync",
25+
"value":835584
26+
},
27+
{
28+
"major":259,
29+
"minor":0,
30+
"op":"Async",
31+
"value":110592
32+
},
33+
{
34+
"major":259,
35+
"minor":0,
36+
"op":"Total",
37+
"value":946176
38+
}
1039
],
1140
"io_serviced_recursive":[
12-
41+
{
42+
"major":259,
43+
"minor":0,
44+
"op":"Read",
45+
"value":145
46+
},
47+
{
48+
"major":259,
49+
"minor":0,
50+
"op":"Write",
51+
"value":4
52+
},
53+
{
54+
"major":259,
55+
"minor":0,
56+
"op":"Sync",
57+
"value":148
58+
},
59+
{
60+
"major":259,
61+
"minor":0,
62+
"op":"Async",
63+
"value":1
64+
},
65+
{
66+
"major":259,
67+
"minor":0,
68+
"op":"Total",
69+
"value":149
70+
}
1371
],
1472
"io_queue_recursive":[
1573

0 commit comments

Comments
 (0)