Skip to content

Commit

Permalink
feat(custom_targets): handle embedded credentials, enable tests (#188)
Browse files Browse the repository at this point in the history
* use MediaType enum for @Produces/@consumes

* turn off JDP in unit tests

* custom target creation should include target in response body

* handle custom target credentials passed along with request form body

* check for stored credentials when opening target connections

* refactor to use redirect-handling webClient extensions, ensure selftest target cleanup

* fix(messaging): handle writing to websockets on dedicated worker thread

* enhance websocket expectation logging and closure handling

* refactor to handle ".data.reason" format of API V2 JSON responses in error cases (no ".data.result")

* deploy 3 vertx-fib-demo samples, one with auth, one with auth+ssl

* bust connection cache entries if matching credentials change

* handle uncaught JMX ConnectionException as a 502 BAD GATEWAY

* permit null JVM IDs, target may not have been connectable yet if we need to evaluate matching credentials for it for the first time

* handle JMX auth failure as HTTP 403 Forbidden

* drop gson dependency

* append, not override, sample app java opts
  • Loading branch information
andrewazores authored Dec 15, 2023
1 parent 7e69df9 commit 539940e
Show file tree
Hide file tree
Showing 33 changed files with 1,126 additions and 778 deletions.
7 changes: 0 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<surefire.rerunFailingTestsCount>2</surefire.rerunFailingTestsCount>
<failsafe-plugin.version>3.2.3</failsafe-plugin.version>
<failsafe.rerunFailingTestsCount>${surefire.rerunFailingTestsCount}</failsafe.rerunFailingTestsCount>
<com.google.code.gson.version>2.10.1</com.google.code.gson.version><!-- TODO drop this -->
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -230,12 +229,6 @@
<version>${com.github.spotbugs.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${com.google.code.gson.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
Expand Down
67 changes: 62 additions & 5 deletions smoketest/compose/sample-apps.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: "3"
services:
sample-app:
sample-app-1:
depends_on:
cryostat:
condition: service_healthy
Expand All @@ -12,17 +12,17 @@ services:
CRYOSTAT_AGENT_APP_NAME: "vertx-fib-demo-1"
CRYOSTAT_AGENT_WEBCLIENT_SSL_TRUST_ALL: "true"
CRYOSTAT_AGENT_WEBCLIENT_SSL_VERIFY_HOSTNAME: "false"
CRYOSTAT_AGENT_WEBSERVER_HOST: "sample-app"
CRYOSTAT_AGENT_WEBSERVER_HOST: "sample-app-1"
CRYOSTAT_AGENT_WEBSERVER_PORT: "8910"
CRYOSTAT_AGENT_CALLBACK: "http://sample-app:8910/"
CRYOSTAT_AGENT_CALLBACK: "http://sample-app-1:8910/"
CRYOSTAT_AGENT_BASEURI: "http://cryostat:8181/"
CRYOSTAT_AGENT_TRUST_ALL: "true"
CRYOSTAT_AGENT_AUTHORIZATION: "Basic dXNlcjpwYXNz"
ports:
- "8081:8081"
labels:
io.cryostat.discovery: "true"
io.cryostat.jmxHost: "sample-app"
io.cryostat.jmxHost: "sample-app-1"
io.cryostat.jmxPort: "9093"
restart: always
healthcheck:
Expand All @@ -31,6 +31,63 @@ services:
retries: 3
start_period: 10s
timeout: 5s
sample-app-2:
depends_on:
cryostat:
condition: service_healthy
image: quay.io/andrewazores/vertx-fib-demo:0.13.0
hostname: vertx-fib-demo-2
environment:
HTTP_PORT: 8082
JMX_PORT: 9094
USE_AUTH: "true"
CRYOSTAT_AGENT_APP_NAME: "vertx-fib-demo-2"
CRYOSTAT_AGENT_WEBCLIENT_SSL_TRUST_ALL: "true"
CRYOSTAT_AGENT_WEBCLIENT_SSL_VERIFY_HOSTNAME: "false"
CRYOSTAT_AGENT_WEBSERVER_HOST: "sample-app-2"
CRYOSTAT_AGENT_WEBSERVER_PORT: "8911"
CRYOSTAT_AGENT_CALLBACK: "http://sample-app-2:8911/"
CRYOSTAT_AGENT_BASEURI: "http://cryostat:8181/"
CRYOSTAT_AGENT_TRUST_ALL: "true"
CRYOSTAT_AGENT_AUTHORIZATION: "Basic dXNlcjpwYXNz"
ports:
- "8082:8082"
restart: always
healthcheck:
test: curl --fail http://localhost:8081 || exit 1
interval: 10s
retries: 3
start_period: 10s
timeout: 5s
sample-app-3:
depends_on:
cryostat:
condition: service_healthy
image: quay.io/andrewazores/vertx-fib-demo:0.13.0
hostname: vertx-fib-demo-3
environment:
HTTP_PORT: 8083
JMX_PORT: 9095
USE_AUTH: "true"
USE_SSL: "true"
CRYOSTAT_AGENT_APP_NAME: "vertx-fib-demo-3"
CRYOSTAT_AGENT_WEBCLIENT_SSL_TRUST_ALL: "true"
CRYOSTAT_AGENT_WEBCLIENT_SSL_VERIFY_HOSTNAME: "false"
CRYOSTAT_AGENT_WEBSERVER_HOST: "sample-app-3"
CRYOSTAT_AGENT_WEBSERVER_PORT: "8910"
CRYOSTAT_AGENT_CALLBACK: "http://sample-app-3:8912/"
CRYOSTAT_AGENT_BASEURI: "http://cryostat:8181/"
CRYOSTAT_AGENT_TRUST_ALL: "true"
CRYOSTAT_AGENT_AUTHORIZATION: "Basic dXNlcjpwYXNz"
ports:
- "8083:8083"
restart: always
healthcheck:
test: curl --fail http://localhost:8081 || exit 1
interval: 10s
retries: 3
start_period: 10s
timeout: 5s
quarkus-test-agent:
image: quay.io/andrewazores/quarkus-test:latest
# do not add a depends_on:cryostat here, so that we can test that the agent is tolerant of that state
Expand All @@ -40,7 +97,7 @@ services:
expose:
- "9977"
environment:
JAVA_OPTS: "-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -javaagent:/deployments/app/cryostat-agent.jar"
JAVA_OPTS_APPEND: "-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -javaagent:/deployments/app/cryostat-agent.jar"
QUARKUS_HTTP_PORT: 10010
ORG_ACME_CRYOSTATSERVICE_ENABLED: "false"
CRYOSTAT_AGENT_APP_NAME: quarkus-test-agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@ kind: Deployment
metadata:
annotations:
io.cryostat.discovery: "true"
io.cryostat.jmxHost: sample-app
io.cryostat.jmxHost: sample-app-1
io.cryostat.jmxPort: "9093"
creationTimestamp: null
labels:
io.kompose.service: sample-app
name: sample-app
io.kompose.service: sample-app-1
name: sample-app-1
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: sample-app
io.kompose.service: sample-app-1
strategy: {}
template:
metadata:
annotations:
io.cryostat.discovery: "true"
io.cryostat.jmxHost: sample-app
io.cryostat.jmxHost: sample-app-1
io.cryostat.jmxPort: "9093"
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
io.kompose.service: sample-app
io.kompose.service: sample-app-1
spec:
containers:
- env:
Expand All @@ -35,15 +35,15 @@ spec:
- name: CRYOSTAT_AGENT_BASEURI
value: http://cryostat:8181/
- name: CRYOSTAT_AGENT_CALLBACK
value: http://sample-app:8910/
value: http://sample-app-1:8910/
- name: CRYOSTAT_AGENT_TRUST_ALL
value: "true"
- name: CRYOSTAT_AGENT_WEBCLIENT_SSL_TRUST_ALL
value: "true"
- name: CRYOSTAT_AGENT_WEBCLIENT_SSL_VERIFY_HOSTNAME
value: "false"
- name: CRYOSTAT_AGENT_WEBSERVER_HOST
value: sample-app
value: sample-app-1
- name: CRYOSTAT_AGENT_WEBSERVER_PORT
value: "8910"
- name: HTTP_PORT
Expand All @@ -59,7 +59,7 @@ spec:
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
name: sample-app
name: sample-app-1
ports:
- containerPort: 8081
hostPort: 8081
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ kind: Service
metadata:
annotations:
io.cryostat.discovery: "true"
io.cryostat.jmxHost: sample-app
io.cryostat.jmxHost: sample-app-1
io.cryostat.jmxPort: "9093"
creationTimestamp: null
labels:
io.kompose.service: sample-app
name: sample-app
io.kompose.service: sample-app-1
name: sample-app-1
spec:
ports:
- name: "8081"
port: 8081
targetPort: 8081
selector:
io.kompose.service: sample-app
io.kompose.service: sample-app-1
status:
loadBalancer: {}
64 changes: 64 additions & 0 deletions smoketest/k8s/sample-app-2-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
io.kompose.service: sample-app-2
name: sample-app-2
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: sample-app-2
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
io.kompose.service: sample-app-2
spec:
containers:
- env:
- name: CRYOSTAT_AGENT_APP_NAME
value: vertx-fib-demo-2
- name: CRYOSTAT_AGENT_AUTHORIZATION
value: Basic dXNlcjpwYXNz
- name: CRYOSTAT_AGENT_BASEURI
value: http://cryostat:8181/
- name: CRYOSTAT_AGENT_CALLBACK
value: http://sample-app-2:8911/
- name: CRYOSTAT_AGENT_TRUST_ALL
value: "true"
- name: CRYOSTAT_AGENT_WEBCLIENT_SSL_TRUST_ALL
value: "true"
- name: CRYOSTAT_AGENT_WEBCLIENT_SSL_VERIFY_HOSTNAME
value: "false"
- name: CRYOSTAT_AGENT_WEBSERVER_HOST
value: sample-app-2
- name: CRYOSTAT_AGENT_WEBSERVER_PORT
value: "8911"
- name: HTTP_PORT
value: "8082"
- name: JMX_PORT
value: "9094"
- name: USE_AUTH
value: "true"
image: quay.io/andrewazores/vertx-fib-demo:0.13.0
livenessProbe:
exec:
command:
- curl --fail http://localhost:8081 || exit 1
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
name: sample-app-2
ports:
- containerPort: 8082
hostPort: 8082
protocol: TCP
resources: {}
hostname: vertx-fib-demo-2
restartPolicy: Always
status: {}
16 changes: 16 additions & 0 deletions smoketest/k8s/sample-app-2-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
io.kompose.service: sample-app-2
name: sample-app-2
spec:
ports:
- name: "8082"
port: 8082
targetPort: 8082
selector:
io.kompose.service: sample-app-2
status:
loadBalancer: {}
66 changes: 66 additions & 0 deletions smoketest/k8s/sample-app-3-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
io.kompose.service: sample-app-3
name: sample-app-3
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: sample-app-3
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
io.kompose.service: sample-app-3
spec:
containers:
- env:
- name: CRYOSTAT_AGENT_APP_NAME
value: vertx-fib-demo-3
- name: CRYOSTAT_AGENT_AUTHORIZATION
value: Basic dXNlcjpwYXNz
- name: CRYOSTAT_AGENT_BASEURI
value: http://cryostat:8181/
- name: CRYOSTAT_AGENT_CALLBACK
value: http://sample-app-3:8912/
- name: CRYOSTAT_AGENT_TRUST_ALL
value: "true"
- name: CRYOSTAT_AGENT_WEBCLIENT_SSL_TRUST_ALL
value: "true"
- name: CRYOSTAT_AGENT_WEBCLIENT_SSL_VERIFY_HOSTNAME
value: "false"
- name: CRYOSTAT_AGENT_WEBSERVER_HOST
value: sample-app-3
- name: CRYOSTAT_AGENT_WEBSERVER_PORT
value: "8910"
- name: HTTP_PORT
value: "8083"
- name: JMX_PORT
value: "9095"
- name: USE_AUTH
value: "true"
- name: USE_SSL
value: "true"
image: quay.io/andrewazores/vertx-fib-demo:0.13.0
livenessProbe:
exec:
command:
- curl --fail http://localhost:8081 || exit 1
failureThreshold: 3
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
name: sample-app-3
ports:
- containerPort: 8083
hostPort: 8083
protocol: TCP
resources: {}
hostname: vertx-fib-demo-3
restartPolicy: Always
status: {}
16 changes: 16 additions & 0 deletions smoketest/k8s/sample-app-3-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
io.kompose.service: sample-app-3
name: sample-app-3
spec:
ports:
- name: "8083"
port: 8083
targetPort: 8083
selector:
io.kompose.service: sample-app-3
status:
loadBalancer: {}
Loading

0 comments on commit 539940e

Please sign in to comment.