diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 18483030a2..7f98674a69 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -56,3 +56,17 @@ updates: schedule: interval: "daily" open-pull-requests-limit: 10 + + - package-ecosystem: "docker" + directory: "/mock/mock-bie-kafka" + target-branch: "develop" + schedule: + interval: "daily" + open-pull-requests-limit: 10 + + - package-ecosystem: "docker" + directory: "/mock/mock-bie-schema-registry" + target-branch: "develop" + schedule: + interval: "daily" + open-pull-requests-limit: 10 diff --git a/.github/workflows/bie-kafka-end2end-test.yml b/.github/workflows/bie-kafka-end2end-test.yml index cbc43addb3..a6cf69b298 100644 --- a/.github/workflows/bie-kafka-end2end-test.yml +++ b/.github/workflows/bie-kafka-end2end-test.yml @@ -45,7 +45,7 @@ jobs: ./gradlew :dockerComposeUp - ./gradlew -p mocks :mock-bie-kafka:docker + ./gradlew -p mocks docker ./gradlew -p mocks :dockerComposeUp ./gradlew :domain-xample:dockerComposeUp diff --git a/app/docker-compose.yml b/app/docker-compose.yml index c9729cdddd..1f695d707d 100644 --- a/app/docker-compose.yml +++ b/app/docker-compose.yml @@ -121,6 +121,7 @@ services: environment: <<: [*rabbitmq-placeholder-vars, *common-vars] BIE_KAFKA_PLACEHOLDERS_BROKERS: mock-bie-kafka:9092 + BIE_KAFKA_PLACEHOLDERS_SCHEMA_REGISTRY: mock-bie-schema-registry:8081 BIE_KAFKA_KEYSTORE_INBASE64: ${BIE_KAFKA_KEYSTORE_INBASE64} BIE_KAFKA_KEYSTORE_PASSWORD: ${BIE_KAFKA_KEYSTORE_PASSWORD} BIE_KAFKA_TRUSTSTORE_INBASE64: ${BIE_KAFKA_TRUSTSTORE_INBASE64} diff --git a/mocks/docker-compose.yml b/mocks/docker-compose.yml index 89914477c9..0709f68410 100644 --- a/mocks/docker-compose.yml +++ b/mocks/docker-compose.yml @@ -96,7 +96,7 @@ services: # Set up SSL -- see "Security" section of https://hub.docker.com/r/bitnami/kafka/ KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,CONTROLLER:PLAINTEXT,EXTERNAL:SSL KAFKA_CFG_SSL_CLIENT_AUTH: required - # PEM https://medium.com/analytics-vidhya/how-to-use-pem-certificates-with-apache-kafka-f3b444a00816 + # PEM https://medium.com/analytics-vidhya/how-to-use-pem-certificates-with-apache-kafka-f3b444a00816 KAFKA_TLS_TYPE: JKS KAFKA_CERTIFICATE_PASSWORD: mockKafka diff --git a/mocks/mock-bie-schema-registry/Dockerfile b/mocks/mock-bie-schema-registry/Dockerfile new file mode 100644 index 0000000000..a21ceec4b5 --- /dev/null +++ b/mocks/mock-bie-schema-registry/Dockerfile @@ -0,0 +1,13 @@ +# Use the official Confluent Schema Registry image as the base +FROM confluentinc/cp-schema-registry:7.5.1 + +USER root + +# Install jq using yum (as root) +RUN yum install -y jq-1.6 && yum clean all + +# Create a new user 'tron' and create a home directory for the user +RUN useradd -m tron + +# Switch to the new user 'tron' +USER tron diff --git a/mocks/mock-bie-schema-registry/build.gradle b/mocks/mock-bie-schema-registry/build.gradle new file mode 100644 index 0000000000..a3a300d514 --- /dev/null +++ b/mocks/mock-bie-schema-registry/build.gradle @@ -0,0 +1,6 @@ +plugins { + id 'shared.docker.container-conventions' +} + +docker { +} diff --git a/mocks/mock-bie-schema-registry/docker-entry.sh b/mocks/mock-bie-schema-registry/docker-entry.sh new file mode 100755 index 0000000000..5c7315d23a --- /dev/null +++ b/mocks/mock-bie-schema-registry/docker-entry.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Start Schema Registry in the background +/etc/confluent/docker/run & + +# Define the Schema Registry URL +SCHEMA_REGISTRY_URL="http://localhost:8081" + +# Wait for Schema Registry to be available +until curl --silent --output /dev/null --fail "$SCHEMA_REGISTRY_URL"; do + echo "Waiting for Schema Registry to be available..." + sleep 5 +done + + +# Navigate to /avro/events folder +cd /avro/events + +# Loop through all .avsc files in the folder +for file in *.avsc; do + # Extract the filename without extension to be used as subject name + subject="${file%.avsc}" + + # Read the file content as schema data + schema=$(cat "$file") + + # Register the schema with the Schema Registry + echo "Registering schema for subject: $subject" + curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \ + --data "$(jq -n --arg schema "$schema" '{"schema": $schema}')" \ + "$SCHEMA_REGISTRY_URL/subjects/$subject/versions" +done + + +# Wait for Schema Registry process to complete +wait $! diff --git a/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_ASSOCIATED_TO_CLAIM_V02.avsc b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_ASSOCIATED_TO_CLAIM_V02.avsc new file mode 100644 index 0000000000..5055330dee --- /dev/null +++ b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_ASSOCIATED_TO_CLAIM_V02.avsc @@ -0,0 +1,188 @@ +{ + "name":"ContentionAssociatedToClaim", + "type":"record", + "namespace":"gov.va.bip.bie.claim.contention", + "fields":[ + { + "name": "ActionName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActionResultName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorApplicationId", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorStation", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorUserId", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "AutomationIndicator", + "type": "boolean" + }, + { + "name":"BenefitClaimTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ClaimId", + "type":"long" + }, + { + "name":"ContentionClassificationName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionId", + "type":"long" + }, + { + "name":"ContentionStatusTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"CurrentLifecycleStatus", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"DateAdded", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "Details", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"DiagnosticTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "EventTime", + "type": + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + }, + { + "name":"VeteranParticipantId", + "type": [ + "null", + "long" + ], + "default": null + }, + { + "name": "BieTs", + "doc": "The timestamp that BIE processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "SourceTs", + "doc": "The timestamp of the source event. This is the time of the database operation.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "ConnectorTs", + "doc": "The timestamp that the connector processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + } + ] +} diff --git a/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_CLASSIFIED_V02.avsc b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_CLASSIFIED_V02.avsc new file mode 100644 index 0000000000..41ec5a99a9 --- /dev/null +++ b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_CLASSIFIED_V02.avsc @@ -0,0 +1,188 @@ +{ + "name":"ContentionClassified", + "type":"record", + "namespace":"gov.va.bip.bie.claim.contention", + "fields":[ + { + "name": "ActionName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActionResultName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorApplicationId", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorUserId", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorStation", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "AutomationIndicator", + "type": "boolean" + }, + { + "name":"BenefitClaimTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ClaimId", + "type":"long" + }, + { + "name":"ContentionClassificationName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionId", + "type":"long" + }, + { + "name":"ContentionStatusTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"CurrentLifecycleStatus", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"DateAdded", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "Details", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"DiagnosticTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "EventTime", + "type": + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + }, + { + "name":"VeteranParticipantId", + "type": [ + "null", + "long" + ], + "default": null + }, + { + "name": "BieTs", + "doc": "The timestamp that BIE processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "SourceTs", + "doc": "The timestamp of the source event. This is the time of the database operation.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "ConnectorTs", + "doc": "The timestamp that the connector processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + } + ] +} diff --git a/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_COMPLETED_V02.avsc b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_COMPLETED_V02.avsc new file mode 100644 index 0000000000..b0c237f04b --- /dev/null +++ b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_COMPLETED_V02.avsc @@ -0,0 +1,188 @@ +{ + "name":"ContentionCompleted", + "type":"record", + "namespace":"gov.va.bip.bie.claim.contention", + "fields":[ + { + "name": "ActionName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActionResultName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorApplicationId", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorStation", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorUserId", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "AutomationIndicator", + "type": "boolean" + }, + { + "name":"BenefitClaimTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ClaimId", + "type":"long" + }, + { + "name":"ContentionClassificationName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionId", + "type":"long" + }, + { + "name":"ContentionStatusTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"CurrentLifecycleStatus", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"DateAdded", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "Details", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"DiagnosticTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "EventTime", + "type": + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + }, + { + "name":"VeteranParticipantId", + "type": [ + "null", + "long" + ], + "default": null + }, + { + "name": "BieTs", + "doc": "The timestamp that BIE processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "SourceTs", + "doc": "The timestamp of the source event. This is the time of the database operation.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "ConnectorTs", + "doc": "The timestamp that the connector processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + } + ] +} diff --git a/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_DELETED_V02.avsc b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_DELETED_V02.avsc new file mode 100644 index 0000000000..49f8d7c395 --- /dev/null +++ b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_DELETED_V02.avsc @@ -0,0 +1,123 @@ +{ + "name":"ContentionDeleted", + "type":"record", + "namespace":"gov.va.bip.bie.claim.contention", + "fields":[ + { + "name": "ActionName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActionResultName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "AutomationIndicator", + "type": [ + "null", + "boolean" + ], + "default": null + }, + { + "name":"ClaimId", + "type":"long" + }, + { + "name":"ContentionId", + "type":"long" + }, + { + "name":"ContentionStatusTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"CurrentLifecycleStatus", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "Description", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "EventTime", + "type": + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + }, + { + "name": "BieTs", + "doc": "The timestamp that BIE processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "SourceTs", + "doc": "The timestamp of the source event. This is the time of the database operation.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "ConnectorTs", + "doc": "The timestamp that the connector processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + } + ] +} diff --git a/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_UPDATED_V02.avsc b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_UPDATED_V02.avsc new file mode 100644 index 0000000000..b0d41a4590 --- /dev/null +++ b/mocks/mock-bie-schema-registry/resources/avro/events/TST_CONTENTION_BIE_CONTENTION_UPDATED_V02.avsc @@ -0,0 +1,234 @@ +{ + "name":"ContentionUpdated", + "type":"record", + "namespace":"gov.va.bip.bie.claim.contention", + "fields":[ + { + "name": "ActionName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActionResultName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorUserId", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorApplicationId", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "ActorStation", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "AutomationIndicator", + "type": "boolean", + "default": false + }, + { + "name":"BenefitClaimTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ClaimId", + "type":"long" + }, + { + "name":"ContentionClassificationName", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionId", + "type":"long" + }, + { + "name":"ContentionStatusTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"ContentionTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"CurrentLifecycleStatus", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"DateAdded", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name":"DateCompleted", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name":"DateUpdated", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "Details", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"DiagnosticTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "Description", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name": "EventTime", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name":"JournalStatusTypeCode", + "type": [ + "null", + "string" + ], + "default": null + }, + { + "name":"VeteranParticipantId", + "type": [ + "null", + "long" + ], + "default": null + }, + { + "name": "BieTs", + "doc": "The timestamp that BIE processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "SourceTs", + "doc": "The timestamp of the source event. This is the time of the database operation.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + }, + { + "name": "ConnectorTs", + "doc": "The timestamp that the connector processed the event.", + "type": [ + "null", + { + "type": "long", + "connect.version": 1, + "connect.name": "org.apache.kafka.connect.data.Timestamp", + "logicalType": "timestamp-millis" + } + ], + "default": null + } + ] +} diff --git a/mocks/settings.gradle b/mocks/settings.gradle index a1ed75a939..8b80be173c 100644 --- a/mocks/settings.gradle +++ b/mocks/settings.gradle @@ -13,6 +13,7 @@ rootProject.name = 'vro_mocks' include ':rabbitmq-dev-tools' include ':mock-bie-kafka' +include ':mock-bie-schema-registry' include ':mock-bip-shared' include ':mock-bip-ce-api' include ':mock-bip-claims-api'