Skip to content

Commit

Permalink
Improve Docker Setup (polypheny#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
gartens authored Aug 3, 2023
1 parent 8052f21 commit a3b44f4
Show file tree
Hide file tree
Showing 58 changed files with 4,010 additions and 1,792 deletions.
47 changes: 0 additions & 47 deletions .github/workflows/docker.yml

This file was deleted.

24 changes: 9 additions & 15 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,27 @@ jobs:
name: Integration Tests (Java 11)
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
- name: Set env variable
run: |
echo "POLYPHENY_HOME=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Create folders for certs
run: |
mkdir $POLYPHENY_HOME/.polypheny
mkdir $POLYPHENY_HOME/.polypheny/certs
- name: Start Docker container
run: docker-compose up -d
- name: Assemble
uses: nick-invision/retry@v2
with:
max_attempts: 2
timeout_minutes: 60
command: ./gradlew assemble

- name: Build Plugins
uses: nick-invision/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemblePlugins
- name: Build Plugins
uses: nick-invision/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemblePlugins

- name: Execute integration tests for ${{ matrix.adapter }}
uses: nick-invision/retry@v2
Expand Down
21 changes: 9 additions & 12 deletions .github/workflows/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,27 @@ jobs:
name: Java ${{ matrix.java }} @ ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: Set env variable
run: |
echo "POLYPHENY_HOME=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Create folders for certs
run: |
mkdir $POLYPHENY_HOME/.polypheny
mkdir $POLYPHENY_HOME/.polypheny/certs
- name: Assemble
uses: nick-invision/retry@v2
with:
max_attempts: 2
timeout_minutes: 60
command: ./gradlew assemble
- name: Build Plugins
uses: nick-invision/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemblePlugins
- name: Build Plugins
uses: nick-invision/retry@v2
with:
max_attempts: 1
timeout_minutes: 60
command: ./gradlew assemblePlugins
- name: Execute tests
uses: nick-invision/retry@v2
with:
Expand Down
18 changes: 4 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {

plugins {
id "org.jetbrains.kotlin.jvm" version "1.5.31"
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.1"
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7"
}


Expand Down Expand Up @@ -90,16 +90,6 @@ allprojects {
options.memberLevel = JavadocMemberLevel.PRIVATE
}

task dockerTests(type: Test) {
description = 'Runs docker tests.'
group = 'verification'
useJUnit {
includeCategories 'org.polypheny.db.docker.DockerManagerTest'
}
shouldRunAfter(tasks.named('test'))
}
dockerTests.dependsOn(testClasses)

String storeName = System.getProperty("store.default") != null ? System.getProperty("store.default") : 'hsqldb'

task integrationTests(type: Test) {
Expand Down Expand Up @@ -135,12 +125,12 @@ allprojects {

dependencies {
////// PF4J
compileOnly(group: 'org.pf4j', name: 'pf4j', version: pf4jVersion) {
compileOnly(group: 'org.pf4j', name: 'pf4j', version: pf4j_version) {
exclude group: "org.slf4j"
}
annotationProcessor group: 'org.pf4j', name: 'pf4j', version: pf4jVersion
annotationProcessor group: 'org.pf4j', name: 'pf4j', version: pf4j_version

testCompileOnly(group: 'org.pf4j', name: 'pf4j', version: pf4jVersion) {
testCompileOnly(group: 'org.pf4j', name: 'pf4j', version: pf4j_version) {
exclude group: "org.slf4j"
}
}
Expand Down
2 changes: 1 addition & 1 deletion config/src/main/java/org/polypheny/db/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public abstract class Config {
private String description;

/**
* Indicated weather applying changes to this configuration element requires a restart of Polypheny-DB.
* Indicated whether applying changes to this configuration element requires a restart of Polypheny-DB.
*/
@Setter
@Getter
Expand Down
125 changes: 64 additions & 61 deletions config/src/main/java/org/polypheny/db/config/ConfigDocker.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 The Polypheny Project
* Copyright 2019-2023 The Polypheny Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,11 +17,8 @@
package org.polypheny.db.config;


import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
Expand All @@ -31,89 +28,98 @@
@Accessors(chain = true)
public class ConfigDocker extends ConfigObject {

public static final String DEFAULT_PROTOCOL = "tcp";
public static final int DEFAULT_PORT = 2376;

// SSH was introduced as a possible transport protocol for connecting to remote Docker hosts recently, it is not yet
// supported in java-docker but can be enabled as soon as this happens
public final List<String> protocols = Collections.singletonList( "tcp" );
public static final int COMMUNICATION_PORT = 7001;
public static final int HANDSHAKE_PORT = 7002;
public static final int PROXY_PORT = 7003;

@Getter
@Setter
private String alias;
@Getter
@Setter
private String host;
@Getter
@Setter
private String protocol = DEFAULT_PROTOCOL;
private String alias;
@Getter
@Setter
private int port = DEFAULT_PORT;
private String registry;
@Getter
private String username;
@Getter
private String password;
@Setter
private int communicationPort;
@Getter
@Setter
private boolean dockerRunning;
private int handshakePort;
@Getter
@Setter
private boolean usingInsecure;
private int proxyPort;


public ConfigDocker( String host, String username, String password, String alias ) {
this( idBuilder.getAndIncrement(), host, username, password, alias );
public ConfigDocker( String host, String alias ) {
this( idBuilder.getAndIncrement(), host, alias, "", COMMUNICATION_PORT, HANDSHAKE_PORT, PROXY_PORT );
}


public ConfigDocker( String host, String username, String password ) {
this( idBuilder.getAndIncrement(), host, username, password, host );
public ConfigDocker( String host, String alias, String registry, int communicationPort, int handshakePort, int proxyPort ) {
this( idBuilder.getAndIncrement(), host, alias, registry, communicationPort, handshakePort, proxyPort );
}


public ConfigDocker( int id, String host, String username, String password, String alias ) {
public ConfigDocker( int id, String host, String alias, String registry, int communicationPort, int handshakePort, int proxyPort ) {
super( "dockerConfig" + id );
this.id = id;
if ( idBuilder.get() <= id ) {
idBuilder.set( id + 1 );
}
this.host = host;
this.alias = alias;
this.username = username;
this.password = password;

this.registry = registry;
this.communicationPort = communicationPort;
this.handshakePort = handshakePort;
this.proxyPort = proxyPort;
this.webUiFormType = WebUiFormType.DOCKER_INSTANCE;
}


public static ConfigDocker fromMap( Map<String, Object> value ) {
ConfigDocker config = new ConfigDocker(
((Double) value.get( "id" )).intValue(),
Double newId = (Double) value.getOrDefault( "id", null );
if ( newId == null ) {
newId = (double) idBuilder.getAndIncrement();
}

return new ConfigDocker(
newId.intValue(),
(String) value.get( "host" ),
(String) value.getOrDefault( "username", "" ),
(String) value.getOrDefault( "password", null ),
(String) value.get( "alias" ) );
config.setDockerRunning( (Boolean) value.get( "dockerRunning" ) );
config.setPort( ((Double) value.getOrDefault( "port", DEFAULT_PORT )).intValue() );
config.setProtocol( (String) value.getOrDefault( "protocol", DEFAULT_PROTOCOL ) );
config.setUsingInsecure( (Boolean) value.get( "usingInsecure" ) );

return config;
(String) value.get( "alias" ),
(String) value.getOrDefault( "registry", "" ),
((Double) value.getOrDefault( "communicationPort", (double) COMMUNICATION_PORT )).intValue(),
((Double) value.getOrDefault( "handshakePort", (double) HANDSHAKE_PORT )).intValue(),
((Double) value.getOrDefault( "proxyPort", (double) PROXY_PORT )).intValue()
);
}


public Map<String, Object> toMap() {
Map<String, Object> m = new HashMap<>();
m.put( "id", (double) id );
m.put( "host", host );
m.put( "alias", alias );
m.put( "registry", registry );
m.put( "communicationPort", (double) communicationPort );
m.put( "handshakePort", (double) handshakePort );
m.put( "proxyPort", (double) proxyPort );

return m;
}


public Map<String, String> getSettings() {
Map<String, String> settings = new HashMap<>();

settings.put( "host", host );
settings.put( "id", String.valueOf( id ) );
settings.put( "host", host );
settings.put( "alias", alias );
settings.put( "username", username );
settings.put( "dockerRunning", String.valueOf( dockerRunning ) );
settings.put( "port", String.valueOf( port ) );
settings.put( "protocol", protocol );
settings.put( "usingInsecure", String.valueOf( usingInsecure ) );
settings.put( "registry", registry );
settings.put( "communicationPort", String.valueOf( communicationPort ) );
settings.put( "handshakePort", String.valueOf( handshakePort ) );
settings.put( "proxyPort", String.valueOf( proxyPort ) );

return settings;
}
Expand Down Expand Up @@ -171,20 +177,19 @@ void setValueFromFile( com.typesafe.config.Config conf ) {
public static Map<String, Object> parseConfigToMap( com.typesafe.config.Config conf ) {
Map<String, Object> confMap = new HashMap<>();

confMap.put( "host", conf.getString( "host" ) );
confMap.put( "id", conf.getDouble( "id" ) );
confMap.put( "host", conf.getString( "host" ) );
confMap.put( "alias", conf.getString( "alias" ) );
if ( conf.hasPath( "username" ) ) {
confMap.put( "username", conf.getString( "username" ) );
confMap.put( "registry", conf.getString( "registry" ) );
if ( conf.hasPath( "communicationPort" ) ) {
confMap.put( "communicationPort", conf.getDouble( "communicationPort" ) );
}
confMap.put( "dockerRunning", conf.getBoolean( "dockerRunning" ) );
if ( conf.hasPath( "port" ) ) {
confMap.put( "port", conf.getDouble( "port" ) );
if ( conf.hasPath( "handshakePort" ) ) {
confMap.put( "handshakePort", conf.getDouble( "handshakePort" ) );
}
if ( conf.hasPath( "protocol" ) ) {
confMap.put( "protocol", conf.getString( "protocol" ) );
if ( conf.hasPath( "proxyPort" ) ) {
confMap.put( "proxyPort", conf.getDouble( "proxyPort" ) );
}
confMap.put( "usingInsecure", conf.getBoolean( "usingInsecure" ) );

return confMap;
}
Expand All @@ -205,14 +210,12 @@ public boolean equals( Object o ) {
return false;
}
ConfigDocker that = (ConfigDocker) o;
return port == that.port &&
dockerRunning == that.dockerRunning &&
host.equals( that.host ) &&
return host.equals( that.host ) &&
alias.equals( that.alias ) &&
protocol.equals( that.protocol ) &&
usingInsecure == that.usingInsecure &&
Objects.equals( username, that.username ) &&
Objects.equals( password, that.password );
registry.equals( that.registry ) &&
communicationPort == that.communicationPort &&
handshakePort == that.handshakePort &&
proxyPort == that.proxyPort;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private void booleanList( String key, final List<Boolean> list ) {


private void dockerList( String key, final List<ConfigDocker> list ) {
this.template = new ConfigDocker( "localhost", null, null );
this.template = new ConfigDocker( "localhost", null );
this.list = list.stream().map( el -> (ConfigScalar) el ).collect( Collectors.toList() );
this.defaultList = ImmutableList.copyOf( this.list );
}
Expand Down
Loading

0 comments on commit a3b44f4

Please sign in to comment.