Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
dcb577b5
Commit
dcb577b5
authored
7 years ago
by
Alex Dadgar
Browse files
Options
Download
Email Patches
Plain Diff
no namespaces in oss test
parent
5a951f4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nomad/node_endpoint_test.go
+4
-22
nomad/node_endpoint_test.go
with
4 additions
and
22 deletions
+4
-22
nomad/node_endpoint_test.go
+
4
-
22
View file @
dcb577b5
...
@@ -1089,7 +1089,7 @@ func TestClientEndpoint_GetAllocs(t *testing.T) {
...
@@ -1089,7 +1089,7 @@ func TestClientEndpoint_GetAllocs(t *testing.T) {
}
}
}
}
func
TestClientEndpoint_GetAllocs_ACL
(
t
*
testing
.
T
)
{
func
TestClientEndpoint_GetAllocs_ACL
_Basic
(
t
*
testing
.
T
)
{
t
.
Parallel
()
t
.
Parallel
()
s1
,
root
:=
testACLServer
(
t
,
nil
)
s1
,
root
:=
testACLServer
(
t
,
nil
)
defer
s1
.
Shutdown
()
defer
s1
.
Shutdown
()
...
@@ -1099,27 +1099,17 @@ func TestClientEndpoint_GetAllocs_ACL(t *testing.T) {
...
@@ -1099,27 +1099,17 @@ func TestClientEndpoint_GetAllocs_ACL(t *testing.T) {
// Create the node
// Create the node
allocDefaultNS
:=
mock
.
Alloc
()
allocDefaultNS
:=
mock
.
Alloc
()
allocAltNS
:=
mock
.
Alloc
()
allocAltNS
.
Namespace
=
"altnamespace"
allocOtherNS
:=
mock
.
Alloc
()
allocOtherNS
.
Namespace
=
"should-only-be-displayed-for-root-ns"
node
:=
mock
.
Node
()
node
:=
mock
.
Node
()
allocDefaultNS
.
NodeID
=
node
.
ID
allocDefaultNS
.
NodeID
=
node
.
ID
allocAltNS
.
NodeID
=
node
.
ID
allocOtherNS
.
NodeID
=
node
.
ID
state
:=
s1
.
fsm
.
State
()
state
:=
s1
.
fsm
.
State
()
assert
.
Nil
(
state
.
UpsertNode
(
1
,
node
),
"UpsertNode"
)
assert
.
Nil
(
state
.
UpsertNode
(
1
,
node
),
"UpsertNode"
)
assert
.
Nil
(
state
.
UpsertJobSummary
(
2
,
mock
.
JobSummary
(
allocDefaultNS
.
JobID
)),
"UpsertJobSummary"
)
assert
.
Nil
(
state
.
UpsertJobSummary
(
2
,
mock
.
JobSummary
(
allocDefaultNS
.
JobID
)),
"UpsertJobSummary"
)
assert
.
Nil
(
state
.
UpsertJobSummary
(
3
,
mock
.
JobSummary
(
allocAltNS
.
JobID
)),
"UpsertJobSummary"
)
allocs
:=
[]
*
structs
.
Allocation
{
allocDefaultNS
}
assert
.
Nil
(
state
.
UpsertJobSummary
(
4
,
mock
.
JobSummary
(
allocOtherNS
.
JobID
)),
"UpsertJobSummary"
)
allocs
:=
[]
*
structs
.
Allocation
{
allocDefaultNS
,
allocAltNS
,
allocOtherNS
}
assert
.
Nil
(
state
.
UpsertAllocs
(
5
,
allocs
),
"UpsertAllocs"
)
assert
.
Nil
(
state
.
UpsertAllocs
(
5
,
allocs
),
"UpsertAllocs"
)
// Create the namespace policy and tokens
// Create the namespace policy and tokens
validDefaultToken
:=
mock
.
CreatePolicyAndToken
(
t
,
state
,
1001
,
"test-default-valid"
,
mock
.
NodePolicy
(
acl
.
PolicyRead
)
+
validDefaultToken
:=
mock
.
CreatePolicyAndToken
(
t
,
state
,
1001
,
"test-default-valid"
,
mock
.
NodePolicy
(
acl
.
PolicyRead
)
+
mock
.
NamespacePolicy
(
structs
.
DefaultNamespace
,
""
,
[]
string
{
acl
.
NamespaceCapabilityReadJob
}))
mock
.
NamespacePolicy
(
structs
.
DefaultNamespace
,
""
,
[]
string
{
acl
.
NamespaceCapabilityReadJob
}))
validNoNSToken
:=
mock
.
CreatePolicyAndToken
(
t
,
state
,
1003
,
"test-alt-valid"
,
mock
.
NodePolicy
(
acl
.
PolicyRead
))
invalidToken
:=
mock
.
CreatePolicyAndToken
(
t
,
state
,
1004
,
"test-invalid"
,
invalidToken
:=
mock
.
CreatePolicyAndToken
(
t
,
state
,
1004
,
"test-invalid"
,
mock
.
NamespacePolicy
(
structs
.
DefaultNamespace
,
""
,
[]
string
{
acl
.
NamespaceCapabilityReadJob
}))
mock
.
NamespacePolicy
(
structs
.
DefaultNamespace
,
""
,
[]
string
{
acl
.
NamespaceCapabilityReadJob
}))
...
@@ -1147,14 +1137,6 @@ func TestClientEndpoint_GetAllocs_ACL(t *testing.T) {
...
@@ -1147,14 +1137,6 @@ func TestClientEndpoint_GetAllocs_ACL(t *testing.T) {
assert
.
Equal
(
allocDefaultNS
.
ID
,
resp
.
Allocs
[
0
]
.
ID
)
assert
.
Equal
(
allocDefaultNS
.
ID
,
resp
.
Allocs
[
0
]
.
ID
)
}
}
// Try with a valid token for a namespace with no allocs on this node
req
.
AuthToken
=
validNoNSToken
.
SecretID
{
var
resp
structs
.
NodeAllocsResponse
assert
.
Nil
(
msgpackrpc
.
CallWithCodec
(
codec
,
"Node.GetAllocs"
,
req
,
&
resp
),
"RPC"
)
assert
.
Len
(
resp
.
Allocs
,
0
)
}
// Try with a invalid token
// Try with a invalid token
req
.
AuthToken
=
invalidToken
.
SecretID
req
.
AuthToken
=
invalidToken
.
SecretID
{
{
...
@@ -1169,10 +1151,10 @@ func TestClientEndpoint_GetAllocs_ACL(t *testing.T) {
...
@@ -1169,10 +1151,10 @@ func TestClientEndpoint_GetAllocs_ACL(t *testing.T) {
{
{
var
resp
structs
.
NodeAllocsResponse
var
resp
structs
.
NodeAllocsResponse
assert
.
Nil
(
msgpackrpc
.
CallWithCodec
(
codec
,
"Node.GetAllocs"
,
req
,
&
resp
),
"RPC"
)
assert
.
Nil
(
msgpackrpc
.
CallWithCodec
(
codec
,
"Node.GetAllocs"
,
req
,
&
resp
),
"RPC"
)
assert
.
Len
(
resp
.
Allocs
,
3
)
assert
.
Len
(
resp
.
Allocs
,
1
)
for
_
,
alloc
:=
range
resp
.
Allocs
{
for
_
,
alloc
:=
range
resp
.
Allocs
{
switch
alloc
.
ID
{
switch
alloc
.
ID
{
case
allocDefaultNS
.
ID
,
allocAltNS
.
ID
,
allocOtherNS
.
ID
:
case
allocDefaultNS
.
ID
:
// expected
// expected
default
:
default
:
t
.
Errorf
(
"unexpected alloc %q for namespace %q"
,
alloc
.
ID
,
alloc
.
Namespace
)
t
.
Errorf
(
"unexpected alloc %q for namespace %q"
,
alloc
.
ID
,
alloc
.
Namespace
)
...
...
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