Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
amrani
jio
Commits
ceec70a0
Commit
ceec70a0
authored
Apr 11, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replicatestorage remove tests added
parent
0afc6fc7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
203 additions
and
0 deletions
+203
-0
test/jio.storage/replicatestorage.tests.js
test/jio.storage/replicatestorage.tests.js
+203
-0
No files found.
test/jio.storage/replicatestorage.tests.js
View file @
ceec70a0
...
@@ -628,6 +628,209 @@
...
@@ -628,6 +628,209 @@
then
(
start
,
start
);
then
(
start
,
start
);
});
});
test
(
"
Remove
"
,
function
()
{
var
shared
=
{},
i
,
jio_list
,
replicate_jio
;
// this test can work with at least 2 sub storages
shared
.
gid_description
=
{
"
type
"
:
"
gid
"
,
"
constraints
"
:
{
"
default
"
:
{
"
identifier
"
:
"
list
"
}
},
"
sub_storage
"
:
null
};
shared
.
storage_description_list
=
[];
for
(
i
=
0
;
i
<
4
;
i
+=
1
)
{
shared
.
storage_description_list
[
i
]
=
jsonClone
(
shared
.
gid_description
);
shared
.
storage_description_list
[
i
].
sub_storage
=
{
"
type
"
:
"
local
"
,
"
username
"
:
"
replicate scenario test for remove method -
"
+
(
i
+
1
),
"
mode
"
:
"
memory
"
};
}
shared
.
replicate_storage_description
=
{
"
type
"
:
"
replicate
"
,
"
storage_list
"
:
shared
.
storage_description_list
};
shared
.
workspace
=
{};
shared
.
jio_option
=
{
"
workspace
"
:
shared
.
workspace
,
"
max_retry
"
:
0
};
jio_list
=
shared
.
storage_description_list
.
map
(
function
(
description
)
{
return
jIO
.
createJIO
(
description
,
shared
.
jio_option
);
});
replicate_jio
=
jIO
.
createJIO
(
shared
.
replicate_storage_description
,
shared
.
jio_option
);
stop
();
function
setFakeStorage
()
{
setFakeStorage
.
original
=
shared
.
storage_description_list
[
0
].
sub_storage
;
shared
.
storage_description_list
[
0
].
sub_storage
=
{
"
type
"
:
"
fake
"
,
"
id
"
:
"
replicate scenario test for remove method - 1
"
};
jio_list
[
0
]
=
jIO
.
createJIO
(
shared
.
storage_description_list
[
0
],
shared
.
jio_option
);
replicate_jio
=
jIO
.
createJIO
(
shared
.
replicate_storage_description
,
shared
.
jio_option
);
}
function
unsetFakeStorage
()
{
shared
.
storage_description_list
[
0
].
sub_storage
=
setFakeStorage
.
original
;
jio_list
[
0
]
=
jIO
.
createJIO
(
shared
.
storage_description_list
[
0
],
shared
.
jio_option
);
replicate_jio
=
jIO
.
createJIO
(
shared
.
replicate_storage_description
,
shared
.
jio_option
);
}
function
putSomeDocuments
()
{
return
all
(
jio_list
.
map
(
function
(
jio
)
{
return
jio
.
post
({
"
identifier
"
:
"
a
"
});
}));
}
function
removeDocument
()
{
return
replicate_jio
.
remove
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
});
}
function
removeDocumentTest
(
answer
)
{
deepEqual
(
answer
,
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
,
"
method
"
:
"
remove
"
,
"
result
"
:
"
success
"
,
"
status
"
:
204
,
"
statusText
"
:
"
No Content
"
},
"
Remove document
"
);
}
function
checkStorageContent
()
{
// check storage state
return
all
(
jio_list
.
map
(
function
(
jio
)
{
return
reverse
(
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
}));
})).
then
(
function
(
answers
)
{
answers
.
forEach
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
error
"
:
"
not_found
"
,
"
id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
,
"
message
"
:
"
Cannot get document
"
,
"
method
"
:
"
get
"
,
"
reason
"
:
"
missing
"
,
"
result
"
:
"
error
"
,
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
},
"
Check storage content
"
);
});
});
}
function
putSomeDocuments2
()
{
return
all
(
jio_list
.
map
(
function
(
jio
)
{
return
jio
.
post
({
"
identifier
"
:
"
b
"
});
}));
}
function
removeDocumentWithUnavailableStorage
()
{
setFakeStorage
();
setTimeout
(
function
()
{
fake_storage
.
commands
[
"
replicate scenario test for remove method - 1/allDocs
"
].
error
({
"
status
"
:
0
});
},
100
);
return
replicate_jio
.
remove
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
});
}
function
removeDocumentWithUnavailableStorageTest
(
answer
)
{
deepEqual
(
answer
,
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
,
"
method
"
:
"
remove
"
,
"
result
"
:
"
success
"
,
"
status
"
:
204
,
"
statusText
"
:
"
No Content
"
},
"
Remove document with unavailable storage
"
);
return
sleep
(
100
);
}
function
checkStorageContent2
()
{
unsetFakeStorage
();
// check storage state
return
all
(
jio_list
.
map
(
function
(
jio
,
i
)
{
if
(
i
===
0
)
{
return
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
});
}
return
reverse
(
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
}));
})).
then
(
function
(
answers
)
{
deepEqual
(
answers
[
0
],
{
"
data
"
:
{
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
,
"
identifier
"
:
"
b
"
},
"
id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Check storage content
"
);
answers
.
slice
(
1
).
forEach
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
error
"
:
"
not_found
"
,
"
id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
,
"
message
"
:
"
Cannot get document
"
,
"
method
"
:
"
get
"
,
"
reason
"
:
"
missing
"
,
"
result
"
:
"
error
"
,
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
},
"
Check storage content
"
);
});
});
}
function
unexpectedError
(
error
)
{
if
(
error
instanceof
Error
)
{
deepEqual
([
error
.
name
+
"
:
"
+
error
.
message
,
error
],
"
NO ERROR
"
,
"
Unexpected error
"
);
}
else
{
deepEqual
(
error
,
"
NO ERROR
"
,
"
Unexpected error
"
);
}
}
chain
().
// remove document
then
(
putSomeDocuments
).
then
(
removeDocument
).
then
(
removeDocumentTest
).
then
(
checkStorageContent
).
// remove document with unavailable storage
then
(
putSomeDocuments2
).
then
(
removeDocumentWithUnavailableStorage
).
then
(
removeDocumentWithUnavailableStorageTest
).
then
(
checkStorageContent2
).
// End of scenario
then
(
null
,
unexpectedError
).
then
(
start
,
start
);
});
test
(
"
AllDocs
"
,
function
()
{
test
(
"
AllDocs
"
,
function
()
{
var
shared
=
{},
i
,
jio_list
,
replicate_jio
;
var
shared
=
{},
i
,
jio_list
,
replicate_jio
;
...
...
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