Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

19.1 - docker infra #73

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions docker-compose-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,8 @@
source ./docker.properties
export PROFILE=docker
export PREFIX="${IMAGE_PREFIX}"
export FRONT_VERSION="2.1.0"
export ARCH=$(uname -m)

echo '### Java version ###'
java --version

if [[ "$1" = "gql" ]]; then
export FRONT="niffler-ng-gql-client"
else
export FRONT="niffler-ng-client"
fi

docker compose down

docker_containers=$(docker ps -a -q)
docker_images=$(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'niffler')

Expand All @@ -30,8 +18,10 @@ if [ ! -z "$docker_images" ]; then
docker rmi $docker_images
fi

echo '### Java version ###'
java --version
bash ./gradlew clean
if [ "$1" = "push" ] || [ "$2" = "push" ]; then
if [ "$1" = "push" ]; then
echo "### Build & push images ###"
bash ./gradlew jib -x :niffler-e-2-e-tests:test
docker compose push frontend.niffler.dc
Expand Down
13 changes: 4 additions & 9 deletions docker-compose-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
#!/bin/bash
source ./docker.properties
export COMPOSE_PROFILES=test
export PROFILE=docker
export PREFIX="${IMAGE_PREFIX}"

export ALLURE_DOCKER_API=http://allure:5050/
export HEAD_COMMIT_MESSAGE="local build"
export FRONT_VERSION="2.1.0"
export COMPOSE_PROFILES=test
export ARCH=$(uname -m)

echo '### Java version ###'
java --version

if [[ "$1" = "gql" ]]; then
export FRONT="niffler-ng-gql-client"
else
export FRONT="niffler-ng-client"
fi

docker compose down

docker_containers=$(docker ps -a -q)
docker_images=$(docker images --format '{{.Repository}}:{{.Tag}}' | grep 'niffler')

Expand All @@ -33,6 +26,8 @@ if [ ! -z "$docker_images" ]; then
docker rmi $docker_images
fi

echo '### Java version ###'
java --version
bash ./gradlew clean
bash ./gradlew jibDockerBuild -x :niffler-e-2-e-tests:test

Expand Down
19 changes: 13 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ services:
- PGTZ=GMT+3
volumes:
- ./postgres/script:/docker-entrypoint-initdb.d
- ./postgres/conf/postgresql.conf:/etc/postgresql.conf
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres", "-d", "postgres" ]
interval: 3s
timeout: 3s
retries: 5
ports:
- 5432:5432
command: [ "postgres", "-c", "max_prepared_transactions=100" ]
networks:
- niffler-network

Expand Down Expand Up @@ -124,13 +124,12 @@ services:

frontend.niffler.dc:
container_name: frontend.niffler.dc
image: ${PREFIX}/${FRONT}-docker:latest
image: ${PREFIX}/niffler-ng-client-docker:latest
build:
context: ./${FRONT}
context: ./niffler-ng-client
dockerfile: ./Dockerfile
args:
NPM_COMMAND: build:docker
VERSION: ${FRONT_VERSION}
ports:
- 80:80
depends_on:
Expand All @@ -151,7 +150,7 @@ services:
environment:
- TZ=Europe/Moscow
restart: unless-stopped
command: [ "-conf", "/etc/selenoid/browsers.json", "-limit", "3", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs", "-container-network", "niffler_niffler-network" ]
command: [ "-conf", "/etc/selenoid/browsers.json", "-limit", "3", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs", "-container-network", "niffler-ng_niffler-network" ]
ports:
- 4444:4444
networks:
Expand Down Expand Up @@ -184,6 +183,8 @@ services:
- BUILD_URL=${BUILD_URL}
- HEAD_COMMIT_MESSAGE=${HEAD_COMMIT_MESSAGE}
- EXECUTION_TYPE=${EXECUTION_TYPE}
volumes:
- allure-results:/niffler/niffler-e-2-e-tests/build/allure-results
depends_on:
frontend.niffler.dc:
condition: service_started
Expand All @@ -197,8 +198,10 @@ services:
depends_on:
- niffler-e-2-e
environment:
- CHECK_RESULTS_EVERY_SECONDS=NONE
- CHECK_RESULTS_EVERY_SECONDS=5
- KEEP_HISTORY=1
volumes:
- allure-results:/app/allure-results
ports:
- 5050:5050
networks:
Expand All @@ -220,3 +223,7 @@ services:
networks:
niffler-network:
driver: bridge

volumes:
allure-results:
external: true
2 changes: 1 addition & 1 deletion niffler-e-2-e-tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ COPY ./build.gradle ./
COPY ./settings.gradle ./
COPY ./gradle.properties ./

CMD ./gradlew test -Dtest.env=docker -Drepository=jpa -Duser.timezone=Europe/Moscow
CMD ./gradlew test -Dtest.env=docker -Duser.timezone=Europe/Moscow
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ default int currencyGrpcPort() {
}

@Nonnull
String ghUrl();
default String ghUrl() {
return "https://api.github.com/";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,66 +10,60 @@ enum DockerConfig implements Config {
@Nonnull
@Override
public String frontUrl() {
return "";
return "http://frontend.niffler.dc/";
}

@Nonnull
@Override
public String authUrl() {
return "";
return "http://auth.niffler.dc:9000/";
}

@Nonnull
@Override
public String authJdbcUrl() {
return "";
return "jdbc:postgresql://niffler-all-db:5432/niffler-auth";
}

@Nonnull
@Override
public String gatewayUrl() {
return "";
return "http://gateway.niffler.dc:8090/";
}

@Nonnull
@Override
public String userdataUrl() {
return "";
return "http://userdata.niffler.dc:8089/";
}

@Nonnull
@Override
public String userdataJdbcUrl() {
return "";
return "jdbc:postgresql://niffler-all-db:5432/niffler-userdata";
}

@Nonnull
@Override
public String spendUrl() {
return "";
return "http://spend.niffler.dc:8093/";
}

@Nonnull
@Override
public String spendJdbcUrl() {
return "";
return "jdbc:postgresql://niffler-all-db:5432/niffler-spend";
}

@Nonnull
@Override
public String currencyJdbcUrl() {
return "";
return "jdbc:postgresql://niffler-all-db:5432/niffler-currency";
}

@NotNull
@Override
public String currencyGrpcAddress() {
return "";
}

@Nonnull
@Override
public String ghUrl() {
return "";
return "currency.niffler.dc";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,4 @@ public String currencyJdbcUrl() {
public String currencyGrpcAddress() {
return "127.0.0.1";
}

@Nonnull
@Override
public String ghUrl() {
return "https://api.github.com/";
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package guru.qa.niffler.jupiter.extension;

import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.WebDriverRunner;
import com.codeborne.selenide.logevents.SelenideLogger;
Expand All @@ -12,6 +13,7 @@
import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.chrome.ChromeOptions;

import java.io.ByteArrayInputStream;

Expand All @@ -21,6 +23,17 @@ public class BrowserExtension implements
TestExecutionExceptionHandler,
LifecycleMethodExecutionExceptionHandler {

static {
Configuration.browser = "chrome";
Configuration.timeout = 8000;
Configuration.pageLoadStrategy = "eager";
if ("docker".equals(System.getProperty("test.env"))) {
Configuration.remote = "http://selenoid:4444/wd/hub";
Configuration.browserVersion = "127.0";
Configuration.browserCapabilities = new ChromeOptions().addArguments("--no-sandbox");
}
}

@Override
public void afterEach(ExtensionContext context) throws Exception {
if (WebDriverRunner.hasWebDriverStarted()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
import guru.qa.niffler.config.Config;
import guru.qa.niffler.jupiter.annotation.ApiLogin;
import guru.qa.niffler.jupiter.annotation.Token;
import guru.qa.niffler.model.rest.UserJson;
import guru.qa.niffler.jupiter.extension.ApiLoginExtension;
import guru.qa.niffler.service.impl.AuthApiClient;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

@ExtendWith(ApiLoginExtension.class)
public class OAuthTest {

private static final Config CFG = Config.getInstance();
private final AuthApiClient authApiClient = new AuthApiClient();

@Test
@ApiLogin(username = "duck", password = "12345")
void oauthTest(@Token String token, UserJson user) {
System.out.println(user);
void oauthTest(@Token String token) {
Assertions.assertNotNull(token);
}
}
2 changes: 0 additions & 2 deletions niffler-ng-client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM node:22.6.0-alpine AS build
ARG NPM_COMMAND
ARG VERSION
WORKDIR /app
COPY package.json ./
RUN npm install
Expand All @@ -10,7 +9,6 @@ RUN npm run ${NPM_COMMAND}
# release step
FROM nginx:1.27.1-alpine AS release
LABEL maintainer="Irina Stiazhkina @irin_alexis"
LABEL version=${VERSION}
ENV TZ=Europe/Moscow
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=build /app/dist /usr/share/nginx/html/
Expand Down
2 changes: 0 additions & 2 deletions postgres/conf/postgresql.conf

This file was deleted.