Commit 9782f15e authored by Jujube Orange's avatar Jujube Orange
Browse files

Merge branch 'develop'

parents 63f68df6 d878c89c
Pipeline #327174 passed with stages
in 42 minutes and 28 seconds
......@@ -16,7 +16,7 @@ FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
echo "$FILES" | xargs prettier --ignore-unknown --write
# Spotlessify java source files
./mvnw spotless:apply
mvn spotless:apply
# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add
......
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
VERSIONING_DISABLE: "false"
VERSIONING_GIT_TAG: $CI_COMMIT_TAG
VERSIONING_GIT_BRANCH: $CI_COMMIT_BRANCH
ANSIBLE_DEPLOY_PROJECT: clea/clea-ansible
default:
cache:
paths:
- .m2/repository/
tags:
- qlf-ci.inria.fr
include:
- project: stopcovid19/accueil
file: gitlab/gitlab-ci-java-template.yml
stages:
- build
- integration-tests
build:
image: maven:3.6.3-adoptopenjdk-11
stage: build
script:
- mvn -B -s .mvn/settings-ci.xml -ntp -fae -DdeployAtEnd spotless:check deploy
artifacts:
paths:
- "**/target/*.jar"
reports:
junit:
- "**/target/surefire-reports/TEST-*.xml"
integration-tests:
image: registry.gitlab.inria.fr/stemcovid19/tac-server/docker-image/tac-system-tests:latest
stage: integration-tests
before_script:
- export PATH="$PWD/docker-compose:$PATH"
- export CLEA_ROOT_DIR=$CI_PROJECT_DIR
e2e-tests-docker:
script:
- currentContainer=$(basename $(cat /proc/1/cpuset))
- docker-compose up -d
- docker network connect clea-server_default $currentContainer
- echo "Waiting for clea-ws-rest component to be up..."
- until curl -s http://clea-ws-rest:8080/actuator/health | grep -q UP; do sleep 0.5; done;
- java -jar -Dspring.profiles.active=docker clea-integration-tests/target/clea-integration-tests-*.jar
- docker network disconnect clea-server_default $currentContainer
- docker-compose down
artifacts:
paths:
- "$CI_PROJECT_DIR/target/cucumber-reports.html"
expire_in: 2 weeks
FROM centos:7 AS installer
# Install all the locales
RUN sed -i 's/^override_install_langs=.*$/override_install_langs=fr_FR/g' /etc/yum.conf \
&& yum -y update \
......@@ -15,13 +14,12 @@ ENV LC_ALL fr_FR.utf8
ENV LANG fr_FR.utf8
ENV PATH $PATH:~/.local/bin
WORKDIR /tmp
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
&& unzip awscliv2.zip \
&& unzip -q awscliv2.zip \
&& ./aws/install -i /usr/local/aws-cli -b /usr/local/bin \
&& rm awscliv2.zip rm -rf aws
&& rm awscliv2.zip \
&& rm -rf aws
WORKDIR /home/javaapp
......@@ -34,13 +32,6 @@ COPY ./target/clea*-exec.jar ./clea-batch.jar
COPY ./src/main/scripts/* ./
COPY ./src/main/docker/aws ./.aws
USER root
RUN chmod +x *.sh \
&& mkdir /logs \
&& touch /logs/clea-batch.log \
&& touch /logs/clea-batch.error.log \
&& chmod a+rw /logs/*.log
USER javaapp
CMD [ "./clea-batch-console.sh" ]
......@@ -5,8 +5,9 @@ _die() { echo "`date "+%Y-%m-%d %T.999"` ERROR 0 --- [ clea-batch] clea-bat
# redirect logs to log file
CLEA_BATCH_LOG_FILE_PATH=${CLEA_BATCH_LOG_FILE_PATH:-/logs}
CLEA_BATCH_LOG_FILE_NAME=${CLEA_BATCH_LOG_FILE_NAME:-clea-batch}
test -f "${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.log" || _die "log file: ${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.log does not exist"
test -f "${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.error.log" || _die "error log file: ${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.error.log does not exist"
mkdir -p "$CLEA_BATCH_LOG_FILE_PATH" || _die "can't create log dir: $CLEA_BATCH_LOG_FILE_PATH"
touch "${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.log" || _die "can't create log file: ${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.log"
touch "${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.error.log" || _die "can't create log file: ${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.error.log"
exec >> "${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.log"
exec 2>> "${CLEA_BATCH_LOG_FILE_PATH}/${CLEA_BATCH_LOG_FILE_NAME}.error.log"
......
File mode changed from 100644 to 100755
flyway.connectRetries=60
\ No newline at end of file
......@@ -2,7 +2,7 @@ version: "3"
services:
flyway:
image: flyway/flyway:7.8
#command: migrate
#command: migrate -connectRetries=60
#command: migrate -baselineOnMigrate=true -baselineVersion=4
entrypoint: ["tail", "-f", "/dev/null"]
environment:
......@@ -10,8 +10,7 @@ services:
FLYWAY_USER: postgres
FLYWAY_PASSWORD: password
volumes:
- ../conf/:/flyway/conf
- ../sql/:/flyway/sql
- ../src/main/resources/db/migrations:/flyway/sql
depends_on:
- postgres
......
<?xml version="1.0" encoding="UTF-8" ?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>clea-server</artifactId>
<groupId>fr.gouv.clea</groupId>
<version>0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>clea-dbmigration</artifactId>
<dependencies>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
</dependencies>
</project>
......@@ -4,11 +4,27 @@ import org.junit.runner.JUnitCore;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.awaitility.Awaitility.await;
import static org.awaitility.pollinterval.FibonacciPollInterval.fibonacci;
import static org.hamcrest.Matchers.is;
@SpringBootApplication
@ConfigurationPropertiesScan
public class CleaIntegrationTestsApplication {
public static void main(String[] args) {
JUnitCore.main(CucumberTest.class.getName());
var exitCode = 1;
try {
await("clea platform is ready")
.atMost(3, MINUTES)
.pollInterval(fibonacci(SECONDS))
.until(() -> JUnitCore.runClasses(SmokeTests.class).wasSuccessful(), is(true));
exitCode = JUnitCore.runClasses(CucumberTest.class).wasSuccessful() ? 0 : 1;
} finally {
System.exit(exitCode);
}
}
}
......@@ -5,6 +5,7 @@ import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(features = { "classpath:features" }, plugin = { "pretty", "html:target/cucumber-reports.html" })
@CucumberOptions(tags = "not @smoke", features = "classpath:features", plugin = { "pretty",
"html:target/cucumber-reports.html" })
public class CucumberTest {
}
package fr.gouv.clea.integrationtests;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(tags = "@smoke", features = "classpath:features", plugin = "pretty")
public class SmokeTests {
}
......@@ -20,11 +20,11 @@ import java.util.function.Predicate;
@ScenarioScope
public class ScenarioContext {
private final Map<String, Visitor> visitors = new HashMap<>(10);
private final Map<String, Visitor> visitors = new HashMap<>();
private final Map<String, LocationQrCodeGenerator> locations = new HashMap<>(10);
private final Map<String, LocationQrCodeGenerator> locations = new HashMap<>();
private final Map<String, LocationQrCodeGenerator> staffLocations = new HashMap<>(10);
private final Map<String, LocationQrCodeGenerator> staffLocations = new HashMap<>();
private final ApplicationProperties applicationProperties;
......
......@@ -136,7 +136,7 @@ public class CleaReportSteps {
.then()
.contentType(ContentType.JSON)
.statusCode(200)
.body("message", equalTo("0 reports processed, 1 rejected"))
.body("message", equalTo("0/1 accepted visits"))
.extract()
.as(WreportResponse.class);
visitor.setLastReportResponse(response);
......@@ -158,8 +158,8 @@ public class CleaReportSteps {
.post(cleaReportUrl)
.then()
.contentType(ContentType.JSON)
.statusCode(400)
.body("message", equalTo("Invalid request"));
.statusCode(200)
.body("message", equalTo("0/1 accepted visits"));
}
@Then("{word} has {int} rejected visit(s)")
......
......@@ -24,8 +24,8 @@ public class CleaVisitorUserSteps {
public void visitor_scans_qrcode_at_given_instant(String visitorName, String locationName, Instant qrCodeScanTime)
throws CleaCryptoException {
final var location = this.scenarioContext.getLocation(locationName);
final var deepLink = location.getQrCodeAt(qrCodeScanTime);
this.scenarioContext.getOrCreateUser(visitorName).registerDeepLink(deepLink.getQrCode(), qrCodeScanTime);
final var qrCode = location.getQrCodeAt(qrCodeScanTime);
this.scenarioContext.getOrCreateUser(visitorName).registerDeepLink(qrCode.getDeepLink(), qrCodeScanTime);
}
// Visitor scan a staff QR code at given instant
......@@ -33,8 +33,8 @@ public class CleaVisitorUserSteps {
public void visitor_scans_staff_qrcode_at_given_instant(String visitorName, String locationName,
Instant qrCodeScanTime) throws CleaCryptoException {
final var location = this.scenarioContext.getStaffLocation(locationName);
final var qr = location.getQrCodeAt(qrCodeScanTime);
this.scenarioContext.getOrCreateUser(visitorName).registerDeepLink(qr.getQrCode(), qrCodeScanTime);
final var qrCode = location.getQrCodeAt(qrCodeScanTime);
this.scenarioContext.getOrCreateUser(visitorName).registerDeepLink(qrCode.getDeepLink(), qrCodeScanTime);
}
// Visitor scan a QR code at a given Instant, but the scanned QR code is valid
......@@ -43,7 +43,7 @@ public class CleaVisitorUserSteps {
public void visitor_scans_qrcode_at_given_instant_but_qr_code_valid_for_another_instant(String visitorName,
String locationName, Instant qrCodeScanTime, Instant qrCodeValidTime) throws CleaCryptoException {
final var location = this.scenarioContext.getLocation(locationName);
final var qr = location.getQrCodeAt(qrCodeValidTime);
this.scenarioContext.getOrCreateUser(visitorName).registerDeepLink(qr.getQrCode(), qrCodeScanTime);
final var qrCode = location.getQrCodeAt(qrCodeValidTime);
this.scenarioContext.getOrCreateUser(visitorName).registerDeepLink(qrCode.getDeepLink(), qrCodeScanTime);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment