Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
7857ac59
Commit
7857ac59
authored
6 years ago
by
Lang Martin
Browse files
Options
Download
Email Patches
Plain Diff
client tests assert the independent handling of interface and speed
parent
658916e3
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/client_test.go
+27
-3
client/client_test.go
with
27 additions
and
3 deletions
+27
-3
client/client_test.go
+
27
-
3
View file @
7857ac59
...
...
@@ -1268,7 +1268,8 @@ func TestClient_UpdateNodeFromFingerprintKeepsConfig(t *testing.T) {
assert
.
Equal
(
t
,
80
,
client
.
config
.
Node
.
Resources
.
CPU
)
assert
.
Equal
(
t
,
"any-interface"
,
client
.
config
.
Node
.
Resources
.
Networks
[
0
]
.
Device
)
// Client with network configured keeps the config setting on update
// Client with network interface configured keeps the config
// setting on update
name
:=
"TestClient_UpdateNodeFromFingerprintKeepsConfig2"
client
,
cleanup
=
TestClient
(
t
,
func
(
c
*
config
.
Config
)
{
c
.
NetworkInterface
=
dev
...
...
@@ -1280,8 +1281,11 @@ func TestClient_UpdateNodeFromFingerprintKeepsConfig(t *testing.T) {
defer
cleanup
()
client
.
updateNodeFromFingerprint
(
&
fingerprint
.
FingerprintResponse
{
NodeResources
:
&
structs
.
NodeResources
{
Cpu
:
structs
.
NodeCpuResources
{
CpuShares
:
123
},
Networks
:
[]
*
structs
.
NetworkResource
{{
Device
:
"any-interface"
}},
Cpu
:
structs
.
NodeCpuResources
{
CpuShares
:
123
},
Networks
:
[]
*
structs
.
NetworkResource
{
{
Device
:
"any-interface"
,
MBits
:
20
},
{
Device
:
dev
,
MBits
:
20
},
},
},
Resources
:
&
structs
.
Resources
{
CPU
:
80
,
...
...
@@ -1289,9 +1293,29 @@ func TestClient_UpdateNodeFromFingerprintKeepsConfig(t *testing.T) {
},
})
assert
.
Equal
(
t
,
int64
(
123
),
client
.
config
.
Node
.
NodeResources
.
Cpu
.
CpuShares
)
// only the configured device is kept
assert
.
Equal
(
t
,
1
,
len
(
client
.
config
.
Node
.
NodeResources
.
Networks
))
assert
.
Equal
(
t
,
dev
,
client
.
config
.
Node
.
NodeResources
.
Networks
[
0
]
.
Device
)
// network speed updates to the configured network are kept
assert
.
Equal
(
t
,
20
,
client
.
config
.
Node
.
NodeResources
.
Networks
[
0
]
.
MBits
)
assert
.
Equal
(
t
,
80
,
client
.
config
.
Node
.
Resources
.
CPU
)
assert
.
Equal
(
t
,
dev
,
client
.
config
.
Node
.
Resources
.
Networks
[
0
]
.
Device
)
// Network speed is applied to all NetworkResources
client
.
config
.
NetworkInterface
=
""
client
.
config
.
NetworkSpeed
=
100
client
.
updateNodeFromFingerprint
(
&
fingerprint
.
FingerprintResponse
{
NodeResources
:
&
structs
.
NodeResources
{
Cpu
:
structs
.
NodeCpuResources
{
CpuShares
:
123
},
Networks
:
[]
*
structs
.
NetworkResource
{{
Device
:
"any-interface"
,
MBits
:
20
}},
},
Resources
:
&
structs
.
Resources
{
CPU
:
80
,
Networks
:
[]
*
structs
.
NetworkResource
{{
Device
:
"any-interface"
}},
},
})
assert
.
Equal
(
t
,
"any-interface"
,
client
.
config
.
Node
.
NodeResources
.
Networks
[
0
]
.
Device
)
assert
.
Equal
(
t
,
100
,
client
.
config
.
Node
.
NodeResources
.
Networks
[
0
]
.
MBits
)
}
func
TestClient_computeAllocatedDeviceStats
(
t
*
testing
.
T
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help