Skip to content

Commit

Permalink
Bump to rc5 (#19)
Browse files Browse the repository at this point in the history
* Bump to rc5

Signed-off-by: Bogdan Vaneev <[email protected]>

* Add script to build and push tag

Signed-off-by: Bogdan Vaneev <[email protected]>

* Fix tag

Signed-off-by: Bogdan Vaneev <[email protected]>

* Remove --info from travis

Signed-off-by: Bogdan Vaneev <[email protected]>
  • Loading branch information
Warchant authored Mar 21, 2019
1 parent 5c68c51 commit 230010c
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:
secure: fKXekuaFWyMO+zEDMaRQ4gQApjunjKDqovNbCPFg/th1oGz7I6xJZB18PgLVN8659gZGREwoIVvijU9MJ6U/Ej+o840D0eosF4QQPDANhQ9kKCNLe22Jv3Co6PK+ENltm9KPP31dsIVRiuhoe3vXGgg5iotYSj+8atVl7cCQl0+j0TirKd/Nfs4Vbe6eiQNGCZK+TPKQMla1fvRurBxUJ/2VeCyThP7lIY93Qbm+PiIok7gTw0bFWvzGHqc6a7VOScCr3b00ruIK0k4CAR0klWw7ICP9n7cPJOzvGW45wAhYVcgON2o9TCxwNqOLotLTeQP4QihIQ5GSFaol3vVD7SsnkyZ03YIF8ZlZiWd5+MpPdShvJ586WPyY9drOaZPP8CnOyuD0le0vlmrLo11kCbNKizRaLYr9XrbM4lDSVHwOw8YS/Nhg24pJp7Bh/e3ULyuyNh2lQ6Q1xdeYHzZRUTUBBIgpU5UL0+4skg06lsD4uJSnlyQqBQk/WbraGPwncf/i03v+AHkSHWctUSI6nSHr641GfQnXqunXcI0KWrH22KI0rlEblzjJHHMP5MLvQyMoWDnPhQZS6Ci6dpZpooaZxibf+7OfrCi45uH2V17kedDOX4TPt6b2by7PPwV+7GwdE8IDPA3eBnAvdK0mYxHTSuxWwJtSUsA/DX5SrwA=
script:
- "./gradlew --daemon"
- "./gradlew build --parallel --build-cache --info"
- "./gradlew build --parallel --build-cache"
- "./gradlew jacocoTestReport"
- bash <(curl -s https://codecov.io/bash) -t ${CODECOV_TOKEN}
after_success:
Expand Down
2 changes: 1 addition & 1 deletion testcontainers/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hyperledger/iroha:1.0.0_rc4-hotfix1
FROM hyperledger/iroha:1.0.0_rc5
WORKDIR /opt/iroha_data
ENTRYPOINT [""]
COPY run-iroha.sh wait-for-it.sh /
Expand Down
6 changes: 6 additions & 0 deletions testcontainers/docker/build_and_push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

export TAG=warchantua/iroha:1.0.0_rc5

docker build -t $TAG --compress --squash .
docker push $TAG
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.net.URI;
import java.time.Duration;
import jp.co.soramitsu.iroha.java.IrohaAPI;
import jp.co.soramitsu.iroha.testcontainers.detail.LoggerConfig;
import jp.co.soramitsu.iroha.testcontainers.detail.PostgresConfig;
import jp.co.soramitsu.iroha.testcontainers.detail.Verbosity;
import lombok.Getter;
Expand Down Expand Up @@ -35,7 +36,7 @@ public class IrohaContainer extends FailureDetectingExternalResource implements
public static final String defaultPostgresAlias = "iroha.postgres";
public static final String defaultIrohaAlias = "iroha";
public static final String irohaWorkdir = "/opt/iroha_data";
public static final String defaultIrohaDockerImage = "warchantua/iroha:1.0.0_rc4-hotfix1";
public static final String defaultIrohaDockerImage = "warchantua/iroha:1.0.0_rc5";
public static final String defaultPostgresDockerImage = "postgres:11-alpine";

// env vars
Expand All @@ -44,7 +45,7 @@ public class IrohaContainer extends FailureDetectingExternalResource implements
private static final String KEY = "KEY";
private static final String VERBOSITY = "VERBOSITY";

private Verbosity verbosity = Verbosity.INFO;
private String verbosity = Verbosity.CONFIG_FILE;
private String irohaAlias = defaultIrohaAlias;
private String irohaDockerImage = defaultIrohaDockerImage;
private String postgresAlias = defaultPostgresAlias;
Expand Down Expand Up @@ -94,7 +95,7 @@ public IrohaContainer configure() {
.withEnv(POSTGRES_HOST, postgresAlias)
.withEnv(POSTGRES_USER, postgresDockerContainer.getUsername())
.withEnv("WAIT_TIMEOUT", "0") // don't wait for postgres
.withEnv(VERBOSITY, String.valueOf(verbosity.getLevel()))
.withEnv(VERBOSITY, verbosity)
.withNetwork(network)
.withExposedPorts(conf.getIrohaConfig().getTorii_port())
.withFileSystemBind(conf.getDir().getAbsolutePath(), irohaWorkdir, READ_ONLY)
Expand Down Expand Up @@ -125,7 +126,13 @@ public IrohaContainer withPeerConfig(@NonNull PeerConfig conf) {
* Setter for irohad verbosity.
*/
public IrohaContainer withVerbosity(Verbosity verbosity) {
this.verbosity = verbosity;
this.verbosity = verbosity.getLevel();
return this;
}

public IrohaContainer withLoggerConfig(LoggerConfig loggerConfig) {
this.verbosity = Verbosity.CONFIG_FILE;
this.conf.getIrohaConfig().setLog(loggerConfig);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static java.nio.charset.StandardCharsets.UTF_8;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.protobuf.util.JsonFormat;
import iroha.protocol.BlockOuterClass;
Expand All @@ -14,6 +15,7 @@
import javax.xml.bind.DatatypeConverter;
import jp.co.soramitsu.iroha.testcontainers.detail.GenesisBlockBuilder;
import jp.co.soramitsu.iroha.testcontainers.detail.IrohaConfig;
import jp.co.soramitsu.iroha.testcontainers.detail.LoggerConfig;
import jp.co.soramitsu.iroha.testcontainers.detail.RuntimeIOException;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -33,6 +35,8 @@
public class PeerConfig {

public static final String peerKeypairName = "iroha_peer_key";
private static final ObjectMapper mapper = new ObjectMapper()
.setSerializationInclusion(Include.NON_NULL);

@Getter
private final Map<String, KeyPair> keyPairMap = new HashMap<String, KeyPair>() {{
Expand Down Expand Up @@ -65,6 +69,9 @@ public void finalize() {
.addDefaultTransaction()
.build();

@Getter
private LoggerConfig loggerConfig;

private void writeToFile(String filename, String data) throws IOException {
File file = new File(dir, filename);
PrintWriter writer = new PrintWriter(file);
Expand All @@ -77,7 +84,6 @@ private void writeKey(String filename, byte[] key) throws IOException {
}

private void writeJsonConfig() throws IOException {
ObjectMapper mapper = new ObjectMapper();
byte[] data = mapper.writeValueAsBytes(irohaConfig);
writeToFile(IrohaConfig.defaultConfigFileName, new String(data, UTF_8));
}
Expand All @@ -90,6 +96,11 @@ private void writeGenesisBlock() throws IOException {
);
}

public void writeLoggerConfig() throws IOException {
byte[] data = mapper.writeValueAsBytes(loggerConfig);
writeToFile(IrohaConfig.defaultConfigFileName, new String(data, UTF_8));
}

public PeerConfig withPeerKeyPair(KeyPair keyPair) {
return withKeyPair(peerKeypairName, keyPair);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class IrohaConfig implements Cloneable {

@Builder.Default
private int stale_stream_max_rounds = 2;

private LoggerConfig log;

@Override
public IrohaConfig clone() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package jp.co.soramitsu.iroha.testcontainers.detail;

import java.util.Map;
import lombok.Builder;
import lombok.Value;

@Builder
@Value
public class LoggerConfig {

@Builder.Default
private Verbosity level = Verbosity.INFO;

private LoggerPattern patterns;

private Map<String, LoggerConfig> children;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package jp.co.soramitsu.iroha.testcontainers.detail;

import lombok.Builder;
import lombok.Value;

@Builder
@Value
public class LoggerPattern {

private String trace;
private String debug;
private String info;
private String warn;
private String error;
private String critical;

}
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
package jp.co.soramitsu.iroha.testcontainers.detail;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum Verbosity {
TRACE(0),
DEBUG(1),
INFO(2),
WARN(3),
ERROR(4),
CRITICAL(5),
OFF(6);
TRACE("trace"),
DEBUG("debug"),
INFO("info"),
WARN("warn"),
ERROR("error"),
CRITICAL("critical");

private final int level;
@JsonValue
private final String level;

public static final String CONFIG_FILE = "config_file";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import io.reactivex.observers.TestObserver
import iroha.protocol.BlockOuterClass
import jp.co.soramitsu.iroha.java.IrohaAPI
import jp.co.soramitsu.iroha.java.Transaction
import jp.co.soramitsu.iroha.testcontainers.detail.GenesisBlockBuilder
import jp.co.soramitsu.iroha.testcontainers.detail.IrohaConfig
import jp.co.soramitsu.iroha.testcontainers.detail.Verbosity
import jp.co.soramitsu.iroha.testcontainers.detail.*
import org.testcontainers.shaded.com.fasterxml.jackson.databind.ObjectMapper
import spock.lang.Specification

Expand All @@ -20,6 +18,7 @@ class IrohaContainerTest extends Specification {
def mapper = new ObjectMapper()
def c = ir.getConf()
def d = c.getDir()
println(d)

when: "create tmp dir and dump files"
ir.configure()
Expand Down Expand Up @@ -84,4 +83,28 @@ class IrohaContainerTest extends Specification {
!ir.postgresDockerContainer.isCreated()
!ir.postgresDockerContainer.isRunning()
}

def "tree logger test"() {
given:
def consensusLog = LoggerConfig.builder().level(Verbosity.DEBUG).build()

def pattern = LoggerPattern.builder()
.info("HEHEHEHEHEHEHEHEHE %v")
.build()

def lc = LoggerConfig.builder()
.level(Verbosity.INFO)
.patterns(pattern)
.children(Collections.singletonMap("Irohad", consensusLog))
.build()

def iroha = new IrohaContainer()
.withLoggerConfig(lc)

when:
iroha.start()

then:
noExceptionThrown()
}
}

0 comments on commit 230010c

Please sign in to comment.