Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
19a8bbd
[Buildkite] Add Docker Build
pickypg Apr 8, 2026
25cd480
Remove unneeded .gradle reference
pickypg Apr 8, 2026
eb9679d
Use root
pickypg Apr 8, 2026
e77a298
Use JUnit 6 platform
pickypg Apr 8, 2026
913d7f9
Disable Gradle Daemon in build since it will never be reused
pickypg Apr 8, 2026
40acd01
Add global per-test timeout
pickypg Apr 8, 2026
94cc1d0
Explicitly bind to 127.0.0.1 in tests
pickypg Apr 8, 2026
6015740
Swap call order for readability
pickypg Apr 8, 2026
ba433b6
Reduce lifecycle timeouts
pickypg Apr 8, 2026
0e27934
Create local Dockerfile.test and use it
pickypg Apr 9, 2026
1b309a2
For tests '-Djava.net.preferIPv4Stack=true'
pickypg Apr 9, 2026
c6d40fa
Try some more ipv4 magic for the forked JVM to communicate
pickypg Apr 9, 2026
d941b11
Log test failure details
pickypg Apr 9, 2026
a57af0d
Try downgrading JUnit
pickypg Apr 9, 2026
75f01cb
Dump XML test reports to stdout on failure for CI diagnostics
pickypg Apr 9, 2026
65ec7d1
Unrevert JUnit and add Docker Ignore to match local behavior with CI
pickypg Apr 9, 2026
0210893
Add --stacktrace to surface test worker crash root cause
pickypg Apr 9, 2026
474cec3
Limit resources
pickypg Apr 9, 2026
0c6f850
Pass security.egd to test worker JVM to prevent entropy starvation on…
pickypg Apr 10, 2026
a9aa62d
Merge branch 'main' into buildkite/build-docker-image
pickypg May 1, 2026
9ee00b8
Delete old tests
pickypg May 1, 2026
216c98c
Remove other low quality tests
pickypg May 1, 2026
a1c25aa
Capture test output
pickypg May 1, 2026
0f9d089
Fix warnings and also cp correct path for test reports
pickypg May 1, 2026
844cc02
Remove complex logic and instead try to place build test reports into…
pickypg May 1, 2026
9da4c25
Have tests for explicitly Docker versus not -- not inferred
pickypg May 1, 2026
ec7da64
Also capture e2eTest output
pickypg May 1, 2026
4b85c97
Let Docker see the socket
pickypg May 2, 2026
8417948
Try without running it in Docker at all
pickypg May 2, 2026
7f3b649
Debug Docker
pickypg May 2, 2026
8464864
Drop environment
pickypg May 2, 2026
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
59 changes: 40 additions & 19 deletions .buildkite/default-pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
---
# $yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
steps:
- label: "Build"
command: "true"
# - label: ":docker: Build and Push Dockerfile"
# commands:
# - "vault kv get -field=password kv/ci-shared/opex/oci-registry-creds-prod | docker login -u $(vault kv get -field=username kv/ci-shared/opex/oci-registry-creds-prod) --password-stdin docker.elastic.co"
# - "docker buildx create --use"
# - "docker buildx build --platform linux/amd64,linux/arm64 --push -t docker.elastic.co/opex/diagnostics:latest ."
# agents:
# provider: "gcp"
# imagePrefix: "core-ubuntu-2204"
# machineType: "n2-standard-2"
- label: ":gradle: Test"
key: "gradle-test"
commands:
- docker build -f Dockerfile.test -t support-diagnostics-test .
- docker ps
- echo $DOCKER_HOST
- ls -l /var/run/docker.sock
- docker run --rm -v "$$(pwd)/test-reports:/app/build/reports/tests" -v /var/run/docker.sock:/var/run/docker.sock support-diagnostics-test
artifact_paths:
- "test-reports/test/**/*"
- "test-reports/e2eTest/**/*"
agents:
provider: "gcp"
imagePrefix: "core-ubuntu-2204"
machineType: "n2-standard-2"

- label: "Test"
command: "true"

- label: "Deploy"
command: "true"

- label: "Publish"
command: "true"
- label: ":docker: Build and Push Docker Image"
depends_on: "gradle-test"
if: build.branch == "main"
plugins:
- elastic/vault-secrets#v0.1.0:
path: 'kv/ci-shared/opex/oci-registry-creds-prod'
field: "username"
env_var: "DOCKER_REG_USER"
- elastic/vault-secrets#v0.1.0:
path: 'kv/ci-shared/opex/oci-registry-creds-prod'
field: "password"
env_var: "DOCKER_REG_PASS"
- elastic/vault-secrets#v0.1.0:
path: 'kv/ci-shared/opex/oci-registry-creds-prod'
field: "hostname"
env_var: "DOCKER_REG_HOSTNAME"
commands:
- VERSION=$(grep '^version=' gradle.properties | cut -d'=' -f2)
- set +x && echo "$$DOCKER_REG_PASS" | docker login -u "$$DOCKER_REG_USER" --password-stdin "$$DOCKER_REG_HOSTNAME"
- docker buildx create --use --name multiarch-builder --driver docker-container || docker buildx use multiarch-builder
- docker buildx build --platform linux/amd64,linux/arm64 --push -t "docker.elastic.co/support/diagnostics:$${VERSION}" .
agents:
provider: "gcp"
imagePrefix: "core-ubuntu-2204"
machineType: "n2-standard-2"
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Build files
build
**/build
.gradle
**/.gradle
diagnostic-output
target

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ WORKDIR /build

COPY ./ ./

RUN ./gradlew build
RUN ./gradlew --no-daemon build

FROM docker.elastic.co/wolfi/jdk:openjdk-25.0.3-r2@sha256:ef761f476e5f50b6755c17c7d679d7e08b8cca47ec3b8f12765adb7f863f0418 AS runner

Expand Down
11 changes: 11 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM docker.elastic.co/wolfi/jdk:openjdk-25.0.2-r2-dev@sha256:05e5fd81a2a335ca2872ee70dcd1cc6b183c412b0e559e5eca648a82872d281d

USER root

WORKDIR /app

COPY . .

ENV GRADLE_OPTS="-Xmx512m -XX:MaxMetaspaceSize=256m"

CMD ["./gradlew", "test", "e2eTest", "--no-daemon", "--stacktrace"]
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ tasks.named("build") {
// ---------------------------------------------------------------------------
tasks.withType<Test> {
useJUnitPlatform()
jvmArgs("-Djava.net.preferIPv4Stack=true", "-Djava.security.egd=file:/dev/./urandom")
maxHeapSize = "512m"
}

tasks.named<Test>("test") {
Expand All @@ -206,7 +208,7 @@ val e2eTest by tasks.registering(Test::class) {

tasks.withType<JavaCompile> {
options.compilerArgs.addAll(listOf("-Xlint:deprecation", "-Xlint:unchecked"))
options.isFork = true
options.isFork = true // fork to guarantee that Lombok does not mess with the Gradle JVM
options.encoding = "UTF-8"
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
group=co.elastic.support
version=9.4.0-SNAPSHOT
org.gradle.jvmargs=-Djava.net.preferIPv4Stack=true
20 changes: 10 additions & 10 deletions src/main/java/co/elastic/support/rest/RestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
Expand Down Expand Up @@ -55,11 +56,10 @@ public class RestClient implements Closeable {
private static final Logger logger = LogManager.getLogger(RestClient.class);
private static final int maxTotal = 100, defaultMaxPerRoute = 10;

private CloseableHttpClient client;
private HttpHost httpHost;
private HttpClientContext httpContext;

private Map<String, String> extraHeaders;
private final CloseableHttpClient client;
private final HttpHost httpHost;
private final HttpClientContext httpContext;
private final Map<String, String> extraHeaders;

public RestClient(CloseableHttpClient client, HttpHost httpHost, HttpClientContext context,
Map<String, String> extraHeaders) {
Expand Down Expand Up @@ -218,18 +218,18 @@ public static RestClient getClient(

// We need to create a registry for socket factories
// for both http and https or pooling will not work.
Registry registry = RegistryBuilder.create()
.register("https", factory)
.register("http", PlainConnectionSocketFactory.getSocketFactory()).build();
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("https", factory)
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.build();
PoolingHttpClientConnectionManager mgr = new PoolingHttpClientConnectionManager(registry);
mgr.setDefaultMaxPerRoute(defaultMaxPerRoute);
mgr.setMaxTotal(maxTotal);
clientBuilder.setConnectionManager(mgr);

CloseableHttpClient httpClient = clientBuilder.build();
RestClient restClient = new RestClient(httpClient, httpHost, context, extraHeaders);

return restClient;
return new RestClient(httpClient, httpHost, context, extraHeaders);
} catch (Exception e) {
logger.error("Connection setup failed", e);
throw new RuntimeException("Error establishing http connection for: " + host, e);
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/co/elastic/support/util/RemoteSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

import co.elastic.support.Constants;
import co.elastic.support.diagnostics.DiagnosticException;
import com.jcraft.jsch.*;
import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -81,11 +86,10 @@ public RemoteSystem(String osName,

UserInfo userInfo = new RemoteUserInfo(remoteUser, remotePassword, keyFilePass);
session = jsch.getSession(remoteUser, host, port);
final Hashtable config = new Hashtable();
final Hashtable<String, String> config = new Hashtable<>();

config.put("StrictHostKeyChecking", hostKeyChecking);
config.put("PreferredAuthentications",
"publickey,keyboard-interactive,password");
config.put("PreferredAuthentications", "publickey,keyboard-interactive,password");

session.setConfig(config);
session.setUserInfo(userInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,25 @@ void setDefaultPort_doesNotOverrideNonDefault() {
@Test
void validateDiagType_valid() {
DiagnosticInputs inputs = new DiagnosticInputs();
inputs.runningInDocker = false;
for (String type : DiagnosticInputs.diagnosticTypeValues) {
List<String> errors = inputs.validateDiagType(type);
assertNull(errors, "Expected no errors for type: " + type);
}
}

@Test
void validateDiagType_localTypesInvalidInDocker() {
DiagnosticInputs inputs = new DiagnosticInputs();
inputs.runningInDocker = true;
String[] localTypes = { Constants.local, Constants.logstashLocal, Constants.kibanaLocal };
for (String type : localTypes) {
List<String> errors = inputs.validateDiagType(type);
assertNotNull(errors, "Expected error for local type in Docker: " + type);
assertEquals(1, errors.size());
}
}

@Test
void validateDiagType_invalid() {
DiagnosticInputs inputs = new DiagnosticInputs();
Expand Down
Loading