use of gov.cms.bfd.pipeline.rda.grpc.source.FissClaimStreamCaller in project beneficiary-fhir-data by CMSgov.
the class RdaServerJobIT method testS3.
@Test
public void testS3() throws Exception {
AmazonS3 s3Client = createS3Client(REGION_DEFAULT);
Bucket bucket = null;
try {
bucket = createTestBucket(s3Client);
final String directoryPath = "files-go-here";
final RdaServerJob.Config config = RdaServerJob.Config.builder().serverMode(RdaServerJob.Config.ServerMode.S3).serverName(SERVER_NAME).s3Bucket(bucket.getName()).s3Directory(directoryPath).build();
final String fissObjectKey = config.getS3Sources().createFissObjectKey();
final String mcsObjectKey = config.getS3Sources().createMcsObjectKey();
uploadJsonToBucket(s3Client, bucket.getName(), fissObjectKey, fissClaimsSource);
uploadJsonToBucket(s3Client, bucket.getName(), mcsObjectKey, mcsClaimsSource);
final RdaServerJob job = new RdaServerJob(config);
final ExecutorService exec = Executors.newCachedThreadPool();
final Future<PipelineJobOutcome> outcome = exec.submit(job);
try {
waitForServerToStart(job);
final ManagedChannel fissChannel = InProcessChannelBuilder.forName(SERVER_NAME).build();
final FissClaimStreamCaller fissCaller = new FissClaimStreamCaller();
final var fissStream = fissCaller.callService(fissChannel, CallOptions.DEFAULT, 1098);
assertTrue(fissStream.hasNext());
RdaChange<PreAdjFissClaim> fissChange = fissTransformer.transformClaim(fissStream.next());
assertMatches(fissCaller.callVersionService(fissChannel, CallOptions.DEFAULT), "S3:\\d+:.*");
assertEquals(1098L, fissChange.getSequenceNumber());
assertTrue(fissStream.hasNext());
fissChange = fissTransformer.transformClaim(fissStream.next());
assertEquals(1099L, fissChange.getSequenceNumber());
assertTrue(fissStream.hasNext());
fissChange = fissTransformer.transformClaim(fissStream.next());
assertEquals(1100L, fissChange.getSequenceNumber());
assertFalse(fissStream.hasNext());
final ManagedChannel mcsChannel = InProcessChannelBuilder.forName(SERVER_NAME).build();
final McsClaimStreamCaller mcsCaller = new McsClaimStreamCaller();
final var mcsStream = mcsCaller.callService(mcsChannel, CallOptions.DEFAULT, 1099);
assertTrue(mcsStream.hasNext());
RdaChange<PreAdjMcsClaim> mcsChange = mcsTransformer.transformClaim(mcsStream.next());
assertMatches(mcsCaller.callVersionService(mcsChannel, CallOptions.DEFAULT), "S3:\\d+:.*");
assertEquals(1099L, mcsChange.getSequenceNumber());
assertTrue(mcsStream.hasNext());
mcsChange = mcsTransformer.transformClaim(mcsStream.next());
assertEquals(1100L, mcsChange.getSequenceNumber());
assertFalse(mcsStream.hasNext());
} finally {
exec.shutdownNow();
exec.awaitTermination(10, TimeUnit.SECONDS);
assertEquals(PipelineJobOutcome.WORK_DONE, outcome.get());
}
} finally {
deleteTestBucket(s3Client, bucket);
}
}
use of gov.cms.bfd.pipeline.rda.grpc.source.FissClaimStreamCaller in project beneficiary-fhir-data by CMSgov.
the class RdaServerJobIT method testRandom.
@Test
public void testRandom() throws Exception {
final RdaServerJob.Config config = RdaServerJob.Config.builder().serverMode(RdaServerJob.Config.ServerMode.Random).serverName(SERVER_NAME).randomSeed(1L).randomMaxClaims(4).build();
final RdaServerJob job = new RdaServerJob(config);
final ExecutorService exec = Executors.newCachedThreadPool();
final Future<PipelineJobOutcome> outcome = exec.submit(job);
try {
waitForServerToStart(job);
final ManagedChannel fissChannel = InProcessChannelBuilder.forName(SERVER_NAME).build();
final FissClaimStreamCaller fissCaller = new FissClaimStreamCaller();
final GrpcResponseStream<FissClaimChange> fissStream = fissCaller.callService(fissChannel, CallOptions.DEFAULT, 2);
assertTrue(fissStream.hasNext());
RdaChange<PreAdjFissClaim> fissChange = fissTransformer.transformClaim(fissStream.next());
assertMatches(fissCaller.callVersionService(fissChannel, CallOptions.DEFAULT), "Random:1:.*");
assertEquals(2L, fissChange.getSequenceNumber());
assertTrue(fissStream.hasNext());
fissChange = fissTransformer.transformClaim(fissStream.next());
assertEquals(3L, fissChange.getSequenceNumber());
assertFalse(fissStream.hasNext());
final ManagedChannel mcsChannel = InProcessChannelBuilder.forName(SERVER_NAME).build();
final McsClaimStreamCaller mcsCaller = new McsClaimStreamCaller();
final GrpcResponseStream<McsClaimChange> mcsStream = mcsCaller.callService(mcsChannel, CallOptions.DEFAULT, 3);
assertTrue(mcsStream.hasNext());
RdaChange<PreAdjMcsClaim> mcsChange = mcsTransformer.transformClaim(mcsStream.next());
assertMatches(mcsCaller.callVersionService(mcsChannel, CallOptions.DEFAULT), "Random:1:.*");
assertEquals(3L, mcsChange.getSequenceNumber());
assertFalse(mcsStream.hasNext());
} finally {
exec.shutdownNow();
exec.awaitTermination(10, TimeUnit.SECONDS);
assertEquals(PipelineJobOutcome.WORK_DONE, outcome.get());
}
}
use of gov.cms.bfd.pipeline.rda.grpc.source.FissClaimStreamCaller in project beneficiary-fhir-data by CMSgov.
the class RdaServerJobIT method jobRunsCorrectlyMultipleTimes.
@Test
public void jobRunsCorrectlyMultipleTimes() throws Exception {
final RdaServerJob.Config config = RdaServerJob.Config.builder().serverMode(RdaServerJob.Config.ServerMode.Random).serverName(SERVER_NAME).randomSeed(1L).randomMaxClaims(4).build();
final RdaServerJob job = new RdaServerJob(config);
final ExecutorService exec = Executors.newCachedThreadPool();
try {
// run it once and then interrupt it
Future<PipelineJobOutcome> outcome = exec.submit(job);
waitForServerToStart(job);
ManagedChannel fissChannel = InProcessChannelBuilder.forName(SERVER_NAME).build();
FissClaimStreamCaller fissCaller = new FissClaimStreamCaller();
var fissStream = fissCaller.callService(fissChannel, CallOptions.DEFAULT, 2);
assertTrue(fissStream.hasNext());
assertEquals(2L, fissTransformer.transformClaim(fissStream.next()).getSequenceNumber());
outcome.cancel(true);
waitForServerToStop(job);
// now run it again to ensure gRPC lets server start a second time
outcome = exec.submit(job);
waitForServerToStart(job);
fissChannel = InProcessChannelBuilder.forName(SERVER_NAME).build();
fissCaller = new FissClaimStreamCaller();
fissStream = fissCaller.callService(fissChannel, CallOptions.DEFAULT, 2);
assertTrue(fissStream.hasNext());
assertEquals(2L, fissTransformer.transformClaim(fissStream.next()).getSequenceNumber());
outcome.cancel(true);
waitForServerToStop(job);
} finally {
exec.shutdownNow();
exec.awaitTermination(10, TimeUnit.SECONDS);
}
}
Aggregations