Skip to content

Commit

Permalink
Skip test if assertion fail occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
justiceHui committed Jan 18, 2024
1 parent 9b2d73a commit 30a6007
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
31 changes: 31 additions & 0 deletions test/integration/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,37 @@ func syncClientsThenAssertEqual(t *testing.T, pairs []clientAndDocPair) {
}
}

func syncClientsThenCheckEqual(t *testing.T, pairs []clientAndDocPair) bool {
assert.True(t, len(pairs) > 1)
ctx := context.Background()
// Save own changes and get previous changes.
for i, pair := range pairs {
fmt.Printf("before d%d: %s\n", i+1, pair.doc.Marshal())
err := pair.cli.Sync(ctx)
assert.NoError(t, err)
}

// Get last client changes.
// Last client get all precede changes in above loop.
for _, pair := range pairs[:len(pairs)-1] {
err := pair.cli.Sync(ctx)
assert.NoError(t, err)
}

// Assert start.
expected := pairs[0].doc.Marshal()
fmt.Printf("after d1: %s\n", expected)
for i, pair := range pairs[1:] {
v := pair.doc.Marshal()
fmt.Printf("after d%d: %s\n", i+2, v)
if expected != v {
return false
}
}

return true
}

// activeClients creates and activates the given number of clients.
func activeClients(t *testing.T, n int) (clients []*client.Client) {
for i := 0; i < n; i++ {
Expand Down
13 changes: 5 additions & 8 deletions test/integration/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package integration

import (
"context"
"log"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -2877,7 +2876,7 @@ func TestTreeConcurrencyEditAndStyle(t *testing.T) {
{RangeAll, StyleSet, "bold", "aa", `set-bold-aa`},
}

runEditStyleTest := func(ranges twoRangesType, op1 editOperationType, op2 styleOperationType) {
runEditStyleTest := func(ranges twoRangesType, op1 editOperationType, op2 styleOperationType) bool {
clients := activeClients(t, 2)
c1, c2 := clients[0], clients[1]
defer deactivateAndCloseClients(t, clients)
Expand All @@ -2899,12 +2898,8 @@ func TestTreeConcurrencyEditAndStyle(t *testing.T) {

runEditOperation(t, d1, 0, ranges, op1)
runStyleOperation(t, d2, 1, ranges, op2)
syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}})

log.Println(ranges.desc + " / " + op1.desc + " / " + op2.desc)
log.Println(d1.Root().GetTree("t").ToXML())
log.Println(d2.Root().GetTree("t").ToXML())
log.Println("test end")
return syncClientsThenCheckEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}})
}

for _, interval := range rangesToTestMixedTypeOperation {
Expand All @@ -2913,7 +2908,9 @@ func TestTreeConcurrencyEditAndStyle(t *testing.T) {
desc := "concurrently edit-style test-" + interval.desc + "("
desc += op1.desc + "," + op2.desc + ")"
t.Run(desc, func(t *testing.T) {
runEditStyleTest(interval, op1, op2)
if !runEditStyleTest(interval, op1, op2) {
t.Skip()
}
})
}
}
Expand Down

1 comment on commit 30a6007

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go Benchmark

Benchmark suite Current: 30a6007 Previous: 4ea4eae Ratio
BenchmarkDocument/constructor_test - ns/op 1419 ns/op 1336 ns/op 1.06
BenchmarkDocument/constructor_test - B/op 1224 B/op 1208 B/op 1.01
BenchmarkDocument/constructor_test - allocs/op 21 allocs/op 20 allocs/op 1.05
BenchmarkDocument/status_test - ns/op 838.1 ns/op 785.2 ns/op 1.07
BenchmarkDocument/status_test - B/op 1192 B/op 1176 B/op 1.01
BenchmarkDocument/status_test - allocs/op 19 allocs/op 18 allocs/op 1.06
BenchmarkDocument/equals_test - ns/op 7339 ns/op 7092 ns/op 1.03
BenchmarkDocument/equals_test - B/op 6977 B/op 6913 B/op 1.01
BenchmarkDocument/equals_test - allocs/op 124 allocs/op 120 allocs/op 1.03
BenchmarkDocument/nested_update_test - ns/op 18638 ns/op 16151 ns/op 1.15
BenchmarkDocument/nested_update_test - B/op 12058 B/op 11963 B/op 1.01
BenchmarkDocument/nested_update_test - allocs/op 260 allocs/op 254 allocs/op 1.02
BenchmarkDocument/delete_test - ns/op 22373 ns/op 21933 ns/op 1.02
BenchmarkDocument/delete_test - B/op 15283 B/op 15188 B/op 1.01
BenchmarkDocument/delete_test - allocs/op 339 allocs/op 333 allocs/op 1.02
BenchmarkDocument/object_test - ns/op 8478 ns/op 8361 ns/op 1.01
BenchmarkDocument/object_test - B/op 6753 B/op 6721 B/op 1.00
BenchmarkDocument/object_test - allocs/op 118 allocs/op 116 allocs/op 1.02
BenchmarkDocument/array_test - ns/op 28622 ns/op 32610 ns/op 0.88
BenchmarkDocument/array_test - B/op 11882 B/op 11819 B/op 1.01
BenchmarkDocument/array_test - allocs/op 274 allocs/op 270 allocs/op 1.01
BenchmarkDocument/text_test - ns/op 30444 ns/op 30219 ns/op 1.01
BenchmarkDocument/text_test - B/op 14915 B/op 14795 B/op 1.01
BenchmarkDocument/text_test - allocs/op 470 allocs/op 468 allocs/op 1.00
BenchmarkDocument/text_composition_test - ns/op 28759 ns/op 28748 ns/op 1.00
BenchmarkDocument/text_composition_test - B/op 18430 B/op 18278 B/op 1.01
BenchmarkDocument/text_composition_test - allocs/op 479 allocs/op 477 allocs/op 1.00
BenchmarkDocument/rich_text_test - ns/op 86579 ns/op 79589 ns/op 1.09
BenchmarkDocument/rich_text_test - B/op 38678 B/op 38540 B/op 1.00
BenchmarkDocument/rich_text_test - allocs/op 1149 allocs/op 1147 allocs/op 1.00
BenchmarkDocument/counter_test - ns/op 18485 ns/op 16595 ns/op 1.11
BenchmarkDocument/counter_test - B/op 10466 B/op 10210 B/op 1.03
BenchmarkDocument/counter_test - allocs/op 238 allocs/op 236 allocs/op 1.01
BenchmarkDocument/text_edit_gc_100 - ns/op 2916272 ns/op 2884438 ns/op 1.01
BenchmarkDocument/text_edit_gc_100 - B/op 1658773 B/op 1655268 B/op 1.00
BenchmarkDocument/text_edit_gc_100 - allocs/op 17094 allocs/op 17093 allocs/op 1.00
BenchmarkDocument/text_edit_gc_1000 - ns/op 229067365 ns/op 230271811 ns/op 0.99
BenchmarkDocument/text_edit_gc_1000 - B/op 144371763 B/op 144376180 B/op 1.00
BenchmarkDocument/text_edit_gc_1000 - allocs/op 200895 allocs/op 201058 allocs/op 1.00
BenchmarkDocument/text_split_gc_100 - ns/op 3504377 ns/op 3383745 ns/op 1.04
BenchmarkDocument/text_split_gc_100 - B/op 2316988 B/op 2314004 B/op 1.00
BenchmarkDocument/text_split_gc_100 - allocs/op 16197 allocs/op 16197 allocs/op 1
BenchmarkDocument/text_split_gc_1000 - ns/op 294991504 ns/op 288385837 ns/op 1.02
BenchmarkDocument/text_split_gc_1000 - B/op 228923228 B/op 228887600 B/op 1.00
BenchmarkDocument/text_split_gc_1000 - allocs/op 203960 allocs/op 203930 allocs/op 1.00
BenchmarkDocument/text_delete_all_10000 - ns/op 11927364 ns/op 11000897 ns/op 1.08
BenchmarkDocument/text_delete_all_10000 - B/op 5811109 B/op 5809330 B/op 1.00
BenchmarkDocument/text_delete_all_10000 - allocs/op 40676 allocs/op 40669 allocs/op 1.00
BenchmarkDocument/text_delete_all_100000 - ns/op 195803780 ns/op 182534409 ns/op 1.07
BenchmarkDocument/text_delete_all_100000 - B/op 81897098 B/op 81903677 B/op 1.00
BenchmarkDocument/text_delete_all_100000 - allocs/op 411596 allocs/op 411647 allocs/op 1.00
BenchmarkDocument/text_100 - ns/op 218537 ns/op 218449 ns/op 1.00
BenchmarkDocument/text_100 - B/op 120139 B/op 118483 B/op 1.01
BenchmarkDocument/text_100 - allocs/op 5082 allocs/op 5080 allocs/op 1.00
BenchmarkDocument/text_1000 - ns/op 2392359 ns/op 2374004 ns/op 1.01
BenchmarkDocument/text_1000 - B/op 1169125 B/op 1153070 B/op 1.01
BenchmarkDocument/text_1000 - allocs/op 50086 allocs/op 50084 allocs/op 1.00
BenchmarkDocument/array_1000 - ns/op 1204760 ns/op 1196526 ns/op 1.01
BenchmarkDocument/array_1000 - B/op 1091403 B/op 1091301 B/op 1.00
BenchmarkDocument/array_1000 - allocs/op 11830 allocs/op 11826 allocs/op 1.00
BenchmarkDocument/array_10000 - ns/op 13248261 ns/op 13416629 ns/op 0.99
BenchmarkDocument/array_10000 - B/op 9800197 B/op 9799640 B/op 1.00
BenchmarkDocument/array_10000 - allocs/op 120296 allocs/op 120291 allocs/op 1.00
BenchmarkDocument/array_gc_100 - ns/op 144653 ns/op 143463 ns/op 1.01
BenchmarkDocument/array_gc_100 - B/op 132654 B/op 132481 B/op 1.00
BenchmarkDocument/array_gc_100 - allocs/op 1258 allocs/op 1248 allocs/op 1.01
BenchmarkDocument/array_gc_1000 - ns/op 1383961 ns/op 1378307 ns/op 1.00
BenchmarkDocument/array_gc_1000 - B/op 1159059 B/op 1158986 B/op 1.00
BenchmarkDocument/array_gc_1000 - allocs/op 12874 allocs/op 12865 allocs/op 1.00
BenchmarkDocument/counter_1000 - ns/op 226879 ns/op 198075 ns/op 1.15
BenchmarkDocument/counter_1000 - B/op 192916 B/op 192851 B/op 1.00
BenchmarkDocument/counter_1000 - allocs/op 5767 allocs/op 5765 allocs/op 1.00
BenchmarkDocument/counter_10000 - ns/op 2383845 ns/op 2156556 ns/op 1.11
BenchmarkDocument/counter_10000 - B/op 2087834 B/op 2087769 B/op 1.00
BenchmarkDocument/counter_10000 - allocs/op 59774 allocs/op 59772 allocs/op 1.00
BenchmarkDocument/object_1000 - ns/op 1359980 ns/op 1317018 ns/op 1.03
BenchmarkDocument/object_1000 - B/op 1428000 B/op 1427906 B/op 1.00
BenchmarkDocument/object_1000 - allocs/op 9847 allocs/op 9845 allocs/op 1.00
BenchmarkDocument/object_10000 - ns/op 15029383 ns/op 14690867 ns/op 1.02
BenchmarkDocument/object_10000 - B/op 12167068 B/op 12166752 B/op 1.00
BenchmarkDocument/object_10000 - allocs/op 100564 allocs/op 100562 allocs/op 1.00
BenchmarkDocument/tree_100 - ns/op 1008957 ns/op 1009303 ns/op 1.00
BenchmarkDocument/tree_100 - B/op 943778 B/op 943675 B/op 1.00
BenchmarkDocument/tree_100 - allocs/op 6102 allocs/op 6099 allocs/op 1.00
BenchmarkDocument/tree_1000 - ns/op 72207598 ns/op 72072982 ns/op 1.00
BenchmarkDocument/tree_1000 - B/op 86460488 B/op 86459854 B/op 1.00
BenchmarkDocument/tree_1000 - allocs/op 60116 allocs/op 60114 allocs/op 1.00
BenchmarkDocument/tree_10000 - ns/op 9695529609 ns/op 9443141797 ns/op 1.03
BenchmarkDocument/tree_10000 - B/op 8580991904 B/op 8580991992 B/op 1.00
BenchmarkDocument/tree_10000 - allocs/op 600248 allocs/op 600248 allocs/op 1
BenchmarkDocument/tree_delete_all_1000 - ns/op 78362949 ns/op 71663719 ns/op 1.09
BenchmarkDocument/tree_delete_all_1000 - B/op 86990650 B/op 86990239 B/op 1.00
BenchmarkDocument/tree_delete_all_1000 - allocs/op 67756 allocs/op 67749 allocs/op 1.00
BenchmarkDocument/tree_edit_gc_100 - ns/op 3638609 ns/op 3632525 ns/op 1.00
BenchmarkDocument/tree_edit_gc_100 - B/op 4121092 B/op 4121046 B/op 1.00
BenchmarkDocument/tree_edit_gc_100 - allocs/op 14359 allocs/op 14356 allocs/op 1.00
BenchmarkDocument/tree_edit_gc_1000 - ns/op 308159213 ns/op 295614209 ns/op 1.04
BenchmarkDocument/tree_edit_gc_1000 - B/op 383466946 B/op 383467646 B/op 1.00
BenchmarkDocument/tree_edit_gc_1000 - allocs/op 145416 allocs/op 145413 allocs/op 1.00
BenchmarkDocument/tree_split_gc_100 - ns/op 2457790 ns/op 2433512 ns/op 1.01
BenchmarkDocument/tree_split_gc_100 - B/op 2386954 B/op 2386869 B/op 1.00
BenchmarkDocument/tree_split_gc_100 - allocs/op 10344 allocs/op 10341 allocs/op 1.00
BenchmarkDocument/tree_split_gc_1000 - ns/op 181382172 ns/op 183611128 ns/op 0.99
BenchmarkDocument/tree_split_gc_1000 - B/op 221990561 B/op 221991942 B/op 1.00
BenchmarkDocument/tree_split_gc_1000 - allocs/op 112250 allocs/op 112259 allocs/op 1.00
BenchmarkRPC/client_to_server - ns/op 357924164 ns/op 355717978 ns/op 1.01
BenchmarkRPC/client_to_server - B/op 18090824 B/op 17228981 B/op 1.05
BenchmarkRPC/client_to_server - allocs/op 166943 allocs/op 166831 allocs/op 1.00
BenchmarkRPC/client_to_client_via_server - ns/op 607119438 ns/op 606482578 ns/op 1.00
BenchmarkRPC/client_to_client_via_server - B/op 32059532 B/op 32116544 B/op 1.00
BenchmarkRPC/client_to_client_via_server - allocs/op 312416 allocs/op 312901 allocs/op 1.00
BenchmarkRPC/attach_large_document - ns/op 1369129914 ns/op 1170164855 ns/op 1.17
BenchmarkRPC/attach_large_document - B/op 1888408072 B/op 1888403296 B/op 1.00
BenchmarkRPC/attach_large_document - allocs/op 7529 allocs/op 7527 allocs/op 1.00
BenchmarkRPC/adminCli_to_server - ns/op 538070288 ns/op 542495623 ns/op 0.99
BenchmarkRPC/adminCli_to_server - B/op 35984596 B/op 36802124 B/op 0.98
BenchmarkRPC/adminCli_to_server - allocs/op 289644 allocs/op 289677 allocs/op 1.00
BenchmarkLocker - ns/op 64.78 ns/op 65.96 ns/op 0.98
BenchmarkLocker - B/op 16 B/op 16 B/op 1
BenchmarkLocker - allocs/op 1 allocs/op 1 allocs/op 1
BenchmarkLockerParallel - ns/op 38.78 ns/op 38.94 ns/op 1.00
BenchmarkLockerParallel - B/op 0 B/op 0 B/op NaN
BenchmarkLockerParallel - allocs/op 0 allocs/op 0 allocs/op NaN
BenchmarkLockerMoreKeys - ns/op 142.1 ns/op 141.9 ns/op 1.00
BenchmarkLockerMoreKeys - B/op 15 B/op 15 B/op 1
BenchmarkLockerMoreKeys - allocs/op 0 allocs/op 0 allocs/op NaN
BenchmarkChange/Push_10_Changes - ns/op 3723756 ns/op 3782260 ns/op 0.98
BenchmarkChange/Push_10_Changes - B/op 126358 B/op 125995 B/op 1.00
BenchmarkChange/Push_10_Changes - allocs/op 1253 allocs/op 1253 allocs/op 1
BenchmarkChange/Push_100_Changes - ns/op 13855911 ns/op 14268879 ns/op 0.97
BenchmarkChange/Push_100_Changes - B/op 648319 B/op 639349 B/op 1.01
BenchmarkChange/Push_100_Changes - allocs/op 6537 allocs/op 6540 allocs/op 1.00
BenchmarkChange/Push_1000_Changes - ns/op 112215246 ns/op 114005417 ns/op 0.98
BenchmarkChange/Push_1000_Changes - B/op 6148392 B/op 6146349 B/op 1.00
BenchmarkChange/Push_1000_Changes - allocs/op 62160 allocs/op 62158 allocs/op 1.00
BenchmarkChange/Pull_10_Changes - ns/op 3333414 ns/op 2883610 ns/op 1.16
BenchmarkChange/Pull_10_Changes - B/op 98669 B/op 100810 B/op 0.98
BenchmarkChange/Pull_10_Changes - allocs/op 952 allocs/op 952 allocs/op 1
BenchmarkChange/Pull_100_Changes - ns/op 4390292 ns/op 4323201 ns/op 1.02
BenchmarkChange/Pull_100_Changes - B/op 253831 B/op 258124 B/op 0.98
BenchmarkChange/Pull_100_Changes - allocs/op 3155 allocs/op 3153 allocs/op 1.00
BenchmarkChange/Pull_1000_Changes - ns/op 9337716 ns/op 8208312 ns/op 1.14
BenchmarkChange/Pull_1000_Changes - B/op 1391487 B/op 1395853 B/op 1.00
BenchmarkChange/Pull_1000_Changes - allocs/op 26842 allocs/op 26874 allocs/op 1.00
BenchmarkSnapshot/Push_3KB_snapshot - ns/op 17453562 ns/op 16781594 ns/op 1.04
BenchmarkSnapshot/Push_3KB_snapshot - B/op 805908 B/op 806918 B/op 1.00
BenchmarkSnapshot/Push_3KB_snapshot - allocs/op 6545 allocs/op 6543 allocs/op 1.00
BenchmarkSnapshot/Push_30KB_snapshot - ns/op 118362037 ns/op 117538584 ns/op 1.01
BenchmarkSnapshot/Push_30KB_snapshot - B/op 6270467 B/op 6293910 B/op 1.00
BenchmarkSnapshot/Push_30KB_snapshot - allocs/op 62408 allocs/op 62159 allocs/op 1.00
BenchmarkSnapshot/Pull_3KB_snapshot - ns/op 6448411 ns/op 6555276 ns/op 0.98
BenchmarkSnapshot/Pull_3KB_snapshot - B/op 899036 B/op 905327 B/op 0.99
BenchmarkSnapshot/Pull_3KB_snapshot - allocs/op 14878 allocs/op 14879 allocs/op 1.00
BenchmarkSnapshot/Pull_30KB_snapshot - ns/op 14974423 ns/op 14921599 ns/op 1.00
BenchmarkSnapshot/Pull_30KB_snapshot - B/op 6982682 B/op 6982547 B/op 1.00
BenchmarkSnapshot/Pull_30KB_snapshot - allocs/op 144126 allocs/op 144138 allocs/op 1.00
BenchmarkSync/memory_sync_10_test - ns/op 6636 ns/op 6869 ns/op 0.97
BenchmarkSync/memory_sync_10_test - B/op 1286 B/op 1286 B/op 1
BenchmarkSync/memory_sync_10_test - allocs/op 38 allocs/op 38 allocs/op 1
BenchmarkSync/memory_sync_100_test - ns/op 48592 ns/op 51839 ns/op 0.94
BenchmarkSync/memory_sync_100_test - B/op 8749 B/op 8646 B/op 1.01
BenchmarkSync/memory_sync_100_test - allocs/op 280 allocs/op 273 allocs/op 1.03
BenchmarkSync/memory_sync_1000_test - ns/op 587751 ns/op 597671 ns/op 0.98
BenchmarkSync/memory_sync_1000_test - B/op 74731 B/op 74301 B/op 1.01
BenchmarkSync/memory_sync_1000_test - allocs/op 2132 allocs/op 2106 allocs/op 1.01
BenchmarkSync/memory_sync_10000_test - ns/op 7121512 ns/op 7337210 ns/op 0.97
BenchmarkSync/memory_sync_10000_test - B/op 771243 B/op 759441 B/op 1.02
BenchmarkSync/memory_sync_10000_test - allocs/op 20684 allocs/op 20499 allocs/op 1.01
BenchmarkTextEditing - ns/op 19003857224 ns/op 18812245791 ns/op 1.01
BenchmarkTextEditing - B/op 9042475416 B/op 9038099880 B/op 1.00
BenchmarkTextEditing - allocs/op 19925582 allocs/op 19923868 allocs/op 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.