Search in sources :

Example 1 with McsClaimStreamCaller

use of gov.cms.bfd.pipeline.rda.grpc.source.McsClaimStreamCaller 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);
    }
}
Also used : AmazonS3(com.amazonaws.services.s3.AmazonS3) McsClaimStreamCaller(gov.cms.bfd.pipeline.rda.grpc.source.McsClaimStreamCaller) FissClaimStreamCaller(gov.cms.bfd.pipeline.rda.grpc.source.FissClaimStreamCaller) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) Bucket(com.amazonaws.services.s3.model.Bucket) PipelineJobOutcome(gov.cms.bfd.pipeline.sharedutils.PipelineJobOutcome) ExecutorService(java.util.concurrent.ExecutorService) ManagedChannel(io.grpc.ManagedChannel) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) Test(org.junit.jupiter.api.Test)

Example 2 with McsClaimStreamCaller

use of gov.cms.bfd.pipeline.rda.grpc.source.McsClaimStreamCaller 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());
    }
}
Also used : McsClaimStreamCaller(gov.cms.bfd.pipeline.rda.grpc.source.McsClaimStreamCaller) FissClaimChange(gov.cms.mpsm.rda.v1.FissClaimChange) FissClaimStreamCaller(gov.cms.bfd.pipeline.rda.grpc.source.FissClaimStreamCaller) PreAdjFissClaim(gov.cms.bfd.model.rda.PreAdjFissClaim) PipelineJobOutcome(gov.cms.bfd.pipeline.sharedutils.PipelineJobOutcome) ExecutorService(java.util.concurrent.ExecutorService) ManagedChannel(io.grpc.ManagedChannel) PreAdjMcsClaim(gov.cms.bfd.model.rda.PreAdjMcsClaim) McsClaimChange(gov.cms.mpsm.rda.v1.McsClaimChange) Test(org.junit.jupiter.api.Test)

Aggregations

PreAdjFissClaim (gov.cms.bfd.model.rda.PreAdjFissClaim)2 PreAdjMcsClaim (gov.cms.bfd.model.rda.PreAdjMcsClaim)2 FissClaimStreamCaller (gov.cms.bfd.pipeline.rda.grpc.source.FissClaimStreamCaller)2 McsClaimStreamCaller (gov.cms.bfd.pipeline.rda.grpc.source.McsClaimStreamCaller)2 PipelineJobOutcome (gov.cms.bfd.pipeline.sharedutils.PipelineJobOutcome)2 ManagedChannel (io.grpc.ManagedChannel)2 ExecutorService (java.util.concurrent.ExecutorService)2 Test (org.junit.jupiter.api.Test)2 AmazonS3 (com.amazonaws.services.s3.AmazonS3)1 Bucket (com.amazonaws.services.s3.model.Bucket)1 FissClaimChange (gov.cms.mpsm.rda.v1.FissClaimChange)1 McsClaimChange (gov.cms.mpsm.rda.v1.McsClaimChange)1