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
b0385582
Commit
b0385582
authored
3 years ago
by
Seth Hoenig
Browse files
Options
Download
Email Patches
Plain Diff
wip need cpu cores
parent
ac0d9001
Changes
57
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
client/acl_test.go
+0
-1
client/acl_test.go
client/agent_endpoint_test.go
+5
-7
client/agent_endpoint_test.go
client/alloc_endpoint_test.go
+14
-18
client/alloc_endpoint_test.go
client/alloc_watcher_e2e_test.go
+1
-1
client/alloc_watcher_e2e_test.go
client/allochealth/tracker_test.go
+0
-7
client/allochealth/tracker_test.go
client/allocrunner/alloc_runner_test.go
+2
-17
client/allocrunner/alloc_runner_test.go
client/allocrunner/alloc_runner_unix_test.go
+0
-3
client/allocrunner/alloc_runner_unix_test.go
client/allocrunner/consul_grpc_sock_hook_test.go
+0
-3
client/allocrunner/consul_grpc_sock_hook_test.go
client/allocrunner/consul_http_sock_hook_test.go
+0
-2
client/allocrunner/consul_http_sock_hook_test.go
client/allocrunner/groupservice_hook_test.go
+0
-5
client/allocrunner/groupservice_hook_test.go
client/allocrunner/health_hook_test.go
+6
-8
client/allocrunner/health_hook_test.go
client/allocrunner/taskrunner/artifact_hook_test.go
+0
-2
client/allocrunner/taskrunner/artifact_hook_test.go
client/allocrunner/taskrunner/connect_native_hook_test.go
+6
-13
client/allocrunner/taskrunner/connect_native_hook_test.go
client/allocrunner/taskrunner/device_hook_test.go
+2
-2
client/allocrunner/taskrunner/device_hook_test.go
client/allocrunner/taskrunner/dispatch_hook_test.go
+0
-3
client/allocrunner/taskrunner/dispatch_hook_test.go
client/allocrunner/taskrunner/envoy_bootstrap_hook_test.go
+6
-10
client/allocrunner/taskrunner/envoy_bootstrap_hook_test.go
client/allocrunner/taskrunner/envoy_version_hook_test.go
+0
-10
client/allocrunner/taskrunner/envoy_version_hook_test.go
client/allocrunner/taskrunner/errors_test.go
+0
-2
client/allocrunner/taskrunner/errors_test.go
client/allocrunner/taskrunner/logmon_hook_test.go
+0
-2
client/allocrunner/taskrunner/logmon_hook_test.go
client/allocrunner/taskrunner/logmon_hook_unix_test.go
+0
-2
client/allocrunner/taskrunner/logmon_hook_unix_test.go
with
42 additions
and
118 deletions
+42
-118
client/acl_test.go
+
0
-
1
View file @
b0385582
...
@@ -167,7 +167,6 @@ func TestClient_ACL_ResolveToken(t *testing.T) {
...
@@ -167,7 +167,6 @@ func TestClient_ACL_ResolveToken(t *testing.T) {
}
}
func
TestClient_ACL_ResolveSecretToken
(
t
*
testing
.
T
)
{
func
TestClient_ACL_ResolveSecretToken
(
t
*
testing
.
T
)
{
s1
,
_
,
_
,
cleanupS1
:=
testACLServer
(
t
,
nil
)
s1
,
_
,
_
,
cleanupS1
:=
testACLServer
(
t
,
nil
)
defer
cleanupS1
()
defer
cleanupS1
()
...
...
This diff is collapsed.
Click to expand it.
client/agent_endpoint_test.go
+
5
-
7
View file @
b0385582
...
@@ -24,7 +24,7 @@ import (
...
@@ -24,7 +24,7 @@ import (
)
)
func
TestMonitor_Monitor
(
t
*
testing
.
T
)
{
func
TestMonitor_Monitor
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
// start server and client
// start server and client
...
@@ -105,7 +105,7 @@ OUTER:
...
@@ -105,7 +105,7 @@ OUTER:
}
}
func
TestMonitor_Monitor_ACL
(
t
*
testing
.
T
)
{
func
TestMonitor_Monitor_ACL
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
// start server
// start server
...
@@ -217,7 +217,7 @@ func TestMonitor_Monitor_ACL(t *testing.T) {
...
@@ -217,7 +217,7 @@ func TestMonitor_Monitor_ACL(t *testing.T) {
// Test that by default with no acl, endpoint is disabled
// Test that by default with no acl, endpoint is disabled
func
TestAgentProfile_DefaultDisabled
(
t
*
testing
.
T
)
{
func
TestAgentProfile_DefaultDisabled
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
// start server and client
// start server and client
...
@@ -243,7 +243,7 @@ func TestAgentProfile_DefaultDisabled(t *testing.T) {
...
@@ -243,7 +243,7 @@ func TestAgentProfile_DefaultDisabled(t *testing.T) {
}
}
func
TestAgentProfile
(
t
*
testing
.
T
)
{
func
TestAgentProfile
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
// start server and client
// start server and client
...
@@ -290,7 +290,7 @@ func TestAgentProfile(t *testing.T) {
...
@@ -290,7 +290,7 @@ func TestAgentProfile(t *testing.T) {
}
}
func
TestAgentProfile_ACL
(
t
*
testing
.
T
)
{
func
TestAgentProfile_ACL
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
// start server
// start server
...
@@ -355,7 +355,6 @@ func TestAgentProfile_ACL(t *testing.T) {
...
@@ -355,7 +355,6 @@ func TestAgentProfile_ACL(t *testing.T) {
}
}
func
TestAgentHost
(
t
*
testing
.
T
)
{
func
TestAgentHost
(
t
*
testing
.
T
)
{
// start server and client
// start server and client
s1
,
cleanup
:=
nomad
.
TestServer
(
t
,
nil
)
s1
,
cleanup
:=
nomad
.
TestServer
(
t
,
nil
)
...
@@ -380,7 +379,6 @@ func TestAgentHost(t *testing.T) {
...
@@ -380,7 +379,6 @@ func TestAgentHost(t *testing.T) {
}
}
func
TestAgentHost_ACL
(
t
*
testing
.
T
)
{
func
TestAgentHost_ACL
(
t
*
testing
.
T
)
{
s
,
root
,
cleanupS
:=
nomad
.
TestACLServer
(
t
,
nil
)
s
,
root
,
cleanupS
:=
nomad
.
TestACLServer
(
t
,
nil
)
defer
cleanupS
()
defer
cleanupS
()
...
...
This diff is collapsed.
Click to expand it.
client/alloc_endpoint_test.go
+
14
-
18
View file @
b0385582
...
@@ -27,7 +27,7 @@ import (
...
@@ -27,7 +27,7 @@ import (
)
)
func
TestAllocations_Restart
(
t
*
testing
.
T
)
{
func
TestAllocations_Restart
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
client
,
cleanup
:=
TestClient
(
t
,
nil
)
client
,
cleanup
:=
TestClient
(
t
,
nil
)
defer
cleanup
()
defer
cleanup
()
...
@@ -66,7 +66,7 @@ func TestAllocations_Restart(t *testing.T) {
...
@@ -66,7 +66,7 @@ func TestAllocations_Restart(t *testing.T) {
}
}
func
TestAllocations_Restart_ACL
(
t
*
testing
.
T
)
{
func
TestAllocations_Restart_ACL
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
...
@@ -142,7 +142,7 @@ func TestAllocations_Restart_ACL(t *testing.T) {
...
@@ -142,7 +142,7 @@ func TestAllocations_Restart_ACL(t *testing.T) {
}
}
func
TestAllocations_GarbageCollectAll
(
t
*
testing
.
T
)
{
func
TestAllocations_GarbageCollectAll
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
client
,
cleanup
:=
TestClient
(
t
,
nil
)
client
,
cleanup
:=
TestClient
(
t
,
nil
)
defer
cleanup
()
defer
cleanup
()
...
@@ -153,7 +153,7 @@ func TestAllocations_GarbageCollectAll(t *testing.T) {
...
@@ -153,7 +153,7 @@ func TestAllocations_GarbageCollectAll(t *testing.T) {
}
}
func
TestAllocations_GarbageCollectAll_ACL
(
t
*
testing
.
T
)
{
func
TestAllocations_GarbageCollectAll_ACL
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
...
@@ -206,7 +206,7 @@ func TestAllocations_GarbageCollectAll_ACL(t *testing.T) {
...
@@ -206,7 +206,7 @@ func TestAllocations_GarbageCollectAll_ACL(t *testing.T) {
}
}
func
TestAllocations_GarbageCollect
(
t
*
testing
.
T
)
{
func
TestAllocations_GarbageCollect
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
client
,
cleanup
:=
TestClient
(
t
,
func
(
c
*
config
.
Config
)
{
client
,
cleanup
:=
TestClient
(
t
,
func
(
c
*
config
.
Config
)
{
c
.
GCDiskUsageThreshold
=
100.0
c
.
GCDiskUsageThreshold
=
100.0
...
@@ -249,7 +249,7 @@ func TestAllocations_GarbageCollect(t *testing.T) {
...
@@ -249,7 +249,7 @@ func TestAllocations_GarbageCollect(t *testing.T) {
}
}
func
TestAllocations_GarbageCollect_ACL
(
t
*
testing
.
T
)
{
func
TestAllocations_GarbageCollect_ACL
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
...
@@ -322,7 +322,6 @@ func TestAllocations_GarbageCollect_ACL(t *testing.T) {
...
@@ -322,7 +322,6 @@ func TestAllocations_GarbageCollect_ACL(t *testing.T) {
}
}
func
TestAllocations_Signal
(
t
*
testing
.
T
)
{
func
TestAllocations_Signal
(
t
*
testing
.
T
)
{
client
,
cleanup
:=
TestClient
(
t
,
nil
)
client
,
cleanup
:=
TestClient
(
t
,
nil
)
defer
cleanup
()
defer
cleanup
()
...
@@ -348,7 +347,7 @@ func TestAllocations_Signal(t *testing.T) {
...
@@ -348,7 +347,7 @@ func TestAllocations_Signal(t *testing.T) {
}
}
func
TestAllocations_Signal_ACL
(
t
*
testing
.
T
)
{
func
TestAllocations_Signal_ACL
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
...
@@ -420,7 +419,7 @@ func TestAllocations_Signal_ACL(t *testing.T) {
...
@@ -420,7 +419,7 @@ func TestAllocations_Signal_ACL(t *testing.T) {
}
}
func
TestAllocations_Stats
(
t
*
testing
.
T
)
{
func
TestAllocations_Stats
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
client
,
cleanup
:=
TestClient
(
t
,
nil
)
client
,
cleanup
:=
TestClient
(
t
,
nil
)
defer
cleanup
()
defer
cleanup
()
...
@@ -453,7 +452,7 @@ func TestAllocations_Stats(t *testing.T) {
...
@@ -453,7 +452,7 @@ func TestAllocations_Stats(t *testing.T) {
}
}
func
TestAllocations_Stats_ACL
(
t
*
testing
.
T
)
{
func
TestAllocations_Stats_ACL
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
server
,
addr
,
root
,
cleanupS
:=
testACLServer
(
t
,
nil
)
...
@@ -525,7 +524,7 @@ func TestAllocations_Stats_ACL(t *testing.T) {
...
@@ -525,7 +524,7 @@ func TestAllocations_Stats_ACL(t *testing.T) {
}
}
func
TestAlloc_ExecStreaming
(
t
*
testing
.
T
)
{
func
TestAlloc_ExecStreaming
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
// Start a server and client
// Start a server and client
...
@@ -629,7 +628,7 @@ OUTER:
...
@@ -629,7 +628,7 @@ OUTER:
}
}
func
TestAlloc_ExecStreaming_NoAllocation
(
t
*
testing
.
T
)
{
func
TestAlloc_ExecStreaming_NoAllocation
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
// Start a server and client
// Start a server and client
...
@@ -684,7 +683,7 @@ func TestAlloc_ExecStreaming_NoAllocation(t *testing.T) {
...
@@ -684,7 +683,7 @@ func TestAlloc_ExecStreaming_NoAllocation(t *testing.T) {
}
}
func
TestAlloc_ExecStreaming_DisableRemoteExec
(
t
*
testing
.
T
)
{
func
TestAlloc_ExecStreaming_DisableRemoteExec
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
// Start a server and client
// Start a server and client
...
@@ -740,7 +739,6 @@ func TestAlloc_ExecStreaming_DisableRemoteExec(t *testing.T) {
...
@@ -740,7 +739,6 @@ func TestAlloc_ExecStreaming_DisableRemoteExec(t *testing.T) {
}
}
func
TestAlloc_ExecStreaming_ACL_Basic
(
t
*
testing
.
T
)
{
func
TestAlloc_ExecStreaming_ACL_Basic
(
t
*
testing
.
T
)
{
// Start a server and client
// Start a server and client
s
,
root
,
cleanupS
:=
nomad
.
TestACLServer
(
t
,
nil
)
s
,
root
,
cleanupS
:=
nomad
.
TestACLServer
(
t
,
nil
)
...
@@ -843,7 +841,7 @@ func TestAlloc_ExecStreaming_ACL_Basic(t *testing.T) {
...
@@ -843,7 +841,7 @@ func TestAlloc_ExecStreaming_ACL_Basic(t *testing.T) {
// TestAlloc_ExecStreaming_ACL_WithIsolation_Image asserts that token only needs
// TestAlloc_ExecStreaming_ACL_WithIsolation_Image asserts that token only needs
// alloc-exec acl policy when image isolation is used
// alloc-exec acl policy when image isolation is used
func
TestAlloc_ExecStreaming_ACL_WithIsolation_Image
(
t
*
testing
.
T
)
{
func
TestAlloc_ExecStreaming_ACL_WithIsolation_Image
(
t
*
testing
.
T
)
{
isolation
:=
drivers
.
FSIsolationImage
isolation
:=
drivers
.
FSIsolationImage
// Start a server and client
// Start a server and client
...
@@ -987,8 +985,6 @@ func TestAlloc_ExecStreaming_ACL_WithIsolation_Image(t *testing.T) {
...
@@ -987,8 +985,6 @@ func TestAlloc_ExecStreaming_ACL_WithIsolation_Image(t *testing.T) {
// TestAlloc_ExecStreaming_ACL_WithIsolation_Chroot asserts that token only needs
// TestAlloc_ExecStreaming_ACL_WithIsolation_Chroot asserts that token only needs
// alloc-exec acl policy when chroot isolation is used
// alloc-exec acl policy when chroot isolation is used
func
TestAlloc_ExecStreaming_ACL_WithIsolation_Chroot
(
t
*
testing
.
T
)
{
func
TestAlloc_ExecStreaming_ACL_WithIsolation_Chroot
(
t
*
testing
.
T
)
{
if
runtime
.
GOOS
!=
"linux"
||
unix
.
Geteuid
()
!=
0
{
if
runtime
.
GOOS
!=
"linux"
||
unix
.
Geteuid
()
!=
0
{
t
.
Skip
(
"chroot isolation requires linux root"
)
t
.
Skip
(
"chroot isolation requires linux root"
)
}
}
...
@@ -1136,7 +1132,7 @@ func TestAlloc_ExecStreaming_ACL_WithIsolation_Chroot(t *testing.T) {
...
@@ -1136,7 +1132,7 @@ func TestAlloc_ExecStreaming_ACL_WithIsolation_Chroot(t *testing.T) {
// TestAlloc_ExecStreaming_ACL_WithIsolation_None asserts that token needs
// TestAlloc_ExecStreaming_ACL_WithIsolation_None asserts that token needs
// alloc-node-exec acl policy as well when no isolation is used
// alloc-node-exec acl policy as well when no isolation is used
func
TestAlloc_ExecStreaming_ACL_WithIsolation_None
(
t
*
testing
.
T
)
{
func
TestAlloc_ExecStreaming_ACL_WithIsolation_None
(
t
*
testing
.
T
)
{
isolation
:=
drivers
.
FSIsolationNone
isolation
:=
drivers
.
FSIsolationNone
// Start a server and client
// Start a server and client
...
...
This diff is collapsed.
Click to expand it.
client/alloc_watcher_e2e_test.go
+
1
-
1
View file @
b0385582
...
@@ -26,7 +26,7 @@ func TestPrevAlloc_StreamAllocDir_TLS(t *testing.T) {
...
@@ -26,7 +26,7 @@ func TestPrevAlloc_StreamAllocDir_TLS(t *testing.T) {
clientCertFn
=
"../helper/tlsutil/testdata/global-client.pem"
clientCertFn
=
"../helper/tlsutil/testdata/global-client.pem"
clientKeyFn
=
"../helper/tlsutil/testdata/global-client-key.pem"
clientKeyFn
=
"../helper/tlsutil/testdata/global-client-key.pem"
)
)
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
server
,
cleanupS
:=
nomad
.
TestServer
(
t
,
func
(
c
*
nomad
.
Config
)
{
server
,
cleanupS
:=
nomad
.
TestServer
(
t
,
func
(
c
*
nomad
.
Config
)
{
...
...
This diff is collapsed.
Click to expand it.
client/allochealth/tracker_test.go
+
0
-
7
View file @
b0385582
...
@@ -19,7 +19,6 @@ import (
...
@@ -19,7 +19,6 @@ import (
)
)
func
TestTracker_Checks_Healthy
(
t
*
testing
.
T
)
{
func
TestTracker_Checks_Healthy
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
1
// let's speed things up
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
1
// let's speed things up
...
@@ -90,7 +89,6 @@ func TestTracker_Checks_Healthy(t *testing.T) {
...
@@ -90,7 +89,6 @@ func TestTracker_Checks_Healthy(t *testing.T) {
}
}
func
TestTracker_Checks_PendingPostStop_Healthy
(
t
*
testing
.
T
)
{
func
TestTracker_Checks_PendingPostStop_Healthy
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
LifecycleAllocWithPoststopDeploy
()
alloc
:=
mock
.
LifecycleAllocWithPoststopDeploy
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
1
// let's speed things up
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
1
// let's speed things up
...
@@ -130,7 +128,6 @@ func TestTracker_Checks_PendingPostStop_Healthy(t *testing.T) {
...
@@ -130,7 +128,6 @@ func TestTracker_Checks_PendingPostStop_Healthy(t *testing.T) {
}
}
func
TestTracker_Succeeded_PostStart_Healthy
(
t
*
testing
.
T
)
{
func
TestTracker_Succeeded_PostStart_Healthy
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
LifecycleAllocWithPoststartDeploy
()
alloc
:=
mock
.
LifecycleAllocWithPoststartDeploy
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
time
.
Millisecond
*
1
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
time
.
Millisecond
*
1
...
@@ -171,7 +168,6 @@ func TestTracker_Succeeded_PostStart_Healthy(t *testing.T) {
...
@@ -171,7 +168,6 @@ func TestTracker_Succeeded_PostStart_Healthy(t *testing.T) {
}
}
func
TestTracker_Checks_Unhealthy
(
t
*
testing
.
T
)
{
func
TestTracker_Checks_Unhealthy
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
1
// let's speed things up
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
1
// let's speed things up
...
@@ -261,7 +257,6 @@ func TestTracker_Checks_Unhealthy(t *testing.T) {
...
@@ -261,7 +257,6 @@ func TestTracker_Checks_Unhealthy(t *testing.T) {
}
}
func
TestTracker_Healthy_IfBothTasksAndConsulChecksAreHealthy
(
t
*
testing
.
T
)
{
func
TestTracker_Healthy_IfBothTasksAndConsulChecksAreHealthy
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -312,7 +307,6 @@ func TestTracker_Healthy_IfBothTasksAndConsulChecksAreHealthy(t *testing.T) {
...
@@ -312,7 +307,6 @@ func TestTracker_Healthy_IfBothTasksAndConsulChecksAreHealthy(t *testing.T) {
// TestTracker_Checks_Healthy_Before_TaskHealth asserts that we mark an alloc
// TestTracker_Checks_Healthy_Before_TaskHealth asserts that we mark an alloc
// healthy, if the checks pass before task health pass
// healthy, if the checks pass before task health pass
func
TestTracker_Checks_Healthy_Before_TaskHealth
(
t
*
testing
.
T
)
{
func
TestTracker_Checks_Healthy_Before_TaskHealth
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
1
// let's speed things up
alloc
.
Job
.
TaskGroups
[
0
]
.
Migrate
.
MinHealthyTime
=
1
// let's speed things up
...
@@ -419,7 +413,6 @@ func TestTracker_Checks_Healthy_Before_TaskHealth(t *testing.T) {
...
@@ -419,7 +413,6 @@ func TestTracker_Checks_Healthy_Before_TaskHealth(t *testing.T) {
}
}
func
TestTracker_Checks_OnUpdate
(
t
*
testing
.
T
)
{
func
TestTracker_Checks_OnUpdate
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
cases
:=
[]
struct
{
desc
string
desc
string
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/alloc_runner_test.go
+
2
-
17
View file @
b0385582
...
@@ -30,7 +30,6 @@ func destroy(ar *allocRunner) {
...
@@ -30,7 +30,6 @@ func destroy(ar *allocRunner) {
// TestAllocRunner_AllocState_Initialized asserts that getting TaskStates via
// TestAllocRunner_AllocState_Initialized asserts that getting TaskStates via
// AllocState() are initialized even before the AllocRunner has run.
// AllocState() are initialized even before the AllocRunner has run.
func
TestAllocRunner_AllocState_Initialized
(
t
*
testing
.
T
)
{
func
TestAllocRunner_AllocState_Initialized
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Driver
=
"mock_driver"
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Driver
=
"mock_driver"
...
@@ -49,7 +48,6 @@ func TestAllocRunner_AllocState_Initialized(t *testing.T) {
...
@@ -49,7 +48,6 @@ func TestAllocRunner_AllocState_Initialized(t *testing.T) {
// TestAllocRunner_TaskLeader_KillTG asserts that when a leader task dies the
// TestAllocRunner_TaskLeader_KillTG asserts that when a leader task dies the
// entire task group is killed.
// entire task group is killed.
func
TestAllocRunner_TaskLeader_KillTG
(
t
*
testing
.
T
)
{
func
TestAllocRunner_TaskLeader_KillTG
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
...
@@ -239,7 +237,6 @@ func TestAllocRunner_Lifecycle_Poststart(t *testing.T) {
...
@@ -239,7 +237,6 @@ func TestAllocRunner_Lifecycle_Poststart(t *testing.T) {
// TestAllocRunner_TaskMain_KillTG asserts that when main tasks die the
// TestAllocRunner_TaskMain_KillTG asserts that when main tasks die the
// entire task group is killed.
// entire task group is killed.
func
TestAllocRunner_TaskMain_KillTG
(
t
*
testing
.
T
)
{
func
TestAllocRunner_TaskMain_KillTG
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
...
@@ -478,7 +475,6 @@ func TestAllocRunner_Lifecycle_Poststop(t *testing.T) {
...
@@ -478,7 +475,6 @@ func TestAllocRunner_Lifecycle_Poststop(t *testing.T) {
}
}
func
TestAllocRunner_TaskGroup_ShutdownDelay
(
t
*
testing
.
T
)
{
func
TestAllocRunner_TaskGroup_ShutdownDelay
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
...
@@ -608,7 +604,6 @@ func TestAllocRunner_TaskGroup_ShutdownDelay(t *testing.T) {
...
@@ -608,7 +604,6 @@ func TestAllocRunner_TaskGroup_ShutdownDelay(t *testing.T) {
// TestAllocRunner_TaskLeader_StopTG asserts that when stopping an alloc with a
// TestAllocRunner_TaskLeader_StopTG asserts that when stopping an alloc with a
// leader the leader is stopped before other tasks.
// leader the leader is stopped before other tasks.
func
TestAllocRunner_TaskLeader_StopTG
(
t
*
testing
.
T
)
{
func
TestAllocRunner_TaskLeader_StopTG
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
...
@@ -707,7 +702,6 @@ func TestAllocRunner_TaskLeader_StopTG(t *testing.T) {
...
@@ -707,7 +702,6 @@ func TestAllocRunner_TaskLeader_StopTG(t *testing.T) {
// not stopped as it does not exist.
// not stopped as it does not exist.
// See https://github.com/hashicorp/nomad/issues/3420#issuecomment-341666932
// See https://github.com/hashicorp/nomad/issues/3420#issuecomment-341666932
func
TestAllocRunner_TaskLeader_StopRestoredTG
(
t
*
testing
.
T
)
{
func
TestAllocRunner_TaskLeader_StopRestoredTG
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
...
@@ -785,7 +779,6 @@ func TestAllocRunner_TaskLeader_StopRestoredTG(t *testing.T) {
...
@@ -785,7 +779,6 @@ func TestAllocRunner_TaskLeader_StopRestoredTG(t *testing.T) {
}
}
func
TestAllocRunner_Restore_LifecycleHooks
(
t
*
testing
.
T
)
{
func
TestAllocRunner_Restore_LifecycleHooks
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
LifecycleAlloc
()
alloc
:=
mock
.
LifecycleAlloc
()
...
@@ -823,7 +816,7 @@ func TestAllocRunner_Restore_LifecycleHooks(t *testing.T) {
...
@@ -823,7 +816,7 @@ func TestAllocRunner_Restore_LifecycleHooks(t *testing.T) {
}
}
func
TestAllocRunner_Update_Semantics
(
t
*
testing
.
T
)
{
func
TestAllocRunner_Update_Semantics
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
updatedAlloc
:=
func
(
a
*
structs
.
Allocation
)
*
structs
.
Allocation
{
updatedAlloc
:=
func
(
a
*
structs
.
Allocation
)
*
structs
.
Allocation
{
...
@@ -876,7 +869,6 @@ func TestAllocRunner_Update_Semantics(t *testing.T) {
...
@@ -876,7 +869,6 @@ func TestAllocRunner_Update_Semantics(t *testing.T) {
// TestAllocRunner_DeploymentHealth_Healthy_Migration asserts that health is
// TestAllocRunner_DeploymentHealth_Healthy_Migration asserts that health is
// reported for services that got migrated; not just part of deployments.
// reported for services that got migrated; not just part of deployments.
func
TestAllocRunner_DeploymentHealth_Healthy_Migration
(
t
*
testing
.
T
)
{
func
TestAllocRunner_DeploymentHealth_Healthy_Migration
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
...
@@ -924,7 +916,6 @@ func TestAllocRunner_DeploymentHealth_Healthy_Migration(t *testing.T) {
...
@@ -924,7 +916,6 @@ func TestAllocRunner_DeploymentHealth_Healthy_Migration(t *testing.T) {
// TestAllocRunner_DeploymentHealth_Healthy_NoChecks asserts that the health
// TestAllocRunner_DeploymentHealth_Healthy_NoChecks asserts that the health
// watcher will mark the allocation as healthy based on task states alone.
// watcher will mark the allocation as healthy based on task states alone.
func
TestAllocRunner_DeploymentHealth_Healthy_NoChecks
(
t
*
testing
.
T
)
{
func
TestAllocRunner_DeploymentHealth_Healthy_NoChecks
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
...
@@ -987,7 +978,6 @@ func TestAllocRunner_DeploymentHealth_Healthy_NoChecks(t *testing.T) {
...
@@ -987,7 +978,6 @@ func TestAllocRunner_DeploymentHealth_Healthy_NoChecks(t *testing.T) {
// TestAllocRunner_DeploymentHealth_Unhealthy_Checks asserts that the health
// TestAllocRunner_DeploymentHealth_Unhealthy_Checks asserts that the health
// watcher will mark the allocation as unhealthy with failing checks.
// watcher will mark the allocation as unhealthy with failing checks.
func
TestAllocRunner_DeploymentHealth_Unhealthy_Checks
(
t
*
testing
.
T
)
{
func
TestAllocRunner_DeploymentHealth_Unhealthy_Checks
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
task
:=
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
task
:=
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
...
@@ -1082,7 +1072,6 @@ func TestAllocRunner_DeploymentHealth_Unhealthy_Checks(t *testing.T) {
...
@@ -1082,7 +1072,6 @@ func TestAllocRunner_DeploymentHealth_Unhealthy_Checks(t *testing.T) {
// TestAllocRunner_Destroy asserts that Destroy kills and cleans up a running
// TestAllocRunner_Destroy asserts that Destroy kills and cleans up a running
// alloc.
// alloc.
func
TestAllocRunner_Destroy
(
t
*
testing
.
T
)
{
func
TestAllocRunner_Destroy
(
t
*
testing
.
T
)
{
// Ensure task takes some time
// Ensure task takes some time
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
...
@@ -1144,7 +1133,6 @@ func TestAllocRunner_Destroy(t *testing.T) {
...
@@ -1144,7 +1133,6 @@ func TestAllocRunner_Destroy(t *testing.T) {
}
}
func
TestAllocRunner_SimpleRun
(
t
*
testing
.
T
)
{
func
TestAllocRunner_SimpleRun
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
...
@@ -1179,7 +1167,6 @@ func TestAllocRunner_SimpleRun(t *testing.T) {
...
@@ -1179,7 +1167,6 @@ func TestAllocRunner_SimpleRun(t *testing.T) {
// TestAllocRunner_MoveAllocDir asserts that a rescheduled
// TestAllocRunner_MoveAllocDir asserts that a rescheduled
// allocation copies ephemeral disk content from previous alloc run
// allocation copies ephemeral disk content from previous alloc run
func
TestAllocRunner_MoveAllocDir
(
t
*
testing
.
T
)
{
func
TestAllocRunner_MoveAllocDir
(
t
*
testing
.
T
)
{
// Step 1: start and run a task
// Step 1: start and run a task
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
...
@@ -1236,7 +1223,6 @@ func TestAllocRunner_MoveAllocDir(t *testing.T) {
...
@@ -1236,7 +1223,6 @@ func TestAllocRunner_MoveAllocDir(t *testing.T) {
// retrying fetching an artifact, other tasks in the group should be able
// retrying fetching an artifact, other tasks in the group should be able
// to proceed.
// to proceed.
func
TestAllocRunner_HandlesArtifactFailure
(
t
*
testing
.
T
)
{
func
TestAllocRunner_HandlesArtifactFailure
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
rp
:=
&
structs
.
RestartPolicy
{
rp
:=
&
structs
.
RestartPolicy
{
...
@@ -1425,7 +1411,7 @@ func TestAllocRunner_TaskFailed_KillTG(t *testing.T) {
...
@@ -1425,7 +1411,7 @@ func TestAllocRunner_TaskFailed_KillTG(t *testing.T) {
// Test that alloc becoming terminal should destroy the alloc runner
// Test that alloc becoming terminal should destroy the alloc runner
func
TestAllocRunner_TerminalUpdate_Destroy
(
t
*
testing
.
T
)
{
func
TestAllocRunner_TerminalUpdate_Destroy
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
tr
:=
alloc
.
AllocatedResources
.
Tasks
[
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
.
Name
]
alloc
.
Job
.
TaskGroups
[
0
]
.
RestartPolicy
.
Attempts
=
0
alloc
.
Job
.
TaskGroups
[
0
]
.
RestartPolicy
.
Attempts
=
0
...
@@ -1513,7 +1499,6 @@ func TestAllocRunner_TerminalUpdate_Destroy(t *testing.T) {
...
@@ -1513,7 +1499,6 @@ func TestAllocRunner_TerminalUpdate_Destroy(t *testing.T) {
// TestAllocRunner_PersistState_Destroyed asserts that destroyed allocs don't persist anymore
// TestAllocRunner_PersistState_Destroyed asserts that destroyed allocs don't persist anymore
func
TestAllocRunner_PersistState_Destroyed
(
t
*
testing
.
T
)
{
func
TestAllocRunner_PersistState_Destroyed
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
taskName
:=
alloc
.
Job
.
LookupTaskGroup
(
alloc
.
TaskGroup
)
.
Tasks
[
0
]
.
Name
taskName
:=
alloc
.
Job
.
LookupTaskGroup
(
alloc
.
TaskGroup
)
.
Tasks
[
0
]
.
Name
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/alloc_runner_unix_test.go
+
0
-
3
View file @
b0385582
...
@@ -25,7 +25,6 @@ import (
...
@@ -25,7 +25,6 @@ import (
// DesiredStatus=Stop, persisting the update, but crashing before terminating
// DesiredStatus=Stop, persisting the update, but crashing before terminating
// the task.
// the task.
func
TestAllocRunner_Restore_RunningTerminal
(
t
*
testing
.
T
)
{
func
TestAllocRunner_Restore_RunningTerminal
(
t
*
testing
.
T
)
{
// 1. Run task
// 1. Run task
// 2. Shutdown alloc runner
// 2. Shutdown alloc runner
...
@@ -143,7 +142,6 @@ func TestAllocRunner_Restore_RunningTerminal(t *testing.T) {
...
@@ -143,7 +142,6 @@ func TestAllocRunner_Restore_RunningTerminal(t *testing.T) {
// TestAllocRunner_Restore_CompletedBatch asserts that restoring a completed
// TestAllocRunner_Restore_CompletedBatch asserts that restoring a completed
// batch alloc doesn't run it again
// batch alloc doesn't run it again
func
TestAllocRunner_Restore_CompletedBatch
(
t
*
testing
.
T
)
{
func
TestAllocRunner_Restore_CompletedBatch
(
t
*
testing
.
T
)
{
// 1. Run task and wait for it to complete
// 1. Run task and wait for it to complete
// 2. Start new alloc runner
// 2. Start new alloc runner
...
@@ -228,7 +226,6 @@ func TestAllocRunner_Restore_CompletedBatch(t *testing.T) {
...
@@ -228,7 +226,6 @@ func TestAllocRunner_Restore_CompletedBatch(t *testing.T) {
// prestart hooks failed, then the alloc and subsequent tasks transition
// prestart hooks failed, then the alloc and subsequent tasks transition
// to failed state
// to failed state
func
TestAllocRunner_PreStartFailuresLeadToFailed
(
t
*
testing
.
T
)
{
func
TestAllocRunner_PreStartFailuresLeadToFailed
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
Type
=
structs
.
JobTypeBatch
alloc
.
Job
.
Type
=
structs
.
JobTypeBatch
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/consul_grpc_sock_hook_test.go
+
0
-
3
View file @
b0385582
...
@@ -24,7 +24,6 @@ import (
...
@@ -24,7 +24,6 @@ import (
// Consul unix socket hook's Prerun method is called and stopped with the
// Consul unix socket hook's Prerun method is called and stopped with the
// Postrun method is called.
// Postrun method is called.
func
TestConsulGRPCSocketHook_PrerunPostrun_Ok
(
t
*
testing
.
T
)
{
func
TestConsulGRPCSocketHook_PrerunPostrun_Ok
(
t
*
testing
.
T
)
{
// As of Consul 1.6.0 the test server does not support the gRPC
// As of Consul 1.6.0 the test server does not support the gRPC
// endpoint so we have to fake it.
// endpoint so we have to fake it.
...
@@ -101,7 +100,6 @@ func TestConsulGRPCSocketHook_PrerunPostrun_Ok(t *testing.T) {
...
@@ -101,7 +100,6 @@ func TestConsulGRPCSocketHook_PrerunPostrun_Ok(t *testing.T) {
// TestConsulGRPCSocketHook_Prerun_Error asserts that invalid Consul addresses cause
// TestConsulGRPCSocketHook_Prerun_Error asserts that invalid Consul addresses cause
// Prerun to return an error if the alloc requires a grpc proxy.
// Prerun to return an error if the alloc requires a grpc proxy.
func
TestConsulGRPCSocketHook_Prerun_Error
(
t
*
testing
.
T
)
{
func
TestConsulGRPCSocketHook_Prerun_Error
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -153,7 +151,6 @@ func TestConsulGRPCSocketHook_Prerun_Error(t *testing.T) {
...
@@ -153,7 +151,6 @@ func TestConsulGRPCSocketHook_Prerun_Error(t *testing.T) {
// TestConsulGRPCSocketHook_proxy_Unix asserts that the destination can be a unix
// TestConsulGRPCSocketHook_proxy_Unix asserts that the destination can be a unix
// socket path.
// socket path.
func
TestConsulGRPCSocketHook_proxy_Unix
(
t
*
testing
.
T
)
{
func
TestConsulGRPCSocketHook_proxy_Unix
(
t
*
testing
.
T
)
{
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"nomadtest_proxy_Unix"
)
dir
,
err
:=
ioutil
.
TempDir
(
""
,
"nomadtest_proxy_Unix"
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/consul_http_sock_hook_test.go
+
0
-
2
View file @
b0385582
...
@@ -14,7 +14,6 @@ import (
...
@@ -14,7 +14,6 @@ import (
)
)
func
TestConsulSocketHook_PrerunPostrun_Ok
(
t
*
testing
.
T
)
{
func
TestConsulSocketHook_PrerunPostrun_Ok
(
t
*
testing
.
T
)
{
fakeConsul
,
err
:=
net
.
Listen
(
"tcp"
,
"127.0.0.1:0"
)
fakeConsul
,
err
:=
net
.
Listen
(
"tcp"
,
"127.0.0.1:0"
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
...
@@ -89,7 +88,6 @@ func TestConsulSocketHook_PrerunPostrun_Ok(t *testing.T) {
...
@@ -89,7 +88,6 @@ func TestConsulSocketHook_PrerunPostrun_Ok(t *testing.T) {
}
}
func
TestConsulHTTPSocketHook_Prerun_Error
(
t
*
testing
.
T
)
{
func
TestConsulHTTPSocketHook_Prerun_Error
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/groupservice_hook_test.go
+
0
-
5
View file @
b0385582
...
@@ -27,7 +27,6 @@ var _ interfaces.RunnerTaskRestartHook = (*groupServiceHook)(nil)
...
@@ -27,7 +27,6 @@ var _ interfaces.RunnerTaskRestartHook = (*groupServiceHook)(nil)
// TestGroupServiceHook_NoGroupServices asserts calling group service hooks
// TestGroupServiceHook_NoGroupServices asserts calling group service hooks
// without group services does not error.
// without group services does not error.
func
TestGroupServiceHook_NoGroupServices
(
t
*
testing
.
T
)
{
func
TestGroupServiceHook_NoGroupServices
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Services
=
[]
*
structs
.
Service
{{
alloc
.
Job
.
TaskGroups
[
0
]
.
Services
=
[]
*
structs
.
Service
{{
...
@@ -65,7 +64,6 @@ func TestGroupServiceHook_NoGroupServices(t *testing.T) {
...
@@ -65,7 +64,6 @@ func TestGroupServiceHook_NoGroupServices(t *testing.T) {
// TestGroupServiceHook_ShutdownDelayUpdate asserts calling group service hooks
// TestGroupServiceHook_ShutdownDelayUpdate asserts calling group service hooks
// update updates the hooks delay value.
// update updates the hooks delay value.
func
TestGroupServiceHook_ShutdownDelayUpdate
(
t
*
testing
.
T
)
{
func
TestGroupServiceHook_ShutdownDelayUpdate
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
TaskGroups
[
0
]
.
ShutdownDelay
=
helper
.
TimeToPtr
(
10
*
time
.
Second
)
alloc
.
Job
.
TaskGroups
[
0
]
.
ShutdownDelay
=
helper
.
TimeToPtr
(
10
*
time
.
Second
)
...
@@ -102,7 +100,6 @@ func TestGroupServiceHook_ShutdownDelayUpdate(t *testing.T) {
...
@@ -102,7 +100,6 @@ func TestGroupServiceHook_ShutdownDelayUpdate(t *testing.T) {
// TestGroupServiceHook_GroupServices asserts group service hooks with group
// TestGroupServiceHook_GroupServices asserts group service hooks with group
// services does not error.
// services does not error.
func
TestGroupServiceHook_GroupServices
(
t
*
testing
.
T
)
{
func
TestGroupServiceHook_GroupServices
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
ConnectAlloc
()
alloc
:=
mock
.
ConnectAlloc
()
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -136,7 +133,6 @@ func TestGroupServiceHook_GroupServices(t *testing.T) {
...
@@ -136,7 +133,6 @@ func TestGroupServiceHook_GroupServices(t *testing.T) {
// TestGroupServiceHook_Error asserts group service hooks with group
// TestGroupServiceHook_Error asserts group service hooks with group
// services but no group network is handled gracefully.
// services but no group network is handled gracefully.
func
TestGroupServiceHook_NoNetwork
(
t
*
testing
.
T
)
{
func
TestGroupServiceHook_NoNetwork
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Networks
=
[]
*
structs
.
NetworkResource
{}
alloc
.
Job
.
TaskGroups
[
0
]
.
Networks
=
[]
*
structs
.
NetworkResource
{}
...
@@ -180,7 +176,6 @@ func TestGroupServiceHook_NoNetwork(t *testing.T) {
...
@@ -180,7 +176,6 @@ func TestGroupServiceHook_NoNetwork(t *testing.T) {
}
}
func
TestGroupServiceHook_getWorkloadServices
(
t
*
testing
.
T
)
{
func
TestGroupServiceHook_getWorkloadServices
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
alloc
.
Job
.
TaskGroups
[
0
]
.
Networks
=
[]
*
structs
.
NetworkResource
{}
alloc
.
Job
.
TaskGroups
[
0
]
.
Networks
=
[]
*
structs
.
NetworkResource
{}
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/health_hook_test.go
+
6
-
8
View file @
b0385582
...
@@ -84,7 +84,7 @@ func (m *mockHealthSetter) HasHealth() bool {
...
@@ -84,7 +84,7 @@ func (m *mockHealthSetter) HasHealth() bool {
// TestHealthHook_PrerunPostrun asserts a health hook does not error if it is
// TestHealthHook_PrerunPostrun asserts a health hook does not error if it is
// run and postrunned.
// run and postrunned.
func
TestHealthHook_PrerunPostrun
(
t
*
testing
.
T
)
{
func
TestHealthHook_PrerunPostrun
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -121,7 +121,7 @@ func TestHealthHook_PrerunPostrun(t *testing.T) {
...
@@ -121,7 +121,7 @@ func TestHealthHook_PrerunPostrun(t *testing.T) {
// TestHealthHook_PrerunUpdatePostrun asserts Updates may be applied concurrently.
// TestHealthHook_PrerunUpdatePostrun asserts Updates may be applied concurrently.
func
TestHealthHook_PrerunUpdatePostrun
(
t
*
testing
.
T
)
{
func
TestHealthHook_PrerunUpdatePostrun
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
...
@@ -160,7 +160,7 @@ func TestHealthHook_PrerunUpdatePostrun(t *testing.T) {
...
@@ -160,7 +160,7 @@ func TestHealthHook_PrerunUpdatePostrun(t *testing.T) {
// TestHealthHook_UpdatePrerunPostrun asserts that a hook may have Update
// TestHealthHook_UpdatePrerunPostrun asserts that a hook may have Update
// called before Prerun.
// called before Prerun.
func
TestHealthHook_UpdatePrerunPostrun
(
t
*
testing
.
T
)
{
func
TestHealthHook_UpdatePrerunPostrun
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
...
@@ -203,7 +203,7 @@ func TestHealthHook_UpdatePrerunPostrun(t *testing.T) {
...
@@ -203,7 +203,7 @@ func TestHealthHook_UpdatePrerunPostrun(t *testing.T) {
// TestHealthHook_Postrun asserts that a hook may have only Postrun called.
// TestHealthHook_Postrun asserts that a hook may have only Postrun called.
func
TestHealthHook_Postrun
(
t
*
testing
.
T
)
{
func
TestHealthHook_Postrun
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -222,7 +222,7 @@ func TestHealthHook_Postrun(t *testing.T) {
...
@@ -222,7 +222,7 @@ func TestHealthHook_Postrun(t *testing.T) {
// TestHealthHook_SetHealth_healthy asserts SetHealth is called when health status is
// TestHealthHook_SetHealth_healthy asserts SetHealth is called when health status is
// set. Uses task state and health checks.
// set. Uses task state and health checks.
func
TestHealthHook_SetHealth_healthy
(
t
*
testing
.
T
)
{
func
TestHealthHook_SetHealth_healthy
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
...
@@ -302,7 +302,7 @@ func TestHealthHook_SetHealth_healthy(t *testing.T) {
...
@@ -302,7 +302,7 @@ func TestHealthHook_SetHealth_healthy(t *testing.T) {
// TestHealthHook_SetHealth_unhealthy asserts SetHealth notices unhealthy allocs
// TestHealthHook_SetHealth_unhealthy asserts SetHealth notices unhealthy allocs
func
TestHealthHook_SetHealth_unhealthy
(
t
*
testing
.
T
)
{
func
TestHealthHook_SetHealth_unhealthy
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
...
@@ -386,7 +386,6 @@ func TestHealthHook_SetHealth_unhealthy(t *testing.T) {
...
@@ -386,7 +386,6 @@ func TestHealthHook_SetHealth_unhealthy(t *testing.T) {
// TestHealthHook_SystemNoop asserts that system jobs return the noop tracker.
// TestHealthHook_SystemNoop asserts that system jobs return the noop tracker.
func
TestHealthHook_SystemNoop
(
t
*
testing
.
T
)
{
func
TestHealthHook_SystemNoop
(
t
*
testing
.
T
)
{
h
:=
newAllocHealthWatcherHook
(
testlog
.
HCLogger
(
t
),
mock
.
SystemAlloc
(),
nil
,
nil
,
nil
)
h
:=
newAllocHealthWatcherHook
(
testlog
.
HCLogger
(
t
),
mock
.
SystemAlloc
(),
nil
,
nil
,
nil
)
...
@@ -407,7 +406,6 @@ func TestHealthHook_SystemNoop(t *testing.T) {
...
@@ -407,7 +406,6 @@ func TestHealthHook_SystemNoop(t *testing.T) {
// TestHealthHook_BatchNoop asserts that batch jobs return the noop tracker.
// TestHealthHook_BatchNoop asserts that batch jobs return the noop tracker.
func
TestHealthHook_BatchNoop
(
t
*
testing
.
T
)
{
func
TestHealthHook_BatchNoop
(
t
*
testing
.
T
)
{
h
:=
newAllocHealthWatcherHook
(
testlog
.
HCLogger
(
t
),
mock
.
BatchAlloc
(),
nil
,
nil
,
nil
)
h
:=
newAllocHealthWatcherHook
(
testlog
.
HCLogger
(
t
),
mock
.
BatchAlloc
(),
nil
,
nil
,
nil
)
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/artifact_hook_test.go
+
0
-
2
View file @
b0385582
...
@@ -33,7 +33,6 @@ func (m *mockEmitter) EmitEvent(ev *structs.TaskEvent) {
...
@@ -33,7 +33,6 @@ func (m *mockEmitter) EmitEvent(ev *structs.TaskEvent) {
// TestTaskRunner_ArtifactHook_Recoverable asserts that failures to download
// TestTaskRunner_ArtifactHook_Recoverable asserts that failures to download
// artifacts are a recoverable error.
// artifacts are a recoverable error.
func
TestTaskRunner_ArtifactHook_Recoverable
(
t
*
testing
.
T
)
{
func
TestTaskRunner_ArtifactHook_Recoverable
(
t
*
testing
.
T
)
{
me
:=
&
mockEmitter
{}
me
:=
&
mockEmitter
{}
artifactHook
:=
newArtifactHook
(
me
,
testlog
.
HCLogger
(
t
))
artifactHook
:=
newArtifactHook
(
me
,
testlog
.
HCLogger
(
t
))
...
@@ -66,7 +65,6 @@ func TestTaskRunner_ArtifactHook_Recoverable(t *testing.T) {
...
@@ -66,7 +65,6 @@ func TestTaskRunner_ArtifactHook_Recoverable(t *testing.T) {
// already downloaded artifacts when subsequent artifacts fail and cause a
// already downloaded artifacts when subsequent artifacts fail and cause a
// restart.
// restart.
func
TestTaskRunner_ArtifactHook_PartialDone
(
t
*
testing
.
T
)
{
func
TestTaskRunner_ArtifactHook_PartialDone
(
t
*
testing
.
T
)
{
me
:=
&
mockEmitter
{}
me
:=
&
mockEmitter
{}
artifactHook
:=
newArtifactHook
(
me
,
testlog
.
HCLogger
(
t
))
artifactHook
:=
newArtifactHook
(
me
,
testlog
.
HCLogger
(
t
))
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/connect_native_hook_test.go
+
6
-
13
View file @
b0385582
...
@@ -35,7 +35,7 @@ func getTestConsul(t *testing.T) *consultest.TestServer {
...
@@ -35,7 +35,7 @@ func getTestConsul(t *testing.T) *consultest.TestServer {
}
}
func
TestConnectNativeHook_Name
(
t
*
testing
.
T
)
{
func
TestConnectNativeHook_Name
(
t
*
testing
.
T
)
{
name
:=
new
(
connectNativeHook
)
.
Name
()
name
:=
new
(
connectNativeHook
)
.
Name
()
require
.
Equal
(
t
,
"connect_native"
,
name
)
require
.
Equal
(
t
,
"connect_native"
,
name
)
}
}
...
@@ -61,7 +61,6 @@ func cleanupCertDirs(t *testing.T, original, secrets string) {
...
@@ -61,7 +61,6 @@ func cleanupCertDirs(t *testing.T, original, secrets string) {
}
}
func
TestConnectNativeHook_copyCertificate
(
t
*
testing
.
T
)
{
func
TestConnectNativeHook_copyCertificate
(
t
*
testing
.
T
)
{
f
,
d
:=
setupCertDirs
(
t
)
f
,
d
:=
setupCertDirs
(
t
)
defer
cleanupCertDirs
(
t
,
f
,
d
)
defer
cleanupCertDirs
(
t
,
f
,
d
)
...
@@ -81,7 +80,6 @@ func TestConnectNativeHook_copyCertificate(t *testing.T) {
...
@@ -81,7 +80,6 @@ func TestConnectNativeHook_copyCertificate(t *testing.T) {
}
}
func
TestConnectNativeHook_copyCertificates
(
t
*
testing
.
T
)
{
func
TestConnectNativeHook_copyCertificates
(
t
*
testing
.
T
)
{
f
,
d
:=
setupCertDirs
(
t
)
f
,
d
:=
setupCertDirs
(
t
)
defer
cleanupCertDirs
(
t
,
f
,
d
)
defer
cleanupCertDirs
(
t
,
f
,
d
)
...
@@ -109,7 +107,6 @@ func TestConnectNativeHook_copyCertificates(t *testing.T) {
...
@@ -109,7 +107,6 @@ func TestConnectNativeHook_copyCertificates(t *testing.T) {
}
}
func
TestConnectNativeHook_tlsEnv
(
t
*
testing
.
T
)
{
func
TestConnectNativeHook_tlsEnv
(
t
*
testing
.
T
)
{
// the hook config comes from client config
// the hook config comes from client config
emptyHook
:=
new
(
connectNativeHook
)
emptyHook
:=
new
(
connectNativeHook
)
...
@@ -163,7 +160,6 @@ func TestConnectNativeHook_tlsEnv(t *testing.T) {
...
@@ -163,7 +160,6 @@ func TestConnectNativeHook_tlsEnv(t *testing.T) {
}
}
func
TestConnectNativeHook_bridgeEnv_bridge
(
t
*
testing
.
T
)
{
func
TestConnectNativeHook_bridgeEnv_bridge
(
t
*
testing
.
T
)
{
t
.
Run
(
"without tls"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"without tls"
,
func
(
t
*
testing
.
T
)
{
hook
:=
new
(
connectNativeHook
)
hook
:=
new
(
connectNativeHook
)
...
@@ -208,7 +204,6 @@ func TestConnectNativeHook_bridgeEnv_bridge(t *testing.T) {
...
@@ -208,7 +204,6 @@ func TestConnectNativeHook_bridgeEnv_bridge(t *testing.T) {
}
}
func
TestConnectNativeHook_bridgeEnv_host
(
t
*
testing
.
T
)
{
func
TestConnectNativeHook_bridgeEnv_host
(
t
*
testing
.
T
)
{
hook
:=
new
(
connectNativeHook
)
hook
:=
new
(
connectNativeHook
)
hook
.
alloc
=
mock
.
ConnectNativeAlloc
(
"host"
)
hook
.
alloc
=
mock
.
ConnectNativeAlloc
(
"host"
)
...
@@ -227,7 +222,6 @@ func TestConnectNativeHook_bridgeEnv_host(t *testing.T) {
...
@@ -227,7 +222,6 @@ func TestConnectNativeHook_bridgeEnv_host(t *testing.T) {
}
}
func
TestConnectNativeHook_hostEnv_host
(
t
*
testing
.
T
)
{
func
TestConnectNativeHook_hostEnv_host
(
t
*
testing
.
T
)
{
hook
:=
new
(
connectNativeHook
)
hook
:=
new
(
connectNativeHook
)
hook
.
alloc
=
mock
.
ConnectNativeAlloc
(
"host"
)
hook
.
alloc
=
mock
.
ConnectNativeAlloc
(
"host"
)
...
@@ -249,7 +243,6 @@ func TestConnectNativeHook_hostEnv_host(t *testing.T) {
...
@@ -249,7 +243,6 @@ func TestConnectNativeHook_hostEnv_host(t *testing.T) {
}
}
func
TestConnectNativeHook_hostEnv_bridge
(
t
*
testing
.
T
)
{
func
TestConnectNativeHook_hostEnv_bridge
(
t
*
testing
.
T
)
{
hook
:=
new
(
connectNativeHook
)
hook
:=
new
(
connectNativeHook
)
hook
.
alloc
=
mock
.
ConnectNativeAlloc
(
"bridge"
)
hook
.
alloc
=
mock
.
ConnectNativeAlloc
(
"bridge"
)
...
@@ -269,7 +262,7 @@ func TestConnectNativeHook_hostEnv_bridge(t *testing.T) {
...
@@ -269,7 +262,7 @@ func TestConnectNativeHook_hostEnv_bridge(t *testing.T) {
}
}
func
TestTaskRunner_ConnectNativeHook_Noop
(
t
*
testing
.
T
)
{
func
TestTaskRunner_ConnectNativeHook_Noop
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
...
@@ -307,7 +300,7 @@ func TestTaskRunner_ConnectNativeHook_Noop(t *testing.T) {
...
@@ -307,7 +300,7 @@ func TestTaskRunner_ConnectNativeHook_Noop(t *testing.T) {
}
}
func
TestTaskRunner_ConnectNativeHook_Ok
(
t
*
testing
.
T
)
{
func
TestTaskRunner_ConnectNativeHook_Ok
(
t
*
testing
.
T
)
{
testutil
.
RequireConsul
(
t
)
testutil
.
RequireConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
...
@@ -372,7 +365,7 @@ func TestTaskRunner_ConnectNativeHook_Ok(t *testing.T) {
...
@@ -372,7 +365,7 @@ func TestTaskRunner_ConnectNativeHook_Ok(t *testing.T) {
}
}
func
TestTaskRunner_ConnectNativeHook_with_SI_token
(
t
*
testing
.
T
)
{
func
TestTaskRunner_ConnectNativeHook_with_SI_token
(
t
*
testing
.
T
)
{
testutil
.
RequireConsul
(
t
)
testutil
.
RequireConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
...
@@ -445,7 +438,7 @@ func TestTaskRunner_ConnectNativeHook_with_SI_token(t *testing.T) {
...
@@ -445,7 +438,7 @@ func TestTaskRunner_ConnectNativeHook_with_SI_token(t *testing.T) {
}
}
func
TestTaskRunner_ConnectNativeHook_shareTLS
(
t
*
testing
.
T
)
{
func
TestTaskRunner_ConnectNativeHook_shareTLS
(
t
*
testing
.
T
)
{
testutil
.
RequireConsul
(
t
)
testutil
.
RequireConsul
(
t
)
try
:=
func
(
t
*
testing
.
T
,
shareSSL
*
bool
)
{
try
:=
func
(
t
*
testing
.
T
,
shareSSL
*
bool
)
{
...
@@ -566,7 +559,7 @@ func checkFilesInDir(t *testing.T, dir string, includes, excludes []string) {
...
@@ -566,7 +559,7 @@ func checkFilesInDir(t *testing.T, dir string, includes, excludes []string) {
}
}
func
TestTaskRunner_ConnectNativeHook_shareTLS_override
(
t
*
testing
.
T
)
{
func
TestTaskRunner_ConnectNativeHook_shareTLS_override
(
t
*
testing
.
T
)
{
testutil
.
RequireConsul
(
t
)
testutil
.
RequireConsul
(
t
)
fakeCert
,
fakeCertDir
:=
setupCertDirs
(
t
)
fakeCert
,
fakeCertDir
:=
setupCertDirs
(
t
)
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/device_hook_test.go
+
2
-
2
View file @
b0385582
...
@@ -15,7 +15,7 @@ import (
...
@@ -15,7 +15,7 @@ import (
)
)
func
TestDeviceHook_CorrectDevice
(
t
*
testing
.
T
)
{
func
TestDeviceHook_CorrectDevice
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
dm
:=
devicemanager
.
NoopMockManager
()
dm
:=
devicemanager
.
NoopMockManager
()
...
@@ -97,7 +97,7 @@ func TestDeviceHook_CorrectDevice(t *testing.T) {
...
@@ -97,7 +97,7 @@ func TestDeviceHook_CorrectDevice(t *testing.T) {
}
}
func
TestDeviceHook_IncorrectDevice
(
t
*
testing
.
T
)
{
func
TestDeviceHook_IncorrectDevice
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
dm
:=
devicemanager
.
NoopMockManager
()
dm
:=
devicemanager
.
NoopMockManager
()
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/dispatch_hook_test.go
+
0
-
3
View file @
b0385582
...
@@ -21,7 +21,6 @@ var _ interfaces.TaskPrestartHook = (*dispatchHook)(nil)
...
@@ -21,7 +21,6 @@ var _ interfaces.TaskPrestartHook = (*dispatchHook)(nil)
// TestTaskRunner_DispatchHook_NoPayload asserts that the hook is a noop and is
// TestTaskRunner_DispatchHook_NoPayload asserts that the hook is a noop and is
// marked as done if there is no dispatch payload.
// marked as done if there is no dispatch payload.
func
TestTaskRunner_DispatchHook_NoPayload
(
t
*
testing
.
T
)
{
func
TestTaskRunner_DispatchHook_NoPayload
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
@@ -57,7 +56,6 @@ func TestTaskRunner_DispatchHook_NoPayload(t *testing.T) {
...
@@ -57,7 +56,6 @@ func TestTaskRunner_DispatchHook_NoPayload(t *testing.T) {
// TestTaskRunner_DispatchHook_Ok asserts that dispatch payloads are written to
// TestTaskRunner_DispatchHook_Ok asserts that dispatch payloads are written to
// a file in the task dir.
// a file in the task dir.
func
TestTaskRunner_DispatchHook_Ok
(
t
*
testing
.
T
)
{
func
TestTaskRunner_DispatchHook_Ok
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
@@ -101,7 +99,6 @@ func TestTaskRunner_DispatchHook_Ok(t *testing.T) {
...
@@ -101,7 +99,6 @@ func TestTaskRunner_DispatchHook_Ok(t *testing.T) {
// TestTaskRunner_DispatchHook_Error asserts that on an error dispatch payloads
// TestTaskRunner_DispatchHook_Error asserts that on an error dispatch payloads
// are not written and Done=false.
// are not written and Done=false.
func
TestTaskRunner_DispatchHook_Error
(
t
*
testing
.
T
)
{
func
TestTaskRunner_DispatchHook_Error
(
t
*
testing
.
T
)
{
require
:=
require
.
New
(
t
)
require
:=
require
.
New
(
t
)
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/envoy_bootstrap_hook_test.go
+
6
-
10
View file @
b0385582
...
@@ -53,7 +53,6 @@ func writeTmp(t *testing.T, s string, fm os.FileMode) string {
...
@@ -53,7 +53,6 @@ func writeTmp(t *testing.T, s string, fm os.FileMode) string {
}
}
func
TestEnvoyBootstrapHook_maybeLoadSIToken
(
t
*
testing
.
T
)
{
func
TestEnvoyBootstrapHook_maybeLoadSIToken
(
t
*
testing
.
T
)
{
// This test fails when running as root because the test case for checking
// This test fails when running as root because the test case for checking
// the error condition when the file is unreadable fails (root can read the
// the error condition when the file is unreadable fails (root can read the
...
@@ -94,7 +93,6 @@ func TestEnvoyBootstrapHook_maybeLoadSIToken(t *testing.T) {
...
@@ -94,7 +93,6 @@ func TestEnvoyBootstrapHook_maybeLoadSIToken(t *testing.T) {
}
}
func
TestEnvoyBootstrapHook_decodeTriState
(
t
*
testing
.
T
)
{
func
TestEnvoyBootstrapHook_decodeTriState
(
t
*
testing
.
T
)
{
require
.
Equal
(
t
,
""
,
decodeTriState
(
nil
))
require
.
Equal
(
t
,
""
,
decodeTriState
(
nil
))
require
.
Equal
(
t
,
"true"
,
decodeTriState
(
helper
.
BoolToPtr
(
true
)))
require
.
Equal
(
t
,
"true"
,
decodeTriState
(
helper
.
BoolToPtr
(
true
)))
...
@@ -118,7 +116,6 @@ var (
...
@@ -118,7 +116,6 @@ var (
)
)
func
TestEnvoyBootstrapHook_envoyBootstrapArgs
(
t
*
testing
.
T
)
{
func
TestEnvoyBootstrapHook_envoyBootstrapArgs
(
t
*
testing
.
T
)
{
t
.
Run
(
"excluding SI token"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"excluding SI token"
,
func
(
t
*
testing
.
T
)
{
ebArgs
:=
envoyBootstrapArgs
{
ebArgs
:=
envoyBootstrapArgs
{
...
@@ -227,7 +224,6 @@ func TestEnvoyBootstrapHook_envoyBootstrapArgs(t *testing.T) {
...
@@ -227,7 +224,6 @@ func TestEnvoyBootstrapHook_envoyBootstrapArgs(t *testing.T) {
}
}
func
TestEnvoyBootstrapHook_envoyBootstrapEnv
(
t
*
testing
.
T
)
{
func
TestEnvoyBootstrapHook_envoyBootstrapEnv
(
t
*
testing
.
T
)
{
environment
:=
[]
string
{
"foo=bar"
,
"baz=1"
}
environment
:=
[]
string
{
"foo=bar"
,
"baz=1"
}
...
@@ -291,7 +287,7 @@ type envoyConfig struct {
...
@@ -291,7 +287,7 @@ type envoyConfig struct {
// TestEnvoyBootstrapHook_with_SI_token asserts the bootstrap file written for
// TestEnvoyBootstrapHook_with_SI_token asserts the bootstrap file written for
// Envoy contains a Consul SI token.
// Envoy contains a Consul SI token.
func
TestEnvoyBootstrapHook_with_SI_token
(
t
*
testing
.
T
)
{
func
TestEnvoyBootstrapHook_with_SI_token
(
t
*
testing
.
T
)
{
testutil
.
RequireConsul
(
t
)
testutil
.
RequireConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
...
@@ -392,7 +388,7 @@ func TestEnvoyBootstrapHook_with_SI_token(t *testing.T) {
...
@@ -392,7 +388,7 @@ func TestEnvoyBootstrapHook_with_SI_token(t *testing.T) {
// creates Envoy's bootstrap.json configuration based on Connect proxy sidecars
// creates Envoy's bootstrap.json configuration based on Connect proxy sidecars
// registered for the task.
// registered for the task.
func
TestTaskRunner_EnvoyBootstrapHook_sidecar_ok
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyBootstrapHook_sidecar_ok
(
t
*
testing
.
T
)
{
testutil
.
RequireConsul
(
t
)
testutil
.
RequireConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
...
@@ -487,7 +483,7 @@ func TestTaskRunner_EnvoyBootstrapHook_sidecar_ok(t *testing.T) {
...
@@ -487,7 +483,7 @@ func TestTaskRunner_EnvoyBootstrapHook_sidecar_ok(t *testing.T) {
}
}
func
TestTaskRunner_EnvoyBootstrapHook_gateway_ok
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyBootstrapHook_gateway_ok
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
testConsul
:=
getTestConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
...
@@ -570,7 +566,7 @@ func TestTaskRunner_EnvoyBootstrapHook_gateway_ok(t *testing.T) {
...
@@ -570,7 +566,7 @@ func TestTaskRunner_EnvoyBootstrapHook_gateway_ok(t *testing.T) {
// TestTaskRunner_EnvoyBootstrapHook_Noop asserts that the Envoy bootstrap hook
// TestTaskRunner_EnvoyBootstrapHook_Noop asserts that the Envoy bootstrap hook
// is a noop for non-Connect proxy sidecar / gateway tasks.
// is a noop for non-Connect proxy sidecar / gateway tasks.
func
TestTaskRunner_EnvoyBootstrapHook_Noop
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyBootstrapHook_Noop
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
alloc
:=
mock
.
Alloc
()
alloc
:=
mock
.
Alloc
()
...
@@ -607,7 +603,7 @@ func TestTaskRunner_EnvoyBootstrapHook_Noop(t *testing.T) {
...
@@ -607,7 +603,7 @@ func TestTaskRunner_EnvoyBootstrapHook_Noop(t *testing.T) {
// bootstrap hook returns a Recoverable error if the bootstrap command runs but
// bootstrap hook returns a Recoverable error if the bootstrap command runs but
// fails.
// fails.
func
TestTaskRunner_EnvoyBootstrapHook_RecoverableError
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyBootstrapHook_RecoverableError
(
t
*
testing
.
T
)
{
testutil
.
RequireConsul
(
t
)
testutil
.
RequireConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
...
@@ -685,7 +681,7 @@ func TestTaskRunner_EnvoyBootstrapHook_RecoverableError(t *testing.T) {
...
@@ -685,7 +681,7 @@ func TestTaskRunner_EnvoyBootstrapHook_RecoverableError(t *testing.T) {
}
}
func
TestTaskRunner_EnvoyBootstrapHook_retryTimeout
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyBootstrapHook_retryTimeout
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
testConsul
:=
getTestConsul
(
t
)
testConsul
:=
getTestConsul
(
t
)
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/envoy_version_hook_test.go
+
0
-
10
View file @
b0385582
...
@@ -24,7 +24,6 @@ var (
...
@@ -24,7 +24,6 @@ var (
)
)
func
TestEnvoyVersionHook_semver
(
t
*
testing
.
T
)
{
func
TestEnvoyVersionHook_semver
(
t
*
testing
.
T
)
{
t
.
Run
(
"with v"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"with v"
,
func
(
t
*
testing
.
T
)
{
result
,
err
:=
semver
(
"v1.2.3"
)
result
,
err
:=
semver
(
"v1.2.3"
)
...
@@ -45,7 +44,6 @@ func TestEnvoyVersionHook_semver(t *testing.T) {
...
@@ -45,7 +44,6 @@ func TestEnvoyVersionHook_semver(t *testing.T) {
}
}
func
TestEnvoyVersionHook_taskImage
(
t
*
testing
.
T
)
{
func
TestEnvoyVersionHook_taskImage
(
t
*
testing
.
T
)
{
t
.
Run
(
"absent"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"absent"
,
func
(
t
*
testing
.
T
)
{
result
:=
(
*
envoyVersionHook
)(
nil
)
.
taskImage
(
map
[
string
]
interface
{}{
result
:=
(
*
envoyVersionHook
)(
nil
)
.
taskImage
(
map
[
string
]
interface
{}{
...
@@ -70,7 +68,6 @@ func TestEnvoyVersionHook_taskImage(t *testing.T) {
...
@@ -70,7 +68,6 @@ func TestEnvoyVersionHook_taskImage(t *testing.T) {
}
}
func
TestEnvoyVersionHook_tweakImage
(
t
*
testing
.
T
)
{
func
TestEnvoyVersionHook_tweakImage
(
t
*
testing
.
T
)
{
image
:=
envoy
.
ImageFormat
image
:=
envoy
.
ImageFormat
...
@@ -106,7 +103,6 @@ func TestEnvoyVersionHook_tweakImage(t *testing.T) {
...
@@ -106,7 +103,6 @@ func TestEnvoyVersionHook_tweakImage(t *testing.T) {
}
}
func
TestEnvoyVersionHook_interpolateImage
(
t
*
testing
.
T
)
{
func
TestEnvoyVersionHook_interpolateImage
(
t
*
testing
.
T
)
{
hook
:=
(
*
envoyVersionHook
)(
nil
)
hook
:=
(
*
envoyVersionHook
)(
nil
)
...
@@ -156,7 +152,6 @@ func TestEnvoyVersionHook_interpolateImage(t *testing.T) {
...
@@ -156,7 +152,6 @@ func TestEnvoyVersionHook_interpolateImage(t *testing.T) {
}
}
func
TestEnvoyVersionHook_skip
(
t
*
testing
.
T
)
{
func
TestEnvoyVersionHook_skip
(
t
*
testing
.
T
)
{
h
:=
new
(
envoyVersionHook
)
h
:=
new
(
envoyVersionHook
)
...
@@ -221,7 +216,6 @@ func TestEnvoyVersionHook_skip(t *testing.T) {
...
@@ -221,7 +216,6 @@ func TestEnvoyVersionHook_skip(t *testing.T) {
}
}
func
TestTaskRunner_EnvoyVersionHook_Prestart_standard
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyVersionHook_Prestart_standard
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -264,7 +258,6 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_standard(t *testing.T) {
...
@@ -264,7 +258,6 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_standard(t *testing.T) {
}
}
func
TestTaskRunner_EnvoyVersionHook_Prestart_custom
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyVersionHook_Prestart_custom
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -308,7 +301,6 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_custom(t *testing.T) {
...
@@ -308,7 +301,6 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_custom(t *testing.T) {
}
}
func
TestTaskRunner_EnvoyVersionHook_Prestart_skip
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyVersionHook_Prestart_skip
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -355,7 +347,6 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_skip(t *testing.T) {
...
@@ -355,7 +347,6 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_skip(t *testing.T) {
}
}
func
TestTaskRunner_EnvoyVersionHook_Prestart_fallback
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyVersionHook_Prestart_fallback
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
@@ -396,7 +387,6 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_fallback(t *testing.T) {
...
@@ -396,7 +387,6 @@ func TestTaskRunner_EnvoyVersionHook_Prestart_fallback(t *testing.T) {
}
}
func
TestTaskRunner_EnvoyVersionHook_Prestart_error
(
t
*
testing
.
T
)
{
func
TestTaskRunner_EnvoyVersionHook_Prestart_error
(
t
*
testing
.
T
)
{
logger
:=
testlog
.
HCLogger
(
t
)
logger
:=
testlog
.
HCLogger
(
t
)
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/errors_test.go
+
0
-
2
View file @
b0385582
...
@@ -14,7 +14,6 @@ var _ structs.Recoverable = (*hookError)(nil)
...
@@ -14,7 +14,6 @@ var _ structs.Recoverable = (*hookError)(nil)
// TestHookError_Recoverable asserts that a NewHookError is recoverable if
// TestHookError_Recoverable asserts that a NewHookError is recoverable if
// passed a recoverable error.
// passed a recoverable error.
func
TestHookError_Recoverable
(
t
*
testing
.
T
)
{
func
TestHookError_Recoverable
(
t
*
testing
.
T
)
{
// Create root error
// Create root error
root
:=
errors
.
New
(
"test error"
)
root
:=
errors
.
New
(
"test error"
)
...
@@ -36,7 +35,6 @@ func TestHookError_Recoverable(t *testing.T) {
...
@@ -36,7 +35,6 @@ func TestHookError_Recoverable(t *testing.T) {
// TestHookError_Unrecoverable asserts that a NewHookError is not recoverable
// TestHookError_Unrecoverable asserts that a NewHookError is not recoverable
// unless it is passed a recoverable error.
// unless it is passed a recoverable error.
func
TestHookError_Unrecoverable
(
t
*
testing
.
T
)
{
func
TestHookError_Unrecoverable
(
t
*
testing
.
T
)
{
// Create error
// Create error
err
:=
errors
.
New
(
"test error"
)
err
:=
errors
.
New
(
"test error"
)
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/logmon_hook_test.go
+
0
-
2
View file @
b0385582
...
@@ -24,7 +24,6 @@ var _ interfaces.TaskStopHook = (*logmonHook)(nil)
...
@@ -24,7 +24,6 @@ var _ interfaces.TaskStopHook = (*logmonHook)(nil)
// TestTaskRunner_LogmonHook_LoadReattach unit tests loading logmon reattach
// TestTaskRunner_LogmonHook_LoadReattach unit tests loading logmon reattach
// config from persisted hook state.
// config from persisted hook state.
func
TestTaskRunner_LogmonHook_LoadReattach
(
t
*
testing
.
T
)
{
func
TestTaskRunner_LogmonHook_LoadReattach
(
t
*
testing
.
T
)
{
// No hook data should return nothing
// No hook data should return nothing
cfg
,
err
:=
reattachConfigFromHookData
(
nil
)
cfg
,
err
:=
reattachConfigFromHookData
(
nil
)
...
@@ -60,7 +59,6 @@ func TestTaskRunner_LogmonHook_LoadReattach(t *testing.T) {
...
@@ -60,7 +59,6 @@ func TestTaskRunner_LogmonHook_LoadReattach(t *testing.T) {
// first time Prestart is called, reattached to on subsequent restarts, and
// first time Prestart is called, reattached to on subsequent restarts, and
// killed on Stop.
// killed on Stop.
func
TestTaskRunner_LogmonHook_StartStop
(
t
*
testing
.
T
)
{
func
TestTaskRunner_LogmonHook_StartStop
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
task
:=
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
task
:=
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
...
...
This diff is collapsed.
Click to expand it.
client/allocrunner/taskrunner/logmon_hook_unix_test.go
+
0
-
2
View file @
b0385582
...
@@ -25,7 +25,6 @@ import (
...
@@ -25,7 +25,6 @@ import (
// Nomad client is restarting and asserts failing to reattach to logmon causes
// Nomad client is restarting and asserts failing to reattach to logmon causes
// nomad to spawn a new logmon.
// nomad to spawn a new logmon.
func
TestTaskRunner_LogmonHook_StartCrashStop
(
t
*
testing
.
T
)
{
func
TestTaskRunner_LogmonHook_StartCrashStop
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
task
:=
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
task
:=
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
...
@@ -94,7 +93,6 @@ func TestTaskRunner_LogmonHook_StartCrashStop(t *testing.T) {
...
@@ -94,7 +93,6 @@ func TestTaskRunner_LogmonHook_StartCrashStop(t *testing.T) {
// TestTaskRunner_LogmonHook_ShutdownMidStart simulates logmon crashing while the
// TestTaskRunner_LogmonHook_ShutdownMidStart simulates logmon crashing while the
// Nomad client is calling Start() and asserts that we recover and spawn a new logmon.
// Nomad client is calling Start() and asserts that we recover and spawn a new logmon.
func
TestTaskRunner_LogmonHook_ShutdownMidStart
(
t
*
testing
.
T
)
{
func
TestTaskRunner_LogmonHook_ShutdownMidStart
(
t
*
testing
.
T
)
{
alloc
:=
mock
.
BatchAlloc
()
alloc
:=
mock
.
BatchAlloc
()
task
:=
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
task
:=
alloc
.
Job
.
TaskGroups
[
0
]
.
Tasks
[
0
]
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
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