Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
g5k-api
Commits
c2e69751
Commit
c2e69751
authored
Oct 27, 2016
by
BASU Anirvan
Committed by
Lucas Nussbaum
Jun 07, 2017
Browse files
added logic & spec tests for /servers
parent
80f822af
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/controllers/servers_controller.rb
0 → 100644
View file @
c2e69751
# Copyright (c) 2015-2016 Anirvan BASU, INRIA Rennes - Bretagne Atlantique
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require
'resources_controller'
# This ServersController taken from jessie branch for bug ref. 7464 -- 2016.10.27
class
ServersController
<
ResourcesController
protected
def
collection_path
if
params
[
:site_id
]
site_servers_path
(
params
[
:site_id
])
else
site_servers_path
end
end
def
links_for_item
(
item
)
super
(
item
)
end
end
config/routes.rb
View file @
c2e69751
...
...
@@ -42,6 +42,8 @@ Api::Application.routes.draw do
end
resources
:nodes
,
:only
=>
[
:index
,
:show
]
end
# abasu bug #7464 to incorporate feature /servers -- 2016.10.27
resources
:servers
,
:only
=>
[
:index
,
:show
]
resources
:jobs
resources
:deployments
end
...
...
spec/controllers/servers_controller_spec.rb
0 → 100644
View file @
c2e69751
# Copyright (c) 2015-2016 Anirvan BASU, INRIA Rennes - Bretagne Atlantique
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
require
'spec_helper'
describe
ServersController
do
render_views
# abasu : unit test for bug ref 7464 to handle /servers - 27.10.2016
describe
"GET /sites/{{site_id}}/servers/{{id}}"
do
# The following unit tests check the responses at level of specific servers.
it
"should return ONLY cluster talc-data in nancy"
do
get
:show
,
:branch
=>
'master'
,
:site_id
=>
"nancy"
,
:id
=>
"talc-data"
,
:format
=>
:json
assert_media_type
(
:json
)
response
.
body
.
should
==
'{"alias":[],"kind":"physical","monitoring":{"metric":"power","wattmeter":"multiple"},"network_adapters":{"bmc":{"ip":"172.17.79.21"},"default":{"ip":"172.16.79.21"}},"sensors":{"network":{"available":true,"resolution":1},"power":{"available":true,"resolution":1,"via":{"pdu":[{"port":20,"uid":"grisou-pdu1"},{"port":20,"uid":"grisou-pdu2"}]}}},"serial":"92ZLL82","type":"server","uid":"talc-data","warranty":11.202,"version":"8a562420c9a659256eeaafcfd89dfa917b5fb4d0","links":[{"rel":"self","type":"application/vnd.grid5000.item+json","href":"/sites/nancy/servers/talc-data"},{"rel":"parent","type":"application/vnd.grid5000.item+json","href":"/sites/nancy"},{"rel":"version","type":"application/vnd.grid5000.item+json","href":"/sites/nancy/servers/talc-data/versions/8a562420c9a659256eeaafcfd89dfa917b5fb4d0"},{"rel":"versions","type":"application/vnd.grid5000.collection+json","href":"/sites/nancy/servers/talc-data/versions"}]}'
response
.
status
.
should
==
200
end
# it "should return ONLY cluster talc in nancy without any queues filter"
end
# "GET /sites/{{site_id}}/servers/{{id}}/"
# abasu : unit tests for bug ref 7464 to handle /servers - 27.10.2016
describe
"GET /sites/{{site_id}}/servers"
do
# The following unit tests check the responses at level of all servers in a site
# abasu : unit test for bug ref 7464 to handle /servers - 27.10.2016
it
"should return 2 servers in site nancy and their exact names"
do
get
:index
,
:branch
=>
'master'
,
:site_id
=>
"nancy"
,
:format
=>
:json
assert_media_type
(
:json
)
response
.
status
.
should
==
200
json
[
"total"
].
should
==
2
serverList
=
[]
json
[
"items"
].
each
do
|
server
|
serverList
=
[
server
[
"uid"
]]
|
serverList
end
(
serverList
-
[
"storage5k"
,
"talc-data"
]).
should
be_empty
end
# it "should return ALL servers in site nancy"
end
# "GET /sites/{{site_id}}/servers"
end
# describe ServersController
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