Skip to content

Commit

Permalink
Fixes 230215 (#159)
Browse files Browse the repository at this point in the history
* Fixed jacoco on windows
* Added further error strings for docker
* Update recording data
* Extra data saved again
* Max ROWS error...
* Fixed concurrency error
* Fixed concurrency error
* 4.1.6

---------

Co-authored-by: Kendar <unknown@kendar.org>
  • Loading branch information
kendarorg and Kendar authored Feb 16, 2023
1 parent 6a2d5c5 commit 4d46cbd
Show file tree
Hide file tree
Showing 80 changed files with 217 additions and 232 deletions.
2 changes: 1 addition & 1 deletion docker/images/apache-php8/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ham.apache

RUN echo ham.apache-php8 version-4.1.5
RUN echo ham.apache-php8 version-4.1.6

# Setup apache and php
RUN apk add --no-cache \
Expand Down
2 changes: 1 addition & 1 deletion docker/images/apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ham.client

RUN echo ham.apache version-4.1.5
RUN echo ham.apache version-4.1.6

# Setup apache and php
RUN apk --no-cache add apache2 apache2-ssl curl \
Expand Down
2 changes: 1 addition & 1 deletion docker/images/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM alpine:latest
RUN apk update
RUN apk upgrade

RUN echo ham.base version-4.1.5
RUN echo ham.base version-4.1.6

ENV JAVA11_HOME /usr/lib/jvm/java-11-openjdk

Expand Down
2 changes: 1 addition & 1 deletion docker/images/client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ham.base

RUN echo ham.client version-4.1.5
RUN echo ham.client version-4.1.6

# Setup localdns
RUN mkdir -p /etc/app/simpledns/
Expand Down
2 changes: 1 addition & 1 deletion docker/images/externalvpn/forticlient/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN \
#docker run --privileged --cap-add SYS_ADMIN --cap-add DAC_READ_SEARCH --name myvpn myvpn
FROM ham.base:latest

RUN echo ham.openforti version-4.1.5
RUN echo ham.openforti version-4.1.6

COPY --from=builder /usr/bin/openfortivpn /usr/bin/
#/go/bin/glider
Expand Down
2 changes: 1 addition & 1 deletion docker/images/externalvpn/openconnect/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM ubuntu:latest
RUN apt-get update
RUN apt-get upgrade -y

RUN echo ham.openconnect version-4.1.5
RUN echo ham.openconnect version-4.1.6

# Block timezone request prompt
ENV DEBIAN_FRONTEND="noninteractive" TZ="Europe/Rome"
Expand Down
2 changes: 1 addition & 1 deletion docker/images/master/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ham.base

RUN echo ham.master version-4.1.5
RUN echo ham.master version-4.1.6

COPY data/ham.sh /etc/app/ham/
COPY data/app /etc/app/ham/app/
Expand Down
2 changes: 1 addition & 1 deletion docker/images/mysql/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ham.client

RUN echo ham.mysql version-4.1.5
RUN echo ham.mysql version-4.1.6

ENV TIMEZONE=Europe/Paris
ENV MYSQL_ROOT_PASSWORD=root
Expand Down
2 changes: 1 addition & 1 deletion docker/images/openvpn/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ham.base


RUN echo ham.openvpn version-4.1.5
RUN echo ham.openvpn version-4.1.6

# Testing: pamtester
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing/" >> /etc/apk/repositories && \
Expand Down
2 changes: 1 addition & 1 deletion docker/images/singlemaster/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ham.master

RUN echo ham.singlemaster version-4.1.5
RUN echo ham.singlemaster version-4.1.6

COPY data/*.* /etc/app/dns/
RUN chmod +x /etc/app/dns/*.sh
Expand Down
2 changes: 1 addition & 1 deletion docker/templates/master/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM ham.singlemaster:latest
RUN echo ham.template version-4.1.5
RUN echo ham.template version-4.1.6

COPY ./config/*.json /etc/app/ham/app/
RUN mkdir -p /etc/app/app
Expand Down
18 changes: 13 additions & 5 deletions globaltest/src/main/java/org/kendar/globaltest/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ private static void startWait(String dir, String script,


private static void handleDockerErrors(String a, Process p) {
if(a.toLowerCase(Locale.ROOT).startsWith("error")){
if(a.toLowerCase(Locale.ROOT).startsWith("error") ||
a.toLowerCase(Locale.ROOT).startsWith("couldn't connect")){
System.err.println("");
System.err.println("[ERROR] "+ a);
p.destroy();
Expand Down Expand Up @@ -612,21 +613,28 @@ public static void main(String[] args) throws Exception {
private static void testAndGenerateJacoco(String startingPath, String hamVersion, String buildDir, String releasePath) throws Exception {
System.out.println("[INFO] Unit test ham & report");
startWait(pathOf(startingPath, "scripts","globaltest"), "test.run",Main::handleRunErrors);
sigtermAllHamProcesses();
if(SystemUtils.IS_OS_WINDOWS) {
checkForSite(60, "http://127.0.0.1/api/shutdown");
}else{
sigtermAllHamProcesses();
}
var path = Path.of(startingPath,"ham","api.test","target","test_run_starter.exec");
System.out.print("[INFO] Waiting for coverage data");
var now =System.currentTimeMillis();
var end = now+5*60*1000;
while(!Files.exists(path) && end>System.currentTimeMillis()){

System.out.print("[INFO] Waiting for coverage data");
while((!Files.exists(path)||Files.size(path)==0) && end>System.currentTimeMillis()){
System.out.print(".");
Thread.sleep(1000);
}
if(!Files.exists(path)) {
if(!Files.exists(path)|| Files.size(path)==0) {
System.err.println("[ERROR] Error loading jacoco reports "+path);
doExit(1);
}else{
System.out.println("OK");
}

sigtermAllHamProcesses();
startWait(pathOf(startingPath, "scripts","globaltest"), "test.jacoco",Main::handleRunErrors);
}

Expand Down
2 changes: 1 addition & 1 deletion ham/api.ham/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion ham/api.js.builder/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion ham/api.replayer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion ham/api.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion ham/app.commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion ham/app.dns/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion ham/app.http.standardfilters/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion ham/app.http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion ham/app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<artifactId>HttpAnsweringMachine</artifactId>
<groupId>org.kendar</groupId>
<version>4.1.5</version>
<version>4.1.6</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>jar</packaging>
Expand Down
22 changes: 20 additions & 2 deletions ham/app/src/main/java/org/kendar/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import org.kendar.utils.Sleeper;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;

import java.util.Arrays;
import java.util.HashMap;
Expand All @@ -20,6 +22,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;

import static java.lang.System.exit;

Expand All @@ -34,10 +37,19 @@ public static void main(String[] args) {
(hostname, sslSession) -> true);
SpringApplication app = new SpringApplication(Main.class);
app.setLazyInitialization(true);
app.run(args);
var ctx = app.run(args);
int exitCode = SpringApplication.exit(ctx, () -> 0);
exit(exitCode);
}



public static AtomicBoolean doRun = new AtomicBoolean(true);
private static Runnable shutdownHook;

public static void shutdown(){
shutdownHook.run();
}

@Override
public void run(String... args) {
Expand All @@ -50,6 +62,11 @@ public void run(String... args) {

var answeringServers = applicationContext.getBeansOfType(AnsweringServer.class);

shutdownHook=()->{
doRun.set(false);
//SpringApplication.exit(applicationContext, () -> 0);
};

//Create fake futures (terminated futures)
Map<AnsweringServer, Future<?>> futures = setupFakeFutures(answeringServers);

Expand All @@ -60,7 +77,8 @@ public void run(String... args) {
runRunners(executor, futures);
Sleeper.sleep(1000);
}
exit(0);
executor.shutdownNow();
//exit(0);
}

public void stop(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private void initialize() {
result.setLocal(local);
if(result.isActive()) {
var serverEngine = new ServerEngine(remote.getConnectionString(), remote.getLogin(), remote.getPassword());
serverEngine.setMaxRows(100);
serverEngine.setMaxRows(500);
result.setServerEngine(serverEngine);
}
logger.info("Db Proxy LOADED, from: " + local.getConnectionString()+" to "+remote.getConnectionString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,20 @@ public void getStatus(Request req, Response res) {
res.addHeader(ConstantsHeader.CONTENT_TYPE, ConstantsMime.TEXT);
res.setResponseText("OK");
}

@HttpMethodFilter(phase = HttpFilterType.API,
pathAddress = "/api/shutdown",
method = "GET")
@HamDoc(
tags = {"base/utils"},
description = "Shutdown the application",
responses = @HamResponse(
body = String.class,
examples = @Example(example = "OK")
))
public void doShutdown(Request req, Response res) {
res.addHeader(ConstantsHeader.CONTENT_TYPE, ConstantsMime.TEXT);
res.setResponseText("OK");
Main.shutdown();
}
}
22 changes: 22 additions & 0 deletions ham/app/src/main/resources/web/libs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,28 @@ const isUndefined=function(variable){
return false;
}

function getTag(value) {
if (value == null) {
return value === undefined ? '[object Undefined]' : '[object Null]'
}
return toString.call(value)
}

function isObjectLike(value) {
return typeof value === 'object' && value !== null
}

function isBoolean(value) {
return value === true || value === false ||
(isObjectLike(value) && getTag(value) == '[object Boolean]')
}

const isTrue=function(variable){
if (variable.constructor === String && variable.toUpperCase()=="TRUE")return true;
else if(isBoolean(variable))return variable;
return false;
}

const waitForAvailableVariableTimes=function(variable,timeout,func,times){
times--;
if(times<0)return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ <h3>{{data.request.path}}</h3>
th.prev = parseInt(result.headers.get("X-PREV"));
th.$set(th,"data", result.data);


axios.get("/api/plugins/replayer/recording/" + th.recordingId + "/script/" + th.selectedRow)
.then(function (results) {
th.script = results.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,16 @@ module.exports = {
watch:{
$props: {
handler(val,oldVal) {
if(val.value.recordDbCalls)this.recordDbCalls=val.value.recordDbCalls=="true";
if(val.value.recordVoidDbCalls)this.recordVoidDbCalls=val.value.recordVoidDbCalls=="true";
if(val.value.useSimEngine)this.useSimEngine=val.value.useSimEngine=="true";
if(val.value.dbNames)this.dbNames=val.value.dbNames;
if(!isUndefined(val.value)) {
if (!isUndefined(val.value.recordDbCalls)) this.recordDbCalls = isTrue(val.value.recordDbCalls);
if (!isUndefined(val.value.recordVoidDbCalls)) this.recordVoidDbCalls = isTrue(val.value.recordVoidDbCalls);
if (!isUndefined(val.value.useSimEngine)) this.useSimEngine = isTrue(val.value.useSimEngine);
if (!isUndefined(val.value.dbNames)) this.dbNames = val.value.dbNames;
}
this.changeDbName();
this.changeUseSimEngine();
this.changeRecordVoidDbCalls();
this.changeRecordDbCalls();
console.log("CHAAAAAAAAAAAAAAAAA");
},
deep: true,
immediate: true,
Expand Down
Loading

0 comments on commit 4d46cbd

Please sign in to comment.