Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
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
Alexandra Rogova
jio_mebibou
Commits
9382e3f7
Commit
9382e3f7
authored
Apr 11, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replicate repair tests added
parent
ceec70a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
309 additions
and
0 deletions
+309
-0
test/jio.storage/replicatestorage.tests.js
test/jio.storage/replicatestorage.tests.js
+309
-0
No files found.
test/jio.storage/replicatestorage.tests.js
View file @
9382e3f7
...
@@ -1011,4 +1011,313 @@
...
@@ -1011,4 +1011,313 @@
then
(
start
);
then
(
start
);
});
});
test
(
"
Repair
"
,
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 repair 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
();
shared
.
modified_date_list
=
[
new
Date
(
"
1995
"
),
new
Date
(
"
2000
"
),
null
,
new
Date
(
"
Invalid Date
"
)
];
shared
.
winner_modified_date
=
shared
.
modified_date_list
[
1
];
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 repair 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
putSimilarDocuments
()
{
return
all
(
jio_list
.
map
(
function
(
jio
)
{
return
jio
.
post
({
"
identifier
"
:
"
a
"
,
"
modified
"
:
shared
.
modified_date_list
[
0
]
});
}));
}
function
repairDocumentNothingToSynchronize
()
{
return
replicate_jio
.
repair
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
});
}
function
repairDocumentNothingToSynchronizeTest
(
answer
)
{
deepEqual
(
answer
,
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
,
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
204
,
"
statusText
"
:
"
No Content
"
},
"
Repair document, nothing to synchronize.
"
);
// check storage state
return
all
(
jio_list
.
map
(
function
(
jio
)
{
return
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
});
})).
then
(
function
(
answers
)
{
answers
.
forEach
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
data
"
:
{
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
,
"
identifier
"
:
"
a
"
,
"
modified
"
:
shared
.
modified_date_list
[
0
].
toJSON
()
},
"
id
"
:
"
{
\"
identifier
\"
:[
\"
a
\"
]}
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Check storage content
"
);
});
});
}
function
putDifferentDocuments
()
{
return
all
(
jio_list
.
map
(
function
(
jio
,
i
)
{
return
jio
.
post
({
"
identifier
"
:
"
b
"
,
"
modified
"
:
shared
.
modified_date_list
[
i
]
});
}));
}
function
repairDocumentWithSynchronization
()
{
return
replicate_jio
.
repair
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
});
}
function
repairDocumentWithSynchronizationTest
(
answer
)
{
deepEqual
(
answer
,
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
,
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
204
,
"
statusText
"
:
"
No Content
"
},
"
Repair document, synchronization should be done.
"
);
// check storage state
return
all
(
jio_list
.
map
(
function
(
jio
)
{
return
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
});
})).
then
(
function
(
answers
)
{
answers
.
forEach
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
data
"
:
{
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
,
"
identifier
"
:
"
b
"
,
"
modified
"
:
shared
.
winner_modified_date
.
toJSON
()
},
"
id
"
:
"
{
\"
identifier
\"
:[
\"
b
\"
]}
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Check storage content
"
);
});
});
}
function
putOneDocument
()
{
return
jio_list
[
1
].
post
({
"
identifier
"
:
"
c
"
,
"
modified
"
:
shared
.
modified_date_list
[
1
]
});
}
function
repairDocumentWith404Synchronization
()
{
return
replicate_jio
.
repair
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
c
\"
]}
"
});
}
function
repairDocumentWith404SynchronizationTest
(
answer
)
{
deepEqual
(
answer
,
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
c
\"
]}
"
,
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
204
,
"
statusText
"
:
"
No Content
"
},
"
Repair document, synchronizing with not found document.
"
);
// check storage state
return
all
(
jio_list
.
map
(
function
(
jio
)
{
return
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
c
\"
]}
"
});
})).
then
(
function
(
answers
)
{
answers
.
forEach
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
data
"
:
{
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
c
\"
]}
"
,
"
identifier
"
:
"
c
"
,
"
modified
"
:
shared
.
winner_modified_date
.
toJSON
()
},
"
id
"
:
"
{
\"
identifier
\"
:[
\"
c
\"
]}
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Check storage content
"
);
});
});
}
function
putDifferentDocuments2
()
{
return
all
(
jio_list
.
map
(
function
(
jio
,
i
)
{
return
jio
.
post
({
"
identifier
"
:
"
d
"
,
"
modified
"
:
shared
.
modified_date_list
[
i
]
});
}));
}
function
repairDocumentWithUnavailableStorage
()
{
setFakeStorage
();
setTimeout
(
function
()
{
fake_storage
.
commands
[
"
replicate scenario test for repair method - 1/allDocs
"
].
error
({
"
status
"
:
0
});
},
100
);
setTimeout
(
function
()
{
fake_storage
.
commands
[
"
replicate scenario test for repair method - 1/allDocs
"
].
error
({
"
status
"
:
0
});
},
200
);
return
replicate_jio
.
repair
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
d
\"
]}
"
});
}
function
repairDocumentWithUnavailableStorageTest
(
answer
)
{
deepEqual
(
answer
,
{
"
id
"
:
"
{
\"
identifier
\"
:[
\"
d
\"
]}
"
,
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
204
,
"
statusText
"
:
"
No Content
"
},
"
Repair document, synchronizing with unavailable storage.
"
);
unsetFakeStorage
();
// check storage state
return
all
(
jio_list
.
map
(
function
(
jio
)
{
return
jio
.
get
({
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
d
\"
]}
"
});
})).
then
(
function
(
answers
)
{
deepEqual
(
answers
[
0
],
{
"
data
"
:
{
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
d
\"
]}
"
,
"
identifier
"
:
"
d
"
,
"
modified
"
:
shared
.
modified_date_list
[
0
].
toJSON
()
},
"
id
"
:
"
{
\"
identifier
\"
:[
\"
d
\"
]}
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Check storage content
"
);
answers
.
slice
(
1
).
forEach
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
data
"
:
{
"
_id
"
:
"
{
\"
identifier
\"
:[
\"
d
\"
]}
"
,
"
identifier
"
:
"
d
"
,
"
modified
"
:
shared
.
winner_modified_date
.
toJSON
()
},
"
id
"
:
"
{
\"
identifier
\"
:[
\"
d
\"
]}
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
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
().
// get without synchronizing anything
then
(
putSimilarDocuments
).
then
(
repairDocumentNothingToSynchronize
).
then
(
repairDocumentNothingToSynchronizeTest
).
// repair with synchronization
then
(
putDifferentDocuments
).
then
(
repairDocumentWithSynchronization
).
then
(
repairDocumentWithSynchronizationTest
).
// repair with 404 synchronization
then
(
putOneDocument
).
then
(
repairDocumentWith404Synchronization
).
then
(
repairDocumentWith404SynchronizationTest
).
// XXX repair with attachment synchronization
// repair with unavailable storage
then
(
putDifferentDocuments2
).
then
(
repairDocumentWithUnavailableStorage
).
then
(
repairDocumentWithUnavailableStorageTest
).
// End of scenario
then
(
null
,
unexpectedError
).
then
(
start
,
start
);
});
}));
}));
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