From 5709fdccd4c2532ce3b875515283d355404fd1dd Mon Sep 17 00:00:00 2001 From: Chris Dukes Date: Sun, 3 Nov 2019 12:41:42 -0500 Subject: [PATCH] Squashed commit of the following: commit ee06f89c4a9c9cb28e6c449dcf1a9ab8cc4efebd Merge: f789252 be35823 Author: Chris Dukes Date: Sun Nov 3 12:39:50 2019 -0500 Merge branch 'master' into release/0.0.1 commit f78925230871c2af751b7c63590658663437b97d Author: Chris Dukes Date: Sun Nov 3 11:44:34 2019 -0500 Add everything to test against a real jenkins Fails at timeout 15 ./swarm-client -master http://192.168.2.45:32779/ -tunnel 192.168.2.45:32778 -username admin -password admin -retry 0 || [ $? -eq 124 ] Nov 03, 2019 4:40:56 PM hudson.plugins.swarm.Client logArguments INFO: Client invoked with: -master http://192.168.2.45:32779/ -password ***** -retry 0 -tunnel 192.168.2.45:32778 -username ***** Nov 03, 2019 4:40:56 PM hudson.plugins.swarm.Client run INFO: Discovering Jenkins master Exception in thread "main" com.oracle.svm.core.jdk.UnsupportedFeatureError: ObjectOutputStream.writeObject() at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:102) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:69) at shaded.org.apache.http.impl.client.BasicAuthCache.put(BasicAuthCache.java:107) at hudson.plugins.swarm.SwarmClient.createHttpClientContext(SwarmClient.java:369) at hudson.plugins.swarm.SwarmClient.discoverFromMasterUrl(SwarmClient.java:232) at hudson.plugins.swarm.Client.run(Client.java:130) at hudson.plugins.swarm.Client.main(Client.java:104) Makefile:2: recipe for target 'test' failed make: *** [test] Error 1 Due to https://github.com/oracle/graal/issues/460 --- .gitignore | 3 ++- Makefile | 55 ++++++++++++++++++++++++++++++++++++---------- jenkins/Dockerfile | 8 +++++++ 3 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 jenkins/Dockerfile diff --git a/.gitignore b/.gitignore index a320ce2..aae2a8d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ native-image.id swarm-client*.jar swarm-client swarm-config/ -libsunec.so \ No newline at end of file +libsunec.so +jenkins.* \ No newline at end of file diff --git a/Makefile b/Makefile index 03a2e9e..96a6ac9 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ -ok: swarm-client libsunec.so +test: swarm-client libsunec.so jenkins.cid | jenkins_up echo Checking $@ - ./swarm-client -help - ./swarm-client -master $(MASTER_URL) -retry 1 -MASTER_URL ?= https://www.google.com/ + ./swarm-client $(TEST_HELP) +# TODO: Will fail until https://github.com/oracle/graal/issues/460 is resolved + timeout 15 ./swarm-client $(TEST_FULL) || [ $$? -eq 124 ] +TEST_HELP = -help > /dev/null +TEST_FULL = -master $(MASTER_URL) -tunnel $(TUNNEL) -username admin -password admin -retry 0 +MASTER_URL = http://$(shell cat jenkins.http_port)/ +TUNNEL = $(shell cat jenkins.jnlp_port) ARCH = $(shell dpkg --print-architecture) swarm-client: swarm-client.jar config/swarm-client native-image.id @@ -10,7 +14,8 @@ swarm-client: swarm-client.jar config/swarm-client native-image.id $(NATIVE_IMAGE) $(SWARM_OPTS) -jar $< TOCLEAN += swarm-client ./\? NATIVE_IMAGE = $(NATIVE_IMAGE_DOCKER) native-image --no-server --no-fallback -H:+ReportExceptionStackTraces -NATIVE_IMAGE_DOCKER = docker run --rm -v $(PWD):/out --user $(ID) --workdir /out $(NATIVE_IMAGE_I) +NATIVE_IMAGE_DOCKER = $(DOCKER_RUN) -v $(PWD):/out --user $(ID) --workdir /out $(NATIVE_IMAGE_I) +DOCKER_RUN = docker container run --rm NATIVE_IMAGE_I = localhost/native-image:latest ID = $(shell id -u $(LOGNAME)) SWARM_OPTS += --initialize-at-run-time=sun.awt.dnd.SunDropTargetContextPeer\$$EventDispatcher @@ -30,27 +35,53 @@ export SWARM_CLIENT_URL = http://repo.jenkins-ci.org/releases/org/jenkins-ci/plu # arg4j requires heavy introspection see # https://github.com/oracle/graal/issues/1137 and # https://github.com/oracle/graal/blob/master/substratevm/CONFIGURE.md -config/%: %.jar native-image.id +config/%: %.jar native-image.id jenkins.cid | jenkins_up echo Inspecting $^ for $@ + rm -rvf $@ mkdir -p config - $(NATIVE_IMAGE_AGENT) -jar $< -master $(MASTER_URL) -retry 1 || true - $(NATIVE_IMAGE_AGENT) -jar $< -help + $(NATIVE_IMAGE_AGENT) -jar $< -master https://www.google.com -retry 0 || true +# TODO: hudson.FilePath + : timeout 15 $(NATIVE_IMAGE_AGENT) -jar $< $(TEST_FULL) || [ $$? -eq 124 ] + $(NATIVE_IMAGE_AGENT) -jar $< $(TEST_HELP) TOCLEAN += config NATIVE_IMAGE_AGENT = $(NATIVE_IMAGE_DOCKER) java -agentlib:native-image-agent=config-merge-dir=$@ +jenkins_up: jenkins.http_port jenkins.jnlp_port + curl --retry 3 --retry-connrefused --retry-delay 15 $(MASTER_URL) > /dev/null + native-image.id: native-image/Dockerfile echo Building docker image $(NATIVE_IMAGE_I) - docker image build --pull --no-cache --tag $(NATIVE_IMAGE_I) native-image - docker image list --quiet $(NATIVE_IMAGE_I) > $@ + docker image build --tag $(NATIVE_IMAGE_I) --iidfile $@ native-image TOCLEAN += native-image.id -DOCKER_TOCLEAN += localhost/native-image:latest +DOCKER_IMAGE_TOCLEAN += localhost/native-image:latest libsunec.so: native-image.id echo Fetching $@ $(NATIVE_IMAGE_DOCKER) find /opt -name $@ -exec cp -v '{}' $@ ';' TOCLEAN += $(SUNEC) +jenkins.cid jenkins.http_port jenkins.jnlp_port: jenkins.id + echo Starting test jenkins + docker container inspect $(shell cat jenkins.cid) > /dev/null || $(DOCKER_RUN) --publish-all --detach $(JENKINS_IMAGE) > jenkins.cid + echo $$(cat jenkins.cid) + docker container port $$(cat jenkins.cid) 8080/tcp | sed -e 's,0\.0\.0\.0,$(HOST),' > jenkins.http_port + docker container port $$(cat jenkins.cid) 50000/tcp | sed -e 's,0\.0\.0\.0,$(HOST),' > jenkins.jnlp_port +TOCLEAN += jenkins.cid jenkins.http_port jenkins.jnlp_port +HOST = $(shell host $$(hostname) | awk '{print $$4}') +JENKINS_IMAGE = localhost/test-jenkins:latest +DOCKER_CONTAINER_RM += $(shell cat jenkins.cid) + +jenkins.id: jenkins/Dockerfile + echo Building docker image $(JENKINS_IMAGE) + docker image build --tag $(JENKINS_IMAGE) --iidfile $@ jenkins +TOCLEAN += jenkins.id +DOCKER_IMAGE_TOCLEAN += $(JENKINS_IMAGE) + + clean: echo Cleaning - docker image rm $(DOCKER_TOCLEAN) || true + docker container rm -f $(DOCKER_CONTAINER_RM) || true + docker image rm $(DOCKER_IMAGE_TOCLEAN) || true rm -rvf $(TOCLEAN) || true +realclean: clean + docker image rm $$(awk '$$1=="FROM"{print $$2}' native-image/Dockerfile) || true diff --git a/jenkins/Dockerfile b/jenkins/Dockerfile new file mode 100644 index 0000000..a3e51e2 --- /dev/null +++ b/jenkins/Dockerfile @@ -0,0 +1,8 @@ +# Best practice is a specific release tag +FROM jenkins/jenkins:lts-alpine +ENV JAVA_OPTS "-Djenkins.install.runSetupWizard=false ${JAVA_OPTS:-}" +RUN /usr/local/bin/install-plugins.sh\ + configuration-as-code\ + script-security\ + swarm +COPY jenkins.yaml ${JENKINS_HOME}/