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

Add HTTP proxy, multiple connections to client, clustering to server #11

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
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
79 changes: 54 additions & 25 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
#!/usr/bin/env groovy


/**
* Jenkinsfile for proxyhook server/client
*
* Environment variables:
*
* PROXYHOOK_DOCKER_REGISTRY - Docker registry host to use with OpenShift platform
* PROXYHOOK_OPENSHIFT - OpenShift platform URL
* PROXYHOOK_SERVER_PROJECT - OpenShift project name for DEV/QA/STAGE/PROD deployments
*
* For pull requests:
* - build and test
* - optional: wait for input
* - deploy to DEV
* - while (input = redeploy) deploy to DEV
* - wait for input
* - deploy to QA
* - while (input = redeploy) deploy to QA
*
* For master:
* - build and test
* - deploy to STAGE
* - wait for input
* - deploy to PROD
*/

@Field
public static final String PROJ_BASE = 'github.com/zanata/proxyhook'

Expand Down Expand Up @@ -96,31 +122,7 @@ timestamps {
stage('Build') {
notify.startBuilding()
tag = makeTag()

// TODO run detekt
sh """./gradlew clean build shadowJar jacocoTestReport
"""

// archive build artifacts
archive "**/build/libs/*.jar"

// gather surefire results; mark build as unstable in case of failures
junit(testResults: '**/build/test-results/**/*.xml')
notify.testResults("UNIT", currentBuild.result)

if (isBuildResultSuccess()) {
// parse Jacoco test coverage
step([$class: 'JacocoPublisher'])

if (env.BRANCH_NAME == 'master') {
step([$class: 'MasterCoverageAction'])
} else if (env.BRANCH_NAME.startsWith('PR-')) {
step([$class: 'CompareCoverageAction'])
}

// send test coverage data to codecov.io
codecov(env, steps, mainScmGit)
}
buildAndTest()
}
stage('Deploy') {
if (tag && isBuildResultSuccess()) {
Expand Down Expand Up @@ -174,6 +176,33 @@ timestamps {
}
}

private void buildAndTest() {
// TODO run detekt
sh """./gradlew clean build shadowJar jacocoTestReport
"""

// archive build artifacts
archive "**/build/libs/*.jar"

// gather surefire results; mark build as unstable in case of failures
junit(testResults: '**/build/test-results/**/*.xml')
notify.testResults("UNIT", currentBuild.result)

if (isBuildResultSuccess()) {
// parse Jacoco test coverage
step([$class: 'JacocoPublisher'])

if (env.BRANCH_NAME == 'master') {
step([$class: 'MasterCoverageAction'])
} else if (env.BRANCH_NAME.startsWith('PR-')) {
step([$class: 'CompareCoverageAction'])
}

// send test coverage data to codecov.io
codecov(env, steps, mainScmGit)
}
}

private boolean isBuildResultSuccess() {
currentBuild.result in ['SUCCESS', null]
}
22 changes: 17 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
buildscript {
ext.kotlin_version = '1.1.51'
ext.kotlin_version = '1.2.30'
ext.vertx_version = '3.5.1'
repositories {
mavenCentral()
}
Expand All @@ -22,12 +23,18 @@ subprojects {

sourceCompatibility = '1.8'

kotlin {
experimental {
coroutines "enable"
}
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
compile 'io.vertx:vertx-core:3.5.0'
compile 'io.vertx:vertx-web:3.5.0'
// testCompile 'io.vertx:vertx-unit:3.5.0'
testCompile 'io.vertx:vertx-lang-kotlin-coroutines:3.5.0'
compile "io.vertx:vertx-core:$vertx_version"
compile "io.vertx:vertx-web:$vertx_version"
// testCompile "io.vertx:vertx-unit:$vertx_version"
compile "io.vertx:vertx-lang-kotlin-coroutines:$vertx_version"
testCompile 'junit:junit:4.12'
testCompile 'net.wuerl.kotlin:assertj-core-kotlin:0.2.1'
}
Expand All @@ -54,6 +61,11 @@ subprojects {
}
}

configurations {
all*.exclude group: 'xerces', module: 'xerces'
all*.exclude group: 'xerces', module: 'xercesImpl'
}

}

task('setVersionFromBuild') << {
Expand Down
14 changes: 7 additions & 7 deletions client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM openjdk:8-jre-alpine
LABEL maintainer="sflaniga@redhat.com"
# https://access.redhat.com/containers/?tab=overview&platform=docker#/registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift
FROM registry.access.redhat.com/redhat-openjdk-18/openjdk18-openshift:1.2-6

ADD build/libs/client*-fat.jar /app/client.jar
RUN chgrp -R 0 /app/ && chmod -R 775 /app/
COPY build/libs/client*-fat.jar /deployments/

WORKDIR /app/

USER 64738
# NB run-java.sh will scale heap size to 50% of container memory size

# NB must use the exec form of ENTRYPOINT if you want to add arguments with CMD
# https://docs.docker.com/engine/reference/builder/#exec-form-entrypoint-example

ENTRYPOINT ["java", "-Xmx32M", "-jar", "client.jar"]
# see https://github.com/fabric8io-images/run-java-sh
ENTRYPOINT ["/opt/run-java/run-java.sh"]
32 changes: 9 additions & 23 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,29 @@ plugins {

dependencies {
compile project(':common')
compile 'com.xenomachina:kotlin-argparser:2.0.4'
compile "io.vertx:vertx-shell:$vertx_version"
testCompile project(':server')
testCompile 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.18'
testCompile 'org.asynchttpclient:async-http-client:2.1.0-alpha20'
testRuntime 'org.slf4j:slf4j-simple:1.7.25'
testCompile 'org.mock-server:mockserver-netty:3.11'

// compile "io.vertx:vertx-hazelcast:$vertx_version"
// compile "io.vertx:vertx-infinispan:$vertx_version"
// // http://vertx.io/docs/vertx-infinispan/java/#_configuring_for_kubernetes_or_openshift_3
// compile 'org.infinispan:infinispan-cloud:9.1.2.Final'
// compile 'org.jgroups.kubernetes:jgroups-kubernetes:1.0.3.Final'
}

mainClassName = 'io.vertx.core.Launcher'
def mainVerticleName = 'org.zanata.proxyhook.client.ProxyHookClient'
mainClassName = 'org.zanata.proxyhook.client.ProxyHookClient'

// enable debugger on a random port
applicationDefaultJvmArgs = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,address=0,server=y,suspend=n', '-Dsun.net.inetaddr.ttl=0', '-Dsun.net.inetaddr.negative.ttl=0']


// Vert.x watches for file changes in all subdirectories
// of src/ but only for files with .kt extension
// NB this won't pick up changes in :common
def watchForChange = 'src/**/*.kt'

// Vert.x will call this task on changes
def doOnChange = 'gradlew classes'

//noinspection GroovyAssignabilityCheck
run {
def urls = System.getProperty('urls') ?: ''
args = ['run', mainVerticleName] + urls.tokenize()
// redeploy doesn't stop the old code, for some reason
// args = ['run', mainVerticleName, "--redeploy=$watchForChange", "--launcher-class=$mainClassName", "--on-redeploy=$doOnChange"] + urls.tokenize()
}

shadowJar {
classifier = 'fat'

manifest {
attributes "Main-Verticle": mainVerticleName
}

mergeServiceFiles {
include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
}
Expand Down
Loading