diff --git a/CHANGELOG.md b/CHANGELOG.md index 90d4411..1213d67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,10 @@ All notable changes to this project will be documented in this file. - Reindent `build.gradle` file. (#114) - Standardisation of the dockerfile and its location in regard to other java components. (#115) +### Dependency Upgrades + +- Upgrade to `jenkins-library` 2.7.4. (#116) + ## [[8.2.0]](https://github.com/iExecBlockchainComputing/iexec-blockchain-adapter-api/releases/tag/v8.2.0) 2023-09-28 ### Bug Fixes diff --git a/Jenkinsfile b/Jenkinsfile index dc4205f..842de7a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,5 @@ -@Library('global-jenkins-library@2.7.3') _ +@Library('global-jenkins-library@2.7.4') _ buildJavaProject( - buildInfo: getBuildInfo(), integrationTestsEnvVars: ['BROKER_PRIVATE_KEY'], shouldPublishJars: true, - shouldPublishDockerImages: true, - dockerfileDir: '.', - buildContext: '.') + shouldPublishDockerImages: true) diff --git a/build.gradle b/build.gradle index 45e9c35..b8d7c1f 100644 --- a/build.gradle +++ b/build.gradle @@ -39,8 +39,10 @@ allprojects { } java { toolchain { - languageVersion.set(JavaLanguageVersion.of(11)) + languageVersion.set(JavaLanguageVersion.of(17)) } + sourceCompatibility = '11' + targetCompatibility = '11' } } @@ -152,6 +154,5 @@ tasks.register('buildImage', Exec) { group 'Build' description 'Builds an OCI image from a Dockerfile.' dependsOn bootJar - commandLine("sh", "-c", "docker build --build-arg jar=$jarPathForOCI -t $ociImageName:$gitShortCommit ." - + " && docker tag $ociImageName:$gitShortCommit $ociImageName:dev") + commandLine 'docker', 'build', '--build-arg', 'jar=' + jarPathForOCI, '-t', ociImageName + ':dev', '.' } diff --git a/iexec-blockchain-adapter-api-library/build.gradle b/iexec-blockchain-adapter-api-library/build.gradle index 4ed991b..6cf8c95 100644 --- a/iexec-blockchain-adapter-api-library/build.gradle +++ b/iexec-blockchain-adapter-api-library/build.gradle @@ -13,6 +13,8 @@ dependencies { } java { + sourceCompatibility = '11' + targetCompatibility = '11' withJavadocJar() withSourcesJar() } diff --git a/src/itest/java/com/iexec/blockchain/IntegrationTests.java b/src/itest/java/com/iexec/blockchain/IntegrationTests.java index 0f4d0da..11babe6 100644 --- a/src/itest/java/com/iexec/blockchain/IntegrationTests.java +++ b/src/itest/java/com/iexec/blockchain/IntegrationTests.java @@ -49,7 +49,7 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; -import org.testcontainers.containers.DockerComposeContainer; +import org.testcontainers.containers.ComposeContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -74,9 +74,14 @@ @Slf4j @Testcontainers @ActiveProfiles("itest") -@SpringBootTest(properties = { "chain.max-allowed-tx-per-block=2"}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(properties = {"chain.max-allowed-tx-per-block=2"}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class IntegrationTests { + private static final String CHAIN_SVC_NAME = "ibaa-chain"; + private static final int CHAIN_SVC_PORT = 8545; + private static final String MONGO_SVC_NAME = "ibaa-blockchain-adapter-mongo"; + private static final int MONGO_SVC_PORT = 13012; + public static final String USER = "admin"; public static final String PASSWORD = "whatever"; public static final int BLOCK_TIME_MS = 5000; @@ -86,44 +91,50 @@ class IntegrationTests { public static final int MAX_POLLING_ATTEMPTS = MAX_BLOCK_TO_WAIT * POLLING_PER_BLOCK; @Container - static DockerComposeContainer environment = new DockerComposeContainer<>(new File("docker-compose.yml")) - .withExposedService("ibaa-chain", 8545, Wait.forListeningPort()) - .withExposedService("ibaa-blockchain-adapter-mongo", 13012, Wait.forListeningPort()); + static ComposeContainer environment = new ComposeContainer(new File("docker-compose.yml")) + .withPull(true) + .withExposedService(CHAIN_SVC_NAME, CHAIN_SVC_PORT, Wait.forListeningPort()) + .withExposedService(MONGO_SVC_NAME, MONGO_SVC_PORT, Wait.forListeningPort()); @DynamicPropertySource static void registerProperties(DynamicPropertyRegistry registry) { registry.add("chain.id", () -> "65535"); registry.add("chain.hubAddress", () -> "0xC129e7917b7c7DeDfAa5Fff1FB18d5D7050fE8ca"); - registry.add("chain.nodeAddress", () -> getServiceUrl(environment.getServicePort("ibaa-chain", 8545))); - registry.add("spring.data.mongodb.port", () -> environment.getServicePort("ibaa-blockchain-adapter-mongo", 13012)); + registry.add("chain.nodeAddress", () -> getServiceUrl( + environment.getServiceHost(CHAIN_SVC_NAME, CHAIN_SVC_PORT), + environment.getServicePort(CHAIN_SVC_NAME, CHAIN_SVC_PORT))); + registry.add("sprint.data.mongodb.host", () -> environment.getServiceHost(MONGO_SVC_NAME, MONGO_SVC_PORT)); + registry.add("spring.data.mongodb.port", () -> environment.getServicePort(MONGO_SVC_NAME, MONGO_SVC_PORT)); } @LocalServerPort private int randomServerPort; - @Autowired - private IexecHubService iexecHubService; - - @Autowired - private CredentialsService credentialsService; - - @Autowired - private BrokerService brokerService; + private final IexecHubService iexecHubService; + private final CredentialsService credentialsService; + private final BrokerService brokerService; + private final ChainConfig chainConfig; + private BlockchainAdapterApiClient appClient; @Autowired - private ChainConfig chainConfig; - private BlockchainAdapterApiClient appClient; + IntegrationTests(IexecHubService iexecHubService, CredentialsService credentialsService, + BrokerService brokerService, ChainConfig chainConfig) { + this.iexecHubService = iexecHubService; + this.credentialsService = credentialsService; + this.brokerService = brokerService; + this.chainConfig = chainConfig; + } @BeforeEach void setUp(TestInfo testInfo) { log.info(">>> {}", testInfo.getDisplayName()); appClient = BlockchainAdapterApiClientBuilder - .getInstanceWithBasicAuth(Logger.Level.FULL, getServiceUrl(randomServerPort), USER, PASSWORD); + .getInstanceWithBasicAuth(Logger.Level.FULL, getServiceUrl("localhost", randomServerPort), USER, PASSWORD); } - private static String getServiceUrl(int servicePort) { - log.info("service url http://localhost:{}", servicePort); - return "http://localhost:" + servicePort; + private static String getServiceUrl(String serviceHost, int servicePort) { + log.info("service url http://{}:{}", serviceHost, servicePort); + return "http://" + serviceHost + ":" + servicePort; } @Test @@ -142,7 +153,7 @@ public void shouldBeFinalized() throws Exception { String enclaveSignature = BytesUtils.bytesToString(new byte[65]); WorkerpoolAuthorization workerpoolAuthorization = mockAuthorization(chainTaskId, enclaveChallenge); - receipt = iexecHubService.contribute( + receipt = iexecHubService.contribute( chainTaskId, someBytes32Payload, workerpoolAuthorization.getSignature().getValue(), @@ -150,7 +161,7 @@ public void shouldBeFinalized() throws Exception { enclaveSignature); log.info("contribute {}", receipt); waitStatus(chainTaskId, ChainTaskStatus.REVEALING, - MAX_POLLING_ATTEMPTS); + MAX_POLLING_ATTEMPTS); receipt = iexecHubService.reveal(chainTaskId, someBytes32Payload); log.info("reveal {}", receipt); @@ -161,7 +172,7 @@ public void shouldBeFinalized() throws Exception { Assertions.assertTrue(StringUtils.isNotEmpty(finalizeResponseBody)); log.info("Requested task finalize: {}", finalizeResponseBody); waitStatus(chainTaskId, ChainTaskStatus.COMPLETED, - MAX_POLLING_ATTEMPTS); + MAX_POLLING_ATTEMPTS); } @Test @@ -183,7 +194,7 @@ public void shouldBurstTransactionsWithAverageOfOneTxPerBlock() { //maximum waiting time equals nb of submitted txs //1 tx/block means N txs / N blocks waitStatus(chainTaskId, ACTIVE, - (taskVolume / 2 + 2) * MAX_POLLING_ATTEMPTS); + (taskVolume / 2 + 2) * MAX_POLLING_ATTEMPTS); //no need to wait for propagation update in db Assertions.assertTrue(true); } catch (Exception e) { @@ -206,7 +217,7 @@ private String triggerDeal(int taskVolume) { secondsTimeout, secondsPollingInterval); log.info("Created app: {}", appAddress); String workerpool = iexecHubService.createWorkerpool(buildRandomName("pool"), - secondsTimeout, secondsPollingInterval); + secondsTimeout, secondsPollingInterval); log.info("Created workerpool: {}", workerpool); String datasetAddress = iexecHubService.createDataset(buildRandomName("data"), "https://abc.com/def.jpeg", @@ -299,7 +310,7 @@ private RequestOrder buildRequestOrder( boolean isCompatibleVolume = appOrder.getVolume().equals(workerpoolOrder.getVolume()) && appOrder.getVolume().equals(datasetOrder.getVolume()); - if (!isCompatibleVolume){ + if (!isCompatibleVolume) { log.info("Volumes are not compatible"); return null; }