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
agkyra
Commits
6b953da8
Commit
6b953da8
authored
Apr 24, 2015
by
Giorgos Korfiatis
Browse files
Started test
parent
3d594fbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
agkyra/agkyra/config.py
View file @
6b953da8
...
...
@@ -24,7 +24,8 @@ from kamaki.cli.utils import escape_ctrl_chars
CLOUD_PREFIX
=
config
.
CLOUD_PREFIX
config
.
HEADER
=
'# Agkyra configuration file version XXX
\n
'
AGKYRA_DIR
=
os
.
environ
.
get
(
'AGKYRA_DIR'
,
os
.
path
.
expanduser
(
'~/.agkyra'
))
config
.
CONFIG_PATH
=
'%s%sconfig.rc'
%
(
AGKYRA_DIR
,
os
.
path
.
sep
)
CONFIG_PATH
=
'%s%sconfig.rc'
%
(
AGKYRA_DIR
,
os
.
path
.
sep
)
config
.
CONFIG_PATH
=
CONFIG_PATH
# neutralize kamaki CONFIG_ENV for this session
config
.
CONFIG_ENV
=
''
...
...
agkyra/test.py
0 → 100644
View file @
6b953da8
from
agkyra.syncer.setup
import
SyncerSettings
from
agkyra.syncer.localfs_client
import
LocalfsFileClient
from
agkyra.syncer.pithos_client
import
PithosFileClient
from
agkyra.syncer.syncer
import
FileSyncer
from
agkyra.syncer
import
messaging
,
utils
import
random
from
agkyra.config
import
AgkyraConfig
,
CONFIG_PATH
cnf
=
AgkyraConfig
()
cloud_conf
=
cnf
.
get
(
'cloud'
,
'test'
)
if
cloud_conf
is
None
:
print
"Define a 'test' cloud in %s"
%
CONFIG_PATH
exit
()
AUTHENTICATION_URL
=
cloud_conf
[
'url'
]
TOKEN
=
cloud_conf
[
'token'
]
ID
=
"AGKYRATEST"
+
str
(
random
.
random
()).
split
(
'.'
)[
1
]
LOCAL_ROOT_PATH
=
"/tmp/"
+
ID
settings
=
SyncerSettings
(
instance
=
ID
,
auth_url
=
AUTHENTICATION_URL
,
auth_token
=
TOKEN
,
container
=
ID
,
local_root_path
=
LOCAL_ROOT_PATH
,
ignore_ssl
=
True
)
master
=
PithosFileClient
(
settings
)
slave
=
LocalfsFileClient
(
settings
)
s
=
FileSyncer
(
settings
,
master
,
slave
)
pithos
=
master
.
endpoint
pithos
.
create_container
(
ID
)
f1
=
"f1"
content1
=
"content1"
r1
=
pithos
.
upload_from_string
(
f1
,
content1
)
etag1
=
r1
[
'etag'
]
pithos_cands
=
master
.
get_pithos_candidates
()
info
=
pithos_cands
[
f1
]
assert
etag1
==
info
[
"pithos_etag"
]
db
=
s
.
get_db
()
state
=
db
.
get_state
(
master
.
SIGNATURE
,
f1
)
assert
state
.
serial
==
-
1
assert
state
.
info
==
{}
s
.
probe_file
(
master
.
SIGNATURE
,
f1
)
m
=
s
.
get_next_message
(
block
=
True
)
assert
isinstance
(
m
,
messaging
.
UpdateMessage
)
state
=
db
.
get_state
(
master
.
SIGNATURE
,
f1
)
assert
state
.
serial
==
0
assert
state
.
info
==
info
deciding
=
s
.
list_deciding
()
assert
deciding
==
set
([
f1
])
state
=
db
.
get_state
(
slave
.
SIGNATURE
,
f1
)
assert
state
.
serial
==
-
1
assert
state
.
info
==
{}
s
.
decide_file_sync
(
f1
)
m
=
s
.
get_next_message
(
block
=
True
)
assert
isinstance
(
m
,
messaging
.
SyncMessage
)
m
=
s
.
get_next_message
(
block
=
True
)
assert
isinstance
(
m
,
messaging
.
AckSyncMessage
)
state
=
db
.
get_state
(
slave
.
SIGNATURE
,
f1
)
assert
state
.
serial
==
0
info
=
state
.
info
assert
info
[
'localfs_size'
]
==
len
(
content1
)
local_path
=
LOCAL_ROOT_PATH
+
'/'
+
f1
assert
utils
.
hash_file
(
local_path
)
==
utils
.
hash_string
(
content1
)
def
write_local
():
content2
=
"content2"
with
open
(
local_path
,
"w"
)
as
f
:
f
.
write
(
content2
)
def
write_upstream
():
content3
=
"content3"
r3
=
pithos
.
upload_from_string
(
f1
,
content3
)
etag3
=
r1
[
'etag'
]
def
func
():
write_upstream
()
write_local
()
assert
s
.
get_next_message
()
is
None
s
.
initiate_probe
()
s
.
start_decide
()
m
=
s
.
get_next_message
(
block
=
True
)
print
m
assert
isinstance
(
m
,
messaging
.
UpdateMessage
)
assert
m
.
archive
==
master
.
SIGNATURE
m
=
s
.
get_next_message
(
block
=
True
)
print
m
assert
isinstance
(
m
,
messaging
.
UpdateMessage
)
assert
m
.
archive
==
slave
.
SIGNATURE
m
=
s
.
get_next_message
(
block
=
True
)
print
m
assert
isinstance
(
m
,
messaging
.
SyncMessage
)
m
=
s
.
get_next_message
(
block
=
True
)
print
m
assert
isinstance
(
m
,
messaging
.
ConflictStashMessage
)
m
=
s
.
get_next_message
(
block
=
True
)
print
m
assert
isinstance
(
m
,
messaging
.
AckSyncMessage
)
func
()
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