Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
9b745324
Commit
9b745324
authored
Jun 10, 2013
by
Stavros Sachtouris
Browse files
Adjust all livetests to use cached astakos client
Refs: #3964
parent
508570ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
kamaki/clients/livetest/astakos.py
View file @
9b745324
...
...
@@ -39,9 +39,9 @@ from kamaki.clients.astakos import AstakosClient
class
Astakos
(
livetest
.
Generic
):
def
setUp
(
self
):
self
.
remote
=
'remote.%s'
%
self
[
'testremote'
]
self
.
client
=
AstakosClient
(
self
[
'remote.default'
,
'url'
],
self
[
'remote.default'
,
'token'
])
self
[
self
.
remote
,
'url'
],
self
[
self
.
remote
,
'token'
])
with
open
(
self
[
'astakos'
,
'details'
])
as
f
:
self
.
_astakos_details
=
eval
(
f
.
read
())
...
...
@@ -56,7 +56,7 @@ class Astakos(livetest.Generic):
self
.
_test_0020_get_services
()
def
_test_0020_get_services
(
self
):
for
args
in
(
tuple
(),
(
self
[
'
remote
.default'
,
'token'
],)):
for
args
in
(
tuple
(),
(
self
[
self
.
remote
,
'token'
],)):
r
=
self
.
client
.
get_services
(
*
args
)
services
=
self
.
_astakos_details
[
'access'
][
'serviceCatalog'
]
self
.
assertEqual
(
len
(
services
),
len
(
r
))
...
...
@@ -71,7 +71,7 @@ class Astakos(livetest.Generic):
parsed_services
=
dict
()
for
args
in
product
(
self
.
_astakos_details
[
'access'
][
'serviceCatalog'
],
([
tuple
(),
(
self
[
'
remote
.default'
,
'token'
],)])):
([
tuple
(),
(
self
[
self
.
remote
,
'token'
],)])):
service
=
args
[
0
]
if
service
[
'type'
]
in
parsed_services
:
continue
...
...
@@ -88,7 +88,7 @@ class Astakos(livetest.Generic):
parsed_services
=
dict
()
for
args
in
product
(
self
.
_astakos_details
[
'access'
][
'serviceCatalog'
],
([],
[
self
[
'
remote
.default'
,
'token'
]])):
([],
[
self
[
self
.
remote
,
'token'
]])):
service
=
args
[
0
]
if
service
[
'type'
]
in
parsed_services
:
continue
...
...
@@ -118,7 +118,7 @@ class Astakos(livetest.Generic):
def
_test_0020_get
(
self
):
for
term
in
(
'id'
,
'name'
,
'roles'
):
self
.
assertEqual
(
self
.
client
.
term
(
term
,
self
[
'
remote
.default'
,
'token'
]),
self
.
client
.
term
(
term
,
self
[
self
.
remote
,
'token'
]),
self
[
'astakos'
,
term
]
or
([]
if
term
==
'roles'
else
''
))
def
test_list_users
(
self
):
...
...
kamaki/clients/livetest/cyclades.py
View file @
9b745324
...
...
@@ -35,6 +35,7 @@ import time
from
kamaki.clients
import
livetest
,
ClientError
from
kamaki.clients.cyclades
import
CycladesClient
from
kamaki.clients.astakos
import
AstakosClient
class
Cyclades
(
livetest
.
Generic
):
...
...
@@ -59,7 +60,11 @@ class Cyclades(livetest.Generic):
self
.
netname1
=
'net'
+
unicode
(
self
.
now
)
self
.
netname2
=
'net'
+
unicode
(
self
.
now
)
+
'_v2'
self
.
client
=
CycladesClient
(
self
[
'compute'
,
'url'
],
self
[
'token'
])
self
.
remote
=
'remote.%s'
%
self
[
'testremote'
]
aurl
,
self
.
token
=
self
[
self
.
remote
,
'url'
],
self
[
self
.
remote
,
'token'
]
self
.
auth_base
=
AstakosClient
(
aurl
,
self
.
token
)
curl
=
self
.
auth_base
.
get_service_endpoints
(
'compute'
)[
'publicURL'
]
self
.
client
=
CycladesClient
(
curl
,
self
.
token
)
def
tearDown
(
self
):
"""Destoy servers used in testing"""
...
...
kamaki/clients/livetest/image.py
View file @
9b745324
...
...
@@ -34,6 +34,7 @@
import
time
from
kamaki.clients
import
livetest
from
kamaki.clients.astakos
import
AstakosClient
as
AstakosCachedClient
from
kamaki.clients.cyclades
import
CycladesClient
from
kamaki.clients.image
import
ImageClient
from
kamaki.clients
import
ClientError
...
...
@@ -48,12 +49,16 @@ IMGMETA = set([
class
Image
(
livetest
.
Generic
):
def
setUp
(
self
):
self
.
now
=
time
.
mktime
(
time
.
gmtime
())
self
.
remote
=
'remote.%s'
%
self
[
'testremote'
]
aurl
,
self
.
token
=
self
[
self
.
remote
,
'url'
],
self
[
self
.
remote
,
'token'
]
self
.
auth_base
=
AstakosCachedClient
(
aurl
,
self
.
token
)
self
.
imgname
=
'img_%s'
%
self
.
now
url
=
self
[
'image'
,
'url'
]
self
.
client
=
ImageClient
(
url
,
self
[
'token'
])
cyclades_url
=
self
[
'compute'
,
'url'
]
self
.
cyclades
=
CycladesClient
(
cyclades_url
,
self
[
'token'
])
url
=
self
.
auth_base
.
get_service_endpoints
(
'image'
)[
'publicURL'
]
self
.
token
=
self
.
auth_base
.
token
self
.
client
=
ImageClient
(
url
,
self
.
token
)
cyclades_url
=
self
.
auth_base
.
get_service_endpoints
(
'compute'
)[
'publicURL'
]
self
.
cyclades
=
CycladesClient
(
cyclades_url
,
self
.
token
)
self
.
_imglist
=
{}
self
.
_imgdetails
=
{}
...
...
@@ -63,12 +68,11 @@ class Image(livetest.Generic):
def
_prepare_img
(
self
):
f
=
open
(
self
[
'image'
,
'local_path'
],
'rb'
)
(
token
,
uuid
)
=
(
self
[
'token'
],
self
[
'file'
,
'account'
])
if
not
uuid
:
from
kamaki.clients.astakos
import
AstakosClient
uuid
=
AstakosClient
(
self
[
'user'
,
'url'
],
token
).
term
(
'uuid'
)
(
token
,
uuid
)
=
(
self
.
token
,
self
.
auth_base
.
user_term
(
'id'
))
purl
=
self
.
auth_base
.
get_service_endpoints
(
'object-store'
)[
'publicURL'
]
from
kamaki.clients.pithos
import
PithosClient
self
.
pithcli
=
PithosClient
(
self
[
'file'
,
'
url
'
]
,
token
,
uuid
)
self
.
pithcli
=
PithosClient
(
p
url
,
token
,
uuid
)
cont
=
'cont_%s'
%
self
.
now
self
.
pithcli
.
container
=
cont
self
.
obj
=
'obj_%s'
%
self
.
now
...
...
@@ -107,14 +111,6 @@ class Image(livetest.Generic):
return
img
return
None
def
assert_dicts_are_deeply_equal
(
self
,
d1
,
d2
):
for
k
,
v
in
d1
.
items
():
self
.
assertTrue
(
k
in
d2
)
if
isinstance
(
v
,
dict
):
self
.
assert_dicts_are_deeply_equal
(
v
,
d2
[
k
])
else
:
self
.
assertEqual
(
unicode
(
v
),
unicode
(
d2
[
k
]))
def
test_list_public
(
self
):
"""Test list_public"""
self
.
_test_list_public
()
...
...
@@ -135,7 +131,7 @@ class Image(livetest.Generic):
self
.
assertTrue
(
r
,
r0
)
r0
.
reverse
()
for
i
,
img
in
enumerate
(
r
):
self
.
assert_dicts_are_
deeply_
equal
(
img
,
r0
[
i
])
self
.
assert_dicts_are_equal
(
img
,
r0
[
i
])
r1
=
self
.
client
.
list_public
(
detail
=
True
)
for
img
in
r1
:
for
term
in
(
...
...
kamaki/clients/livetest/pithos.py
View file @
9b745324
...
...
@@ -69,13 +69,13 @@ class Pithos(livetest.Generic):
files
=
[]
def
setUp
(
self
):
self
.
client
=
PithosClient
(
self
[
'file'
,
'url'
],
self
[
'file'
,
'
token
'
],
AstakosClient
(
self
[
'user'
,
'url
'
]
,
self
[
'file'
,
'token'
]
).
term
(
'
uuid
'
)
)
self
.
remote
=
'remote.%s'
%
self
[
'testremote'
]
aurl
,
self
.
token
=
self
[
self
.
remote
,
'url'
],
self
[
self
.
remote
,
'token'
]
self
.
auth_base
=
AstakosClient
(
aurl
,
self
.
token
)
purl
=
self
.
auth_base
.
get_service_endpoints
(
'object-store'
)[
'publicURL
'
]
self
.
uuid
=
self
.
auth_base
.
user_term
(
'id'
)
self
.
client
=
PithosClient
(
purl
,
self
.
token
,
self
.
uuid
)
self
.
now
=
time
.
mktime
(
time
.
gmtime
())
self
.
now_unformated
=
datetime
.
datetime
.
utcnow
()
...
...
Write
Preview
Markdown
is supported
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