|
74 | 74 | */ |
75 | 75 | public class PubsubIOLT extends IOLoadTestBase { |
76 | 76 |
|
| 77 | + private static final double TOLERANCE_FRACTION = 0.005; |
77 | 78 | private static final int NUMBER_OF_BUNDLES_FOR_LOCAL = 10; |
78 | 79 | private static final int NUMBER_OF_BUNDLES_FOR_MEDIUM_AND_LARGE = 20; |
79 | 80 | private static final String READ_ELEMENT_METRIC_NAME = "read_count"; |
@@ -239,10 +240,12 @@ public void testWriteAndRead() throws IOException { |
239 | 240 | readLaunchInfo.jobId(), |
240 | 241 | getBeamMetricsName(PipelineMetricsType.COUNTER, READ_ELEMENT_METRIC_NAME)); |
241 | 242 |
|
242 | | - // Assert that actual data equals or greater than expected data number since there might be |
| 243 | + // Assert that actual data is within tolerance of expected data number since there might be |
243 | 244 | // duplicates when testing big amount of data |
244 | 245 | long expectedDataNum = configuration.numRecords - configuration.forceNumInitialBundles; |
245 | | - assertTrue(numRecords >= expectedDataNum); |
| 246 | + long allowedTolerance = (long) (configuration.numRecords * TOLERANCE_FRACTION); |
| 247 | + double delta = Math.abs(numRecords - expectedDataNum); |
| 248 | + assertTrue(delta <= allowedTolerance); |
246 | 249 |
|
247 | 250 | // export metrics |
248 | 251 | MetricsConfiguration writeMetricsConfig = |
@@ -305,6 +308,7 @@ private PipelineLauncher.LaunchInfo testWrite(WriteAndReadFormat format) throws |
305 | 308 | .addParameter("runner", configuration.runner) |
306 | 309 | .addParameter("streaming", "true") |
307 | 310 | .addParameter("numWorkers", String.valueOf(configuration.numWorkers)) |
| 311 | + .addParameter("experiments", "use_runner_v2") |
308 | 312 | .build(); |
309 | 313 |
|
310 | 314 | return pipelineLauncher.launch(project, region, writeOptions); |
@@ -339,6 +343,7 @@ private PipelineLauncher.LaunchInfo testRead(WriteAndReadFormat format) throws I |
339 | 343 | .addParameter("runner", configuration.runner) |
340 | 344 | .addParameter("streaming", "true") |
341 | 345 | .addParameter("numWorkers", String.valueOf(configuration.numWorkers)) |
| 346 | + .addParameter("experiments", "use_runner_v2") |
342 | 347 | .build(); |
343 | 348 |
|
344 | 349 | return pipelineLauncher.launch(project, region, readOptions); |
|
0 commit comments