Skip to content

Commit

Permalink
FACT-1881 changed db to imported image and chart bump (#3307)
Browse files Browse the repository at this point in the history
* FACT-1881 changed db to imported image and chart bump

* added azurite test container changes

* compileIntegrationTest fix

* checkStyleIntegrationTest

* trying to make it similar to blobrouter

* test

* merging functions

* changes for all the other places

* checkStyleIntegrationTest

* more changes to blobserviceclient
  • Loading branch information
justiceia committed Jul 15, 2024
1 parent 3b463d3 commit 5d390d9
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 94 deletions.
2 changes: 2 additions & 0 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def component = "processor"

def channel = '#bsp-build-notices'

env.TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX = 'hmctspublic.azurecr.io/imported/'

def combinedSecrets = [
'bulk-scan-${env}': [
secret('processed-envelopes-staging-queue-send-shared-access-key',
Expand Down
2 changes: 2 additions & 0 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ def component = "processor"

def channel = '#bsp-build-notices'

env.TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX = 'hmctspublic.azurecr.io/imported/'

def secrets = [
'bulk-scan-${env}': [
secret('fortify-on-demand-username', 'FORTIFY_USER_NAME'),
Expand Down
2 changes: 2 additions & 0 deletions Jenkinsfile_parameterized
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

def channel = '#bsp-build-notices'

env.TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX = 'hmctspublic.azurecr.io/imported/'

def combinedSecrets = [
'bulk-scan-${env}': [
secret('storage-account-primary-key', 'TEST_STORAGE_ACCOUNT_KEY'),
Expand Down
6 changes: 3 additions & 3 deletions charts/bulk-scan-processor/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: bulk-scan-processor
apiVersion: v2
home: https://github.com/hmcts/bulk-scan-processor
version: 1.0.25
version: 1.0.26
description: HMCTS Bulk scan processor service
maintainers:
- name: HMCTS BSP Team
Expand All @@ -11,10 +11,10 @@ dependencies:
version: 5.2.0
repository: https://hmctspublic.azurecr.io/helm/v1/repo/
- name: servicebus
version: 1.0.4
version: 1.0.6
repository: https://hmctspublic.azurecr.io/helm/v1/repo/
condition: servicebus.enabled
- name: blobstorage
version: 2.0.0
version: 2.0.1
repository: https://hmctspublic.azurecr.io/helm/v1/repo/
condition: blobstorage.enabled
2 changes: 1 addition & 1 deletion docker/database/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM postgres:15
FROM hmctspublic.azurecr.io/imported/postgres:16-alpine

MAINTAINER "HMCTS BSP <https://github.com/hmcts>"
LABEL maintainer = "HMCTS BSP <https://github.com/hmcts>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.GenericContainer;
import uk.gov.hmcts.reform.authorisation.validators.AuthTokenValidator;
import uk.gov.hmcts.reform.bulkscanprocessor.config.BlobManagementProperties;
import uk.gov.hmcts.reform.bulkscanprocessor.config.ContainerMappings;
Expand Down Expand Up @@ -73,6 +73,9 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static uk.gov.hmcts.reform.bulkscanprocessor.entity.Status.UPLOADED;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.AZURE_TEST_CONTAINER;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.CONTAINER_PORT;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.EXTRACTION_HOST;

@ActiveProfiles({
IntegrationContextInitializer.PROFILE_WIREMOCK,
Expand Down Expand Up @@ -110,18 +113,17 @@ public class EnvelopeControllerTest {
private UploadEnvelopeDocumentsTask uploadTask;
private BlobContainerClient testContainer;

private static DockerComposeContainer dockerComposeContainer;
private static GenericContainer<?> dockerComposeContainer =
new GenericContainer<>(AZURE_TEST_CONTAINER).withExposedPorts(CONTAINER_PORT);

private static String dockerHost;

@BeforeAll
public static void initialize() {
File dockerComposeFile = new File("src/integrationTest/resources/docker-compose.yml");

dockerComposeContainer = new DockerComposeContainer(dockerComposeFile)
.withExposedService("azure-storage", 10000);

dockerComposeContainer.withEnv("executable", "blob");
dockerComposeContainer.withNetworkAliases(EXTRACTION_HOST);
dockerComposeContainer.start();
dockerHost = dockerComposeContainer.getServiceHost("azure-storage", 10000);
dockerHost = dockerComposeContainer.getHost();
}

@AfterAll
Expand All @@ -132,9 +134,14 @@ public static void tearDownContainer() {
@BeforeEach
public void setup() {

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.connectionString(String.format(TestStorageHelper.STORAGE_CONN_STRING, dockerHost, 10000))
.buildClient();
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.connectionString(
String.format(
TestStorageHelper.STORAGE_CONN_STRING,
dockerHost,
dockerComposeContainer.getMappedPort(CONTAINER_PORT))
)
.buildClient();

BlobManager blobManager = new BlobManager(blobServiceClient, blobManagementProperties);
EnvelopeValidator envelopeValidator = new EnvelopeValidator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.GenericContainer;
import uk.gov.hmcts.reform.authorisation.validators.AuthTokenValidator;
import uk.gov.hmcts.reform.bulkscanprocessor.config.BlobManagementProperties;
import uk.gov.hmcts.reform.bulkscanprocessor.config.ContainerMappings;
Expand Down Expand Up @@ -64,6 +64,9 @@
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.AZURE_TEST_CONTAINER;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.CONTAINER_PORT;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.EXTRACTION_HOST;

@ActiveProfiles({
IntegrationContextInitializer.PROFILE_WIREMOCK,
Expand Down Expand Up @@ -101,18 +104,17 @@ class ZipStatusControllerTest {
private BlobContainerClient testContainer;


private static DockerComposeContainer dockerComposeContainer;
private static GenericContainer<?> dockerComposeContainer =
new GenericContainer<>(AZURE_TEST_CONTAINER).withExposedPorts(CONTAINER_PORT);

private static String dockerHost;

@BeforeAll
static void initialize() {
File dockerComposeFile = new File("src/integrationTest/resources/docker-compose.yml");

dockerComposeContainer = new DockerComposeContainer(dockerComposeFile)
.withExposedService("azure-storage", 10000);

public static void initialize() {
dockerComposeContainer.withEnv("executable", "blob");
dockerComposeContainer.withNetworkAliases(EXTRACTION_HOST);
dockerComposeContainer.start();
dockerHost = dockerComposeContainer.getServiceHost("azure-storage", 10000);
dockerHost = dockerComposeContainer.getHost();
}

@AfterAll
Expand All @@ -124,8 +126,13 @@ static void tearDownContainer() {
void setup() {

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.connectionString(String.format(TestStorageHelper.STORAGE_CONN_STRING, dockerHost, 10000))
.buildClient();
.connectionString(
String.format(
TestStorageHelper.STORAGE_CONN_STRING,
dockerHost,
dockerComposeContainer.getMappedPort(CONTAINER_PORT))
)
.buildClient();

BlobManager blobManager = new BlobManager(blobServiceClient, blobManagementProperties);
EnvelopeValidator envelopeValidator = new EnvelopeValidator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.GenericContainer;
import uk.gov.hmcts.reform.bulkscanprocessor.config.BlobManagementProperties;
import uk.gov.hmcts.reform.bulkscanprocessor.services.reports.models.RejectedFile;
import uk.gov.hmcts.reform.bulkscanprocessor.tasks.processor.BlobManager;
import uk.gov.hmcts.reform.bulkscanprocessor.util.TestStorageHelper;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.AZURE_TEST_CONTAINER;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.CONTAINER_PORT;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.EXTRACTION_HOST;

public class RejectedFilesReportServiceTest {

Expand All @@ -28,17 +30,17 @@ public class RejectedFilesReportServiceTest {
private BlobContainerClient rejectedContainer;
private BlobManager blobManager;

private static DockerComposeContainer dockerComposeContainer;
private static GenericContainer<?> dockerComposeContainer =
new GenericContainer<>(AZURE_TEST_CONTAINER).withExposedPorts(CONTAINER_PORT);

private static String dockerHost;

@BeforeAll
public static void initialize() {
dockerComposeContainer =
new DockerComposeContainer(new File("src/integrationTest/resources/docker-compose.yml"))
.withExposedService("azure-storage", 10000);

dockerComposeContainer.withEnv("executable", "blob");
dockerComposeContainer.withNetworkAliases(EXTRACTION_HOST);
dockerComposeContainer.start();
dockerHost = dockerComposeContainer.getServiceHost("azure-storage", 10000);
dockerHost = dockerComposeContainer.getHost();
}

@AfterAll
Expand All @@ -48,9 +50,12 @@ public static void tearDownContainer() {

@BeforeEach
public void setUp() {

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.connectionString(String.format(TestStorageHelper.STORAGE_CONN_STRING, dockerHost, 10000))
.connectionString(
String.format(TestStorageHelper.STORAGE_CONN_STRING,
dockerHost,
dockerComposeContainer.getMappedPort(CONTAINER_PORT))
)
.buildClient();

this.blobManager = new BlobManager(blobServiceClient, blobManagementProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.GenericContainer;
import uk.gov.hmcts.reform.bulkscanprocessor.config.IntegrationTest;
import uk.gov.hmcts.reform.bulkscanprocessor.util.TestStorageHelper;

import java.io.ByteArrayInputStream;
import java.io.File;

import static org.assertj.core.api.Assertions.assertThat;
import static uk.gov.hmcts.reform.bulkscanprocessor.helper.DirectoryZipper.zipDir;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.AZURE_TEST_CONTAINER;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.CONTAINER_PORT;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.EXTRACTION_HOST;

@IntegrationTest
class OcrValidationRetryManagerTest {
Expand All @@ -31,15 +33,22 @@ class OcrValidationRetryManagerTest {
@Autowired
private OcrValidationRetryManager ocrValidationRetryManager;

private static DockerComposeContainer dockerComposeContainer;
private static GenericContainer<?> dockerComposeContainer =
new GenericContainer<>(AZURE_TEST_CONTAINER).withExposedPorts(CONTAINER_PORT);

private static String dockerHost;

private BlobContainerClient testContainer;

@BeforeEach
void setUp() {
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.connectionString(String.format(TestStorageHelper.STORAGE_CONN_STRING, dockerHost, 10000))
.connectionString(
String.format(
TestStorageHelper.STORAGE_CONN_STRING,
dockerHost,
dockerComposeContainer.getMappedPort(CONTAINER_PORT))
)
.buildClient();

testContainer = blobServiceClient.getBlobContainerClient(CONTAINER_NAME);
Expand All @@ -57,13 +66,10 @@ void cleanUp() {

@BeforeAll
static void initialize() {
File dockerComposeFile = new File("src/integrationTest/resources/docker-compose.yml");

dockerComposeContainer = new DockerComposeContainer(dockerComposeFile)
.withExposedService("azure-storage", 10000);

dockerComposeContainer.withEnv("executable", "blob");
dockerComposeContainer.withNetworkAliases(EXTRACTION_HOST);
dockerComposeContainer.start();
dockerHost = dockerComposeContainer.getServiceHost("azure-storage", 10000);
dockerHost = dockerComposeContainer.getHost();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.testcontainers.containers.DockerComposeContainer;
import org.testcontainers.containers.GenericContainer;
import uk.gov.hmcts.reform.bulkscanprocessor.config.BlobManagementProperties;
import uk.gov.hmcts.reform.bulkscanprocessor.config.IntegrationTest;
import uk.gov.hmcts.reform.bulkscanprocessor.services.storage.LeaseAcquirer;
import uk.gov.hmcts.reform.bulkscanprocessor.tasks.processor.BlobManager;
import uk.gov.hmcts.reform.bulkscanprocessor.util.TestStorageHelper;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
Expand All @@ -27,6 +26,9 @@

import static org.assertj.core.api.Assertions.assertThat;
import static uk.gov.hmcts.reform.bulkscanprocessor.services.storage.LeaseMetaDataChecker.LEASE_EXPIRATION_TIME;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.AZURE_TEST_CONTAINER;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.CONTAINER_PORT;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.AzureHelper.EXTRACTION_HOST;
import static uk.gov.hmcts.reform.bulkscanprocessor.util.TimeZones.EUROPE_LONDON_ZONE_ID;

@IntegrationTest
Expand All @@ -44,17 +46,17 @@ public class CleanUpRejectedFilesTaskTest {

private BlobManager blobManager;

private static DockerComposeContainer dockerComposeContainer;
private static GenericContainer<?> dockerComposeContainer =
new GenericContainer<>(AZURE_TEST_CONTAINER).withExposedPorts(CONTAINER_PORT);

private static String dockerHost;

@BeforeAll
public static void initialize() {
dockerComposeContainer =
new DockerComposeContainer(new File("src/integrationTest/resources/docker-compose.yml"))
.withExposedService("azure-storage", 10000);

dockerComposeContainer.withEnv("executable", "blob");
dockerComposeContainer.withNetworkAliases(EXTRACTION_HOST);
dockerComposeContainer.start();
dockerHost = dockerComposeContainer.getServiceHost("azure-storage", 10000);
dockerHost = dockerComposeContainer.getHost();
}

@AfterAll
Expand All @@ -63,9 +65,14 @@ public static void tearDownContainer() {
}

@BeforeEach
public void setUp() throws Exception {
public void setUp() {
blobServiceClient = new BlobServiceClientBuilder()
.connectionString(String.format(TestStorageHelper.STORAGE_CONN_STRING, dockerHost, 10000))
.connectionString(
String.format(
TestStorageHelper.STORAGE_CONN_STRING,
dockerHost,
dockerComposeContainer.getMappedPort(CONTAINER_PORT))
)
.buildClient();

this.blobManager = new BlobManager(blobServiceClient, blobManagementProperties);
Expand Down
Loading

0 comments on commit 5d390d9

Please sign in to comment.