@@ -17,7 +17,6 @@ use std::mem::variant_count;
17
17
use std:: sync:: atomic:: AtomicUsize ;
18
18
use std:: sync:: atomic:: Ordering ;
19
19
use std:: sync:: Arc ;
20
- use std:: time:: Duration ;
21
20
22
21
use concurrent_queue:: ConcurrentQueue ;
23
22
use log:: info;
@@ -146,7 +145,7 @@ impl TimeSeriesProfile {
146
145
pub stats : Vec < ( usize , usize ) > ,
147
146
}
148
147
info ! (
149
- target: "databend::log::time_series_stats " ,
148
+ target: "databend::log::time_series " ,
150
149
"{}" ,
151
150
serde_json:: to_string( & TimeSeriesStatistics {
152
151
query_id: self . query_id. clone( ) ,
@@ -164,39 +163,48 @@ impl TimeSeriesProfile {
164
163
}
165
164
}
166
165
167
- #[ test]
168
- fn test_time_series_profile ( ) {
169
- let time_series_profile = TimeSeriesProfile :: create ( 1 , "test_query_id" . to_string ( ) ) ;
170
- time_series_profile. record_point ( ProfileStatisticsName :: OutputRows , 100 ) ;
171
- time_series_profile. record_point ( ProfileStatisticsName :: OutputRows , 200 ) ;
172
- time_series_profile. record_point ( ProfileStatisticsName :: OutputBytes , 400 ) ;
173
- let batch = Vec :: from_iter (
174
- time_series_profile. items [ TimeSeriesProfileStatisticsName :: OutputRows as usize ]
175
- . queue
176
- . try_iter ( ) ,
177
- ) ;
178
- assert_eq ! ( batch. len( ) , 1 ) ;
179
- let batch = Vec :: from_iter (
180
- time_series_profile. items [ TimeSeriesProfileStatisticsName :: OutputBytes as usize ]
181
- . queue
182
- . try_iter ( ) ,
183
- ) ;
184
- assert_eq ! ( batch. len( ) , 1 ) ;
185
- std:: thread:: sleep ( Duration :: from_millis ( 1100 ) ) ;
186
- time_series_profile. record_point ( ProfileStatisticsName :: OutputRows , 300 ) ;
187
- let batch = Vec :: from_iter (
188
- time_series_profile. items [ TimeSeriesProfileStatisticsName :: OutputRows as usize ]
189
- . queue
190
- . try_iter ( ) ,
191
- ) ;
192
- assert_eq ! ( batch. len( ) , 1 ) ;
193
- }
166
+ #[ cfg( test) ]
167
+ mod tests {
168
+ use std:: time:: Duration ;
169
+
170
+ use super :: * ;
171
+ #[ test]
172
+ fn test_time_series_profile ( ) {
173
+ let time_series_profile = TimeSeriesProfile :: create ( 1 , "test_query_id" . to_string ( ) ) ;
174
+ time_series_profile. record_point ( ProfileStatisticsName :: OutputRows , 100 ) ;
175
+ time_series_profile. record_point ( ProfileStatisticsName :: OutputRows , 200 ) ;
176
+ time_series_profile. record_point ( ProfileStatisticsName :: OutputBytes , 400 ) ;
177
+ let batch = Vec :: from_iter (
178
+ time_series_profile. items [ TimeSeriesProfileStatisticsName :: OutputRows as usize ]
179
+ . queue
180
+ . try_iter ( ) ,
181
+ ) ;
182
+ assert_eq ! ( batch. len( ) , 1 ) ;
183
+ assert_eq ! ( batch[ 0 ] . 1 , 100 ) ;
184
+ let batch = Vec :: from_iter (
185
+ time_series_profile. items [ TimeSeriesProfileStatisticsName :: OutputBytes as usize ]
186
+ . queue
187
+ . try_iter ( ) ,
188
+ ) ;
189
+ assert_eq ! ( batch. len( ) , 1 ) ;
190
+ assert_eq ! ( batch[ 0 ] . 1 , 400 ) ;
191
+ std:: thread:: sleep ( Duration :: from_millis ( 1100 ) ) ;
192
+ time_series_profile. record_point ( ProfileStatisticsName :: OutputRows , 300 ) ;
193
+ let batch = Vec :: from_iter (
194
+ time_series_profile. items [ TimeSeriesProfileStatisticsName :: OutputRows as usize ]
195
+ . queue
196
+ . try_iter ( ) ,
197
+ ) ;
198
+ assert_eq ! ( batch. len( ) , 1 ) ;
199
+ assert_eq ! ( batch[ 0 ] . 1 , 300 ) ;
200
+ }
194
201
195
- #[ test]
196
- fn test_time_series_enum ( ) {
197
- let len = variant_count :: < TimeSeriesProfileStatisticsName > ( ) ;
198
- for i in 0 ..len {
199
- let name = TimeSeriesProfileStatisticsName :: from ( i) ;
200
- assert_eq ! ( name as usize , i) ;
202
+ #[ test]
203
+ fn test_time_series_enum ( ) {
204
+ let len = variant_count :: < TimeSeriesProfileStatisticsName > ( ) ;
205
+ for i in 0 ..len {
206
+ let name = TimeSeriesProfileStatisticsName :: from ( i) ;
207
+ assert_eq ! ( name as usize , i) ;
208
+ }
201
209
}
202
210
}
0 commit comments