|
@@ -3,12 +3,9 @@ use crate::revision_test::script::{RevisionScript::*, RevisionTest};
|
|
#[tokio::test]
|
|
#[tokio::test]
|
|
async fn revision_sync_test() {
|
|
async fn revision_sync_test() {
|
|
let test = RevisionTest::new().await;
|
|
let test = RevisionTest::new().await;
|
|
- let (base_rev_id, rev_id) = test.next_rev_id_pair();
|
|
|
|
-
|
|
|
|
|
|
+ let rev_id = 1;
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "123".to_string(),
|
|
content: "123".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
@@ -20,21 +17,21 @@ async fn revision_sync_test() {
|
|
#[tokio::test]
|
|
#[tokio::test]
|
|
async fn revision_compress_2_revisions_with_2_threshold_test() {
|
|
async fn revision_compress_2_revisions_with_2_threshold_test() {
|
|
let test = RevisionTest::new_with_configuration(2).await;
|
|
let test = RevisionTest::new_with_configuration(2).await;
|
|
-
|
|
|
|
test.run_script(AddLocalRevision2 {
|
|
test.run_script(AddLocalRevision2 {
|
|
content: "123".to_string(),
|
|
content: "123".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
test.run_script(AddLocalRevision2 {
|
|
test.run_script(AddLocalRevision2 {
|
|
content: "456".to_string(),
|
|
content: "456".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
test.run_scripts(vec![
|
|
test.run_scripts(vec![
|
|
AssertNextSyncRevisionId { rev_id: Some(1) },
|
|
AssertNextSyncRevisionId { rev_id: Some(1) },
|
|
|
|
+ AssertNextSyncRevisionContent {
|
|
|
|
+ expected: "123456".to_string(),
|
|
|
|
+ },
|
|
AckRevision { rev_id: 1 },
|
|
AckRevision { rev_id: 1 },
|
|
AssertNextSyncRevisionId { rev_id: None },
|
|
AssertNextSyncRevisionId { rev_id: None },
|
|
])
|
|
])
|
|
@@ -44,36 +41,25 @@ async fn revision_compress_2_revisions_with_2_threshold_test() {
|
|
#[tokio::test]
|
|
#[tokio::test]
|
|
async fn revision_compress_4_revisions_with_threshold_2_test() {
|
|
async fn revision_compress_4_revisions_with_threshold_2_test() {
|
|
let test = RevisionTest::new_with_configuration(2).await;
|
|
let test = RevisionTest::new_with_configuration(2).await;
|
|
- let (base_rev_id, rev_id_1) = test.next_rev_id_pair();
|
|
|
|
-
|
|
|
|
|
|
+ let rev_id_1 = 1;
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "1".to_string(),
|
|
content: "1".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_1,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_2) = test.next_rev_id_pair();
|
|
|
|
|
|
+ let rev_id_2 = 2;
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "2".to_string(),
|
|
content: "2".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_2,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_3) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "3".to_string(),
|
|
content: "3".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_3,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_4) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "4".to_string(),
|
|
content: "4".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_4,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
@@ -96,68 +82,45 @@ async fn revision_compress_4_revisions_with_threshold_2_test() {
|
|
#[tokio::test]
|
|
#[tokio::test]
|
|
async fn revision_compress_8_revisions_with_threshold_4_test() {
|
|
async fn revision_compress_8_revisions_with_threshold_4_test() {
|
|
let test = RevisionTest::new_with_configuration(4).await;
|
|
let test = RevisionTest::new_with_configuration(4).await;
|
|
- let (base_rev_id, rev_id_1) = test.next_rev_id_pair();
|
|
|
|
-
|
|
|
|
|
|
+ let rev_id_1 = 1;
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "1".to_string(),
|
|
content: "1".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_1,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_2) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "2".to_string(),
|
|
content: "2".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_2,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_3) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "3".to_string(),
|
|
content: "3".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_3,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_4) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "4".to_string(),
|
|
content: "4".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_4,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_a) = test.next_rev_id_pair();
|
|
|
|
|
|
+ let rev_id_a = 2;
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "a".to_string(),
|
|
content: "a".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_a,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_b) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "b".to_string(),
|
|
content: "b".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_b,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_c) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "c".to_string(),
|
|
content: "c".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_c,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
- let (base_rev_id, rev_id_d) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: "d".to_string(),
|
|
content: "d".to_string(),
|
|
- base_rev_id,
|
|
|
|
- rev_id: rev_id_d,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
|
|
|
|
@@ -183,13 +146,7 @@ async fn revision_merge_per_5_revision_test() {
|
|
let test = RevisionTest::new_with_configuration(5).await;
|
|
let test = RevisionTest::new_with_configuration(5).await;
|
|
for i in 0..20 {
|
|
for i in 0..20 {
|
|
let content = format!("{}", i);
|
|
let content = format!("{}", i);
|
|
- let (base_rev_id, rev_id) = test.next_rev_id_pair();
|
|
|
|
- test.run_script(AddLocalRevision {
|
|
|
|
- content,
|
|
|
|
- base_rev_id,
|
|
|
|
- rev_id,
|
|
|
|
- })
|
|
|
|
- .await;
|
|
|
|
|
|
+ test.run_script(AddLocalRevision { content }).await;
|
|
}
|
|
}
|
|
|
|
|
|
test.run_scripts(vec![
|
|
test.run_scripts(vec![
|
|
@@ -220,13 +177,7 @@ async fn revision_merge_per_100_revision_test() {
|
|
let test = RevisionTest::new_with_configuration(100).await;
|
|
let test = RevisionTest::new_with_configuration(100).await;
|
|
for i in 0..1000 {
|
|
for i in 0..1000 {
|
|
let content = format!("{}", i);
|
|
let content = format!("{}", i);
|
|
- let (base_rev_id, rev_id) = test.next_rev_id_pair();
|
|
|
|
- test.run_script(AddLocalRevision {
|
|
|
|
- content,
|
|
|
|
- base_rev_id,
|
|
|
|
- rev_id,
|
|
|
|
- })
|
|
|
|
- .await;
|
|
|
|
|
|
+ test.run_script(AddLocalRevision { content }).await;
|
|
}
|
|
}
|
|
|
|
|
|
test.run_scripts(vec![AssertNumberOfSyncRevisions { num: 10 }]).await;
|
|
test.run_scripts(vec![AssertNumberOfSyncRevisions { num: 10 }]).await;
|
|
@@ -236,11 +187,8 @@ async fn revision_merge_per_100_revision_test() {
|
|
async fn revision_merge_per_100_revision_test2() {
|
|
async fn revision_merge_per_100_revision_test2() {
|
|
let test = RevisionTest::new_with_configuration(100).await;
|
|
let test = RevisionTest::new_with_configuration(100).await;
|
|
for i in 0..50 {
|
|
for i in 0..50 {
|
|
- let (base_rev_id, rev_id) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: format!("{}", i),
|
|
content: format!("{}", i),
|
|
- base_rev_id,
|
|
|
|
- rev_id,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
}
|
|
}
|
|
@@ -252,11 +200,8 @@ async fn revision_merge_per_100_revision_test2() {
|
|
async fn revision_merge_per_1000_revision_test() {
|
|
async fn revision_merge_per_1000_revision_test() {
|
|
let test = RevisionTest::new_with_configuration(1000).await;
|
|
let test = RevisionTest::new_with_configuration(1000).await;
|
|
for i in 0..100000 {
|
|
for i in 0..100000 {
|
|
- let (base_rev_id, rev_id) = test.next_rev_id_pair();
|
|
|
|
test.run_script(AddLocalRevision {
|
|
test.run_script(AddLocalRevision {
|
|
content: format!("{}", i),
|
|
content: format!("{}", i),
|
|
- base_rev_id,
|
|
|
|
- rev_id,
|
|
|
|
})
|
|
})
|
|
.await;
|
|
.await;
|
|
}
|
|
}
|
|
@@ -267,50 +212,42 @@ async fn revision_merge_per_1000_revision_test() {
|
|
#[tokio::test]
|
|
#[tokio::test]
|
|
async fn revision_compress_revision_test() {
|
|
async fn revision_compress_revision_test() {
|
|
let test = RevisionTest::new_with_configuration(2).await;
|
|
let test = RevisionTest::new_with_configuration(2).await;
|
|
-
|
|
|
|
test.run_scripts(vec![
|
|
test.run_scripts(vec![
|
|
AddLocalRevision2 {
|
|
AddLocalRevision2 {
|
|
content: "1".to_string(),
|
|
content: "1".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
},
|
|
},
|
|
AddLocalRevision2 {
|
|
AddLocalRevision2 {
|
|
content: "2".to_string(),
|
|
content: "2".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
},
|
|
},
|
|
AddLocalRevision2 {
|
|
AddLocalRevision2 {
|
|
content: "3".to_string(),
|
|
content: "3".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
},
|
|
},
|
|
AddLocalRevision2 {
|
|
AddLocalRevision2 {
|
|
content: "4".to_string(),
|
|
content: "4".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
},
|
|
},
|
|
AssertNumberOfSyncRevisions { num: 2 },
|
|
AssertNumberOfSyncRevisions { num: 2 },
|
|
])
|
|
])
|
|
.await;
|
|
.await;
|
|
}
|
|
}
|
|
|
|
+
|
|
#[tokio::test]
|
|
#[tokio::test]
|
|
async fn revision_compress_revision_while_recv_ack_test() {
|
|
async fn revision_compress_revision_while_recv_ack_test() {
|
|
let test = RevisionTest::new_with_configuration(2).await;
|
|
let test = RevisionTest::new_with_configuration(2).await;
|
|
test.run_scripts(vec![
|
|
test.run_scripts(vec![
|
|
AddLocalRevision2 {
|
|
AddLocalRevision2 {
|
|
content: "1".to_string(),
|
|
content: "1".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
},
|
|
},
|
|
AckRevision { rev_id: 1 },
|
|
AckRevision { rev_id: 1 },
|
|
AddLocalRevision2 {
|
|
AddLocalRevision2 {
|
|
content: "2".to_string(),
|
|
content: "2".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
},
|
|
},
|
|
AckRevision { rev_id: 2 },
|
|
AckRevision { rev_id: 2 },
|
|
AddLocalRevision2 {
|
|
AddLocalRevision2 {
|
|
content: "3".to_string(),
|
|
content: "3".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
},
|
|
},
|
|
AckRevision { rev_id: 3 },
|
|
AckRevision { rev_id: 3 },
|
|
AddLocalRevision2 {
|
|
AddLocalRevision2 {
|
|
content: "4".to_string(),
|
|
content: "4".to_string(),
|
|
- pair_rev_id: test.next_rev_id_pair(),
|
|
|
|
},
|
|
},
|
|
AssertNumberOfSyncRevisions { num: 4 },
|
|
AssertNumberOfSyncRevisions { num: 4 },
|
|
])
|
|
])
|