Skip to content

Commit a83e295

Browse files
authored
Merge pull request kubernetes#127644 from kiashok/refactor-hcs-references
Add local reference to hcs structs in windows cri stats test
2 parents 996e674 + 4a5513c commit a83e295

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

pkg/kubelet/stats/cri_stats_provider_windows_test.go

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,24 @@ type fakeNetworkStatsProvider struct {
3939
containers []containerStats
4040
}
4141

42+
// NetworkStats holds the network statistics for a container
43+
type fakeNetworkStats struct {
44+
BytesReceived uint64
45+
BytesSent uint64
46+
PacketsReceived uint64
47+
PacketsSent uint64
48+
DroppedPacketsIncoming uint64
49+
DroppedPacketsOutgoing uint64
50+
EndpointId string
51+
InstanceId string
52+
}
53+
54+
type fakeContainerProperties struct {
55+
ID string
56+
}
4257
type containerStats struct {
43-
container hcsshim.ContainerProperties
44-
hcsStats []hcsshim.NetworkStats
58+
container fakeContainerProperties
59+
hcsStats []fakeNetworkStats
4560
}
4661

4762
func (s fakeNetworkStatsProvider) GetHNSEndpointStats(endpointName string) (*hcsshim.HNSEndpointStats, error) {
@@ -105,9 +120,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
105120
fields: fakeNetworkStatsProvider{
106121
containers: []containerStats{
107122
{
108-
container: hcsshim.ContainerProperties{
123+
container: fakeContainerProperties{
109124
ID: "c1",
110-
}, hcsStats: []hcsshim.NetworkStats{
125+
}, hcsStats: []fakeNetworkStats{
111126
{
112127
BytesReceived: 1,
113128
BytesSent: 10,
@@ -117,9 +132,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
117132
},
118133
},
119134
{
120-
container: hcsshim.ContainerProperties{
135+
container: fakeContainerProperties{
121136
ID: "c2",
122-
}, hcsStats: []hcsshim.NetworkStats{
137+
}, hcsStats: []fakeNetworkStats{
123138
{
124139
BytesReceived: 2,
125140
BytesSent: 20,
@@ -170,9 +185,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
170185
fields: fakeNetworkStatsProvider{
171186
containers: []containerStats{
172187
{
173-
container: hcsshim.ContainerProperties{
188+
container: fakeContainerProperties{
174189
ID: "c1",
175-
}, hcsStats: []hcsshim.NetworkStats{
190+
}, hcsStats: []fakeNetworkStats{
176191
{
177192
BytesReceived: 1,
178193
BytesSent: 10,
@@ -182,9 +197,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
182197
},
183198
},
184199
{
185-
container: hcsshim.ContainerProperties{
200+
container: fakeContainerProperties{
186201
ID: "c2",
187-
}, hcsStats: []hcsshim.NetworkStats{
202+
}, hcsStats: []fakeNetworkStats{
188203
{
189204
BytesReceived: 2,
190205
BytesSent: 20,
@@ -194,9 +209,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
194209
},
195210
},
196211
{
197-
container: hcsshim.ContainerProperties{
212+
container: fakeContainerProperties{
198213
ID: "c3",
199-
}, hcsStats: []hcsshim.NetworkStats{
214+
}, hcsStats: []fakeNetworkStats{
200215
{
201216
BytesReceived: 3,
202217
BytesSent: 30,
@@ -262,9 +277,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
262277
fields: fakeNetworkStatsProvider{
263278
containers: []containerStats{
264279
{
265-
container: hcsshim.ContainerProperties{
280+
container: fakeContainerProperties{
266281
ID: "c1",
267-
}, hcsStats: []hcsshim.NetworkStats{
282+
}, hcsStats: []fakeNetworkStats{
268283
{
269284
BytesReceived: 1,
270285
BytesSent: 10,
@@ -280,9 +295,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
280295
},
281296
},
282297
{
283-
container: hcsshim.ContainerProperties{
298+
container: fakeContainerProperties{
284299
ID: "c2",
285-
}, hcsStats: []hcsshim.NetworkStats{
300+
}, hcsStats: []fakeNetworkStats{
286301
{
287302
BytesReceived: 2,
288303
BytesSent: 20,
@@ -333,9 +348,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
333348
fields: fakeNetworkStatsProvider{
334349
containers: []containerStats{
335350
{
336-
container: hcsshim.ContainerProperties{
351+
container: fakeContainerProperties{
337352
ID: "c1",
338-
}, hcsStats: []hcsshim.NetworkStats{
353+
}, hcsStats: []fakeNetworkStats{
339354
{
340355
BytesReceived: 1,
341356
BytesSent: 10,
@@ -351,9 +366,9 @@ func Test_criStatsProvider_listContainerNetworkStats(t *testing.T) {
351366
},
352367
},
353368
{
354-
container: hcsshim.ContainerProperties{
369+
container: fakeContainerProperties{
355370
ID: "c2",
356-
}, hcsStats: []hcsshim.NetworkStats{
371+
}, hcsStats: []fakeNetworkStats{
357372
{
358373
BytesReceived: 2,
359374
BytesSent: 20,

0 commit comments

Comments
 (0)