1
+ // Copyright 2023 RisingWave Labs
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
1
15
use std:: time:: Duration ;
2
16
3
17
use anyhow:: Result ;
4
- use risingwave_simulation:: cluster:: { Configuration , KillOpts } ;
18
+ use risingwave_simulation:: cluster:: Configuration ;
5
19
use risingwave_simulation:: nexmark:: NexmarkCluster ;
6
20
use risingwave_simulation:: utils:: AssertResult ;
7
21
use tokio:: time:: { sleep, timeout} ;
@@ -24,7 +38,16 @@ enum ResumeBy {
24
38
}
25
39
26
40
async fn test_impl ( resume_by : ResumeBy ) -> Result < ( ) > {
27
- let mut cluster = NexmarkCluster :: new ( Configuration :: for_scale ( ) , 6 , None , false ) . await ?;
41
+ let mut cluster = NexmarkCluster :: new (
42
+ Configuration {
43
+ meta_nodes : 1 ,
44
+ ..Configuration :: for_scale ( )
45
+ } ,
46
+ 6 ,
47
+ None ,
48
+ false ,
49
+ )
50
+ . await ?;
28
51
29
52
cluster. run ( SET_PARAMETER ) . await ?;
30
53
cluster. run ( CREATE ) . await ?;
@@ -33,8 +56,8 @@ async fn test_impl(resume_by: ResumeBy) -> Result<()> {
33
56
// Run for a while.
34
57
sleep ( Duration :: from_secs ( 10 ) ) . await ;
35
58
36
- // Kill all nodes and wait for the service to recover.
37
- cluster. kill_node ( & KillOpts :: ALL ) . await ;
59
+ // Kill the meta node and wait for the service to recover.
60
+ cluster. kill_nodes ( [ "meta-1" ] , 0 ) . await ;
38
61
sleep ( Duration :: from_secs ( 10 ) ) . await ;
39
62
40
63
// The source should be paused.
@@ -64,20 +87,28 @@ async fn test_impl(resume_by: ResumeBy) -> Result<()> {
64
87
65
88
match resume_by {
66
89
ResumeBy :: Risectl => cluster. resume ( ) . await ?,
67
- ResumeBy :: Restart => cluster. kill_node ( & KillOpts :: ALL ) . await ,
90
+ ResumeBy :: Restart => cluster. kill_nodes ( [ "meta-1" ] , 0 ) . await ,
68
91
}
69
92
sleep ( Duration :: from_secs ( 10 ) ) . await ;
70
93
71
94
// The source should be resumed.
72
95
let new_count = cluster. run ( SELECT ) . await ?;
73
96
assert_ne ! ( count, new_count) ;
74
97
75
- // DML on tables should be allowed.
98
+ // DML on tables should be allowed. However, we're uncertain whether the previous blocked DML is
99
+ // executed or not. So we just check the count difference.
76
100
{
77
101
let mut session = cluster. start_session ( ) ;
102
+
103
+ session. run ( "FLUSH" ) . await ?;
104
+ let count: i64 = session. run ( SELECT_COUNT_TABLE ) . await ?. parse ( ) . unwrap ( ) ;
105
+
78
106
session. run ( INSERT_INTO_TABLE ) . await ?;
79
107
session. run ( "FLUSH" ) . await ?;
80
- session. run ( SELECT_COUNT_TABLE ) . await ?. assert_result_eq ( "1" ) ;
108
+ session
109
+ . run ( SELECT_COUNT_TABLE )
110
+ . await ?
111
+ . assert_result_eq ( format ! ( "{}" , count + 1 ) ) ;
81
112
}
82
113
83
114
Ok ( ( ) )
0 commit comments