You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2026/10/08 11:39:43 UTC
(juneau) branch juneau-release-manager updated: Live console output and run view on the new-release page; bulk-selection cards on the releases page; drop vendored DataTables and jQuery
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch juneau-release-manager
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/juneau-release-manager by this push:
new 72e00262cc Live console output and run view on the new-release page; bulk-selection cards on the releases page; drop vendored DataTables and jQuery
72e00262cc is described below
commit 72e00262cc56b7963c881a47b2880fce63e2ef04
Author: James Bognar <ja...@apache.org>
AuthorDate: Thu Oct 8 07:39:38 2026 -0400
Live console output and run view on the new-release page; bulk-selection cards on the releases page; drop vendored DataTables and jQuery
---
LICENSE | 57 ----
README.md | 4 +-
.../tests/new-release-console-output.spec.ts | 28 +-
.../tests/new-release-run-view.spec.ts | 27 +-
e2e/tests/releases-dropped-only.spec.ts | 53 ++++
pom.xml | 3 -
.../org/apache/juneau/releng/AppConfiguration.java | 44 +--
.../apache/juneau/releng/engine/DropRcService.java | 30 +-
.../apache/juneau/releng/engine/ReleaseEngine.java | 106 ++++++-
.../apache/juneau/releng/engine/ReleaseStep.java | 7 +
.../apache/juneau/releng/engine/StepContext.java | 40 +++
.../juneau/releng/engine/TestReportEvents.java | 111 +++++++
.../releng/engine/steps/BuildVerifyStep.java | 5 +
.../engine/steps/ComposeAnnouncementEmailStep.java | 1 +
.../engine/steps/ComposeProposeEmailStep.java | 1 +
.../engine/steps/ComposeResultEmailStep.java | 1 +
.../releng/engine/steps/ComposeVoteEmailStep.java | 1 +
.../releng/engine/steps/DeploySnapshotStep.java | 5 +
.../engine/steps/GithubReleaseCreateStep.java | 7 +-
.../releng/engine/steps/NexusStagingCloseStep.java | 1 +
.../releng/engine/steps/ReleasePerformStep.java | 5 +
.../releng/engine/steps/ReleasePrepareStep.java | 5 +
.../releng/engine/steps/TallyVoteResultStep.java | 6 +
.../org/apache/juneau/releng/log/Broadcaster.java | 5 +-
.../apache/juneau/releng/log/LogBroadcaster.java | 55 ----
.../apache/juneau/releng/log/RunEventStore.java | 288 ++++++++++++++++++
.../java/org/apache/juneau/releng/log/RunLog.java | 20 +-
...{SseLogServlet.java => RunStateSseServlet.java} | 110 ++-----
.../juneau/releng/log/StepOutputSources.java | 117 ++++++++
.../org/apache/juneau/releng/rest/ReleaseRest.java | 6 +-
.../apache/juneau/releng/rest/ReleaseRunRest.java | 42 ++-
src/main/resources/static/css/new-release.css | 77 +----
.../datatables/dataTables.dataTables.min.css | 1 -
.../resources/static/datatables/dataTables.min.js | 4 -
src/main/resources/static/datatables/jquery.min.js | 2 -
src/main/resources/static/js/new-release.js | 43 ++-
src/main/resources/templates/new-release.ftlh | 6 +-
src/main/resources/templates/releases.ftlh | 54 ++--
.../apache/juneau/releng/AppConfigurationTest.java | 44 ---
.../juneau/releng/engine/DropRcServiceTest.java | 8 +-
.../releng/engine/ReleaseEngineRunViewTest.java | 333 +++++++++++++++++++++
.../juneau/releng/engine/ReleaseEngineTest.java | 3 +-
.../juneau/releng/engine/TestReportEventsTest.java | 76 +++++
.../juneau/releng/log/RunEventStoreTest.java | 129 ++++++++
.../org/apache/juneau/releng/log/RunLogTest.java | 43 +--
...ervletTest.java => RunStateSseServletTest.java} | 36 +--
.../juneau/releng/log/StepOutputSourcesTest.java | 124 ++++++++
.../apache/juneau/releng/rest/ReleaseRestTest.java | 46 +--
.../releng/rest/ReleaseRunRestOutputTest.java | 176 +++++++++++
.../juneau/releng/rest/ReleaseRunRestTest.java | 6 +-
50 files changed, 1849 insertions(+), 553 deletions(-)
diff --git a/LICENSE b/LICENSE
index 166df52937..8dada3edaf 100644
--- a/LICENSE
+++ b/LICENSE
@@ -199,60 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-
-=============================================================================
-== THIRD-PARTY COMPONENTS ==
-=============================================================================
-
-This product bundles the following third-party components under
-src/main/resources/static/. Each is licensed under the MIT License.
-
------------------------------------------------------------------------------
-jQuery JavaScript Library v3.7.1
- Bundled at: src/main/resources/static/datatables/jquery.min.js
- Homepage: https://jquery.com/ (https://jquery.org/license/)
- Copyright OpenJS Foundation and other contributors.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
------------------------------------------------------------------------------
-DataTables 2.1.8
- Bundled at: src/main/resources/static/datatables/dataTables.min.js
- src/main/resources/static/datatables/dataTables.dataTables.min.css
- Homepage: https://datatables.net/ (https://datatables.net/license)
- Copyright (C) 2008-2024, SpryMedia Ltd.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
------------------------------------------------------------------------------
diff --git a/README.md b/README.md
index deecab1f85..2554b18091 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,4 @@ mvn clean verify # build + run tests + apache-rat license check
## License
-Apache License 2.0. See `LICENSE` (which also reproduces the MIT attribution
-notices for the vendored jQuery 3.7.1 and DataTables 2.1.8 assets under
-`src/main/resources/static/datatables/`).
+Apache License 2.0. See `LICENSE`.
diff --git a/src/main/java/org/apache/juneau/releng/log/Broadcaster.java b/e2e/tests/new-release-console-output.spec.ts
similarity index 54%
copy from src/main/java/org/apache/juneau/releng/log/Broadcaster.java
copy to e2e/tests/new-release-console-output.spec.ts
index f420b461df..1fe2c1bc52 100644
--- a/src/main/java/org/apache/juneau/releng/log/Broadcaster.java
+++ b/e2e/tests/new-release-console-output.spec.ts
@@ -15,19 +15,19 @@
* limitations under the License.
*/
-package org.apache.juneau.releng.log;
+import { test, expect } from '@playwright/test';
-import java.util.function.Consumer;
+test.describe('step console output', () => {
+ test('execution page loads the console-output region and none of the old renderer', async ({ page }) => {
+ await page.goto('/rest/runs?tab=exec');
+ await expect(page.locator('#nr-panel-exec')).toBeAttached();
+ const html = await page.content();
+ expect(html).toContain('juneau-console-output.js');
+ expect(html).not.toContain('rm-console');
+ });
-/**
- * Common subscribe shape shared by {@link LogBroadcaster} (console log lines) and
- * {@link RunStateBroadcaster} (run/step status snapshots) so {@link SseLogServlet}'s tail loop can serve
- * either channel without duplicating it.
- */
-public interface Broadcaster {
-
- /**
- * Subscribes {@code sink} to every payload published from now on; closing the return unsubscribes it.
- */
- AutoCloseable subscribe(Consumer<String> sink);
-}
+ test('lines endpoint answers 404 for an unknown run and step', async ({ request }) => {
+ const res = await request.get('/rest/runs/0.0.0-none/steps/no-such-step/output/lines');
+ expect(res.status()).toBe(404);
+ });
+});
diff --git a/src/main/java/org/apache/juneau/releng/log/Broadcaster.java b/e2e/tests/new-release-run-view.spec.ts
similarity index 58%
copy from src/main/java/org/apache/juneau/releng/log/Broadcaster.java
copy to e2e/tests/new-release-run-view.spec.ts
index f420b461df..720f8c3a89 100644
--- a/src/main/java/org/apache/juneau/releng/log/Broadcaster.java
+++ b/e2e/tests/new-release-run-view.spec.ts
@@ -15,19 +15,18 @@
* limitations under the License.
*/
-package org.apache.juneau.releng.log;
+import { test, expect } from '@playwright/test';
-import java.util.function.Consumer;
+test.describe('run progress region', () => {
+ test('execution page loads the run-view module', async ({ page }) => {
+ await page.goto('/rest/runs?tab=exec');
+ await expect(page.locator('#nr-panel-exec')).toBeAttached();
+ const html = await page.content();
+ expect(html).toContain('juneau-run-view.js');
+ });
-/**
- * Common subscribe shape shared by {@link LogBroadcaster} (console log lines) and
- * {@link RunStateBroadcaster} (run/step status snapshots) so {@link SseLogServlet}'s tail loop can serve
- * either channel without duplicating it.
- */
-public interface Broadcaster {
-
- /**
- * Subscribes {@code sink} to every payload published from now on; closing the return unsubscribes it.
- */
- AutoCloseable subscribe(Consumer<String> sink);
-}
+ test('events endpoint answers 404 for an unknown run', async ({ request }) => {
+ const res = await request.get('/rest/runs/juneau-run-view/0_0_0-none/events');
+ expect(res.status()).toBe(404);
+ });
+});
diff --git a/e2e/tests/releases-dropped-only.spec.ts b/e2e/tests/releases-dropped-only.spec.ts
new file mode 100644
index 0000000000..334717128a
--- /dev/null
+++ b/e2e/tests/releases-dropped-only.spec.ts
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { test, expect, type Page } from '@playwright/test';
+
+/**
+ * The 'Dropped only' ribbon option is a column-scoped filter. It must reach the server in the JSON request body as the
+ * BeanQuery expression `$eq(DROPPED)`, and the table must then show only DROPPED rows. Before the ribbon encoding was
+ * shared with the Java decoder through a corpus, this was the filter that silently stopped applying.
+ */
+const TABLE_SELECTOR = '#releases';
+
+function dataRows(page: Page) {
+ return page.locator(TABLE_SELECTOR).locator('tbody tr');
+}
+
+test.describe('releases: dropped-only ribbon option', () => {
+ test.beforeEach(async ({ page }) => {
+ await page.goto('/rest/releases');
+ await page.evaluate(() => localStorage.clear());
+ await page.reload();
+ await expect(page.locator(TABLE_SELECTOR)).toBeVisible();
+ await expect(dataRows(page).first()).toBeVisible();
+ });
+
+ test('turning the option on sends $eq(DROPPED) and shows only DROPPED rows', async ({ page }) => {
+ const [req] = await Promise.all([
+ page.waitForRequest(r => r.method() === 'POST' && (r.postData() ?? '').includes('$eq(DROPPED)')),
+ page.getByTestId('ribbon').getByRole('button', { name: 'Dropped only' }).click(),
+ ]);
+ expect(req.postDataJSON().columns.some((c: any) => c?.search?.value === '$eq(DROPPED)')).toBe(true);
+
+ await page.waitForLoadState('networkidle');
+ // The fixture is real tag history, so it may hold no DROPPED release: then the table is empty and the loop is
+ // vacuous, but any status pill that IS shown must be DROPPED.
+ const statuses = await page.locator(TABLE_SELECTOR).locator('.tag.status').allInnerTexts();
+ for (const s of statuses) expect(s.trim()).toBe('DROPPED');
+ });
+});
diff --git a/pom.xml b/pom.xml
index 5a4ea4034e..dcb0e864e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -141,9 +141,6 @@
<configuration>
<consoleOutput>true</consoleOutput>
<excludes>
- <!-- Vendored third-party MIT assets - keep their own upstream headers -->
- <exclude>src/main/resources/static/datatables/**</exclude>
-
<!-- Docs / release metadata - no license-header comment syntax -->
<exclude>**/*.md</exclude>
<exclude>LICENSE</exclude>
diff --git a/src/main/java/org/apache/juneau/releng/AppConfiguration.java b/src/main/java/org/apache/juneau/releng/AppConfiguration.java
index 9aa1829990..c34f06f746 100644
--- a/src/main/java/org/apache/juneau/releng/AppConfiguration.java
+++ b/src/main/java/org/apache/juneau/releng/AppConfiguration.java
@@ -21,7 +21,6 @@ import java.nio.file.Path;
import java.util.EnumMap;
import java.util.Map;
import java.util.Optional;
-import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import org.apache.juneau.commons.secret.SecretStore;
@@ -39,9 +38,8 @@ import org.apache.juneau.releng.engine.DropRcService;
import org.apache.juneau.releng.engine.ReleaseEngine;
import org.apache.juneau.releng.engine.RunStateStore;
import org.apache.juneau.releng.engine.StepRegistry;
-import org.apache.juneau.releng.log.LogBroadcaster;
import org.apache.juneau.releng.log.RunStateBroadcaster;
-import org.apache.juneau.releng.log.SseLogServlet;
+import org.apache.juneau.releng.log.RunStateSseServlet;
import org.apache.juneau.releng.milestone.GithubPrSource;
import org.apache.juneau.releng.milestone.MilestoneService;
import org.apache.juneau.releng.nexus.NexusStagingClient;
@@ -407,7 +405,7 @@ public class AppConfiguration {
@Value("${rm.staging.dir}") String stagingDir,
@Value("${rm.state.dir}") String stateDir) {
return new DropRcService(store, registry, runner, Path.of(stagingDir).resolve("git/juneau"), Path.of(stateDir),
- secrets.nexus(), target, engine::broadcaster);
+ secrets.nexus(), target, engine.runEvents());
}
/**
@@ -419,44 +417,22 @@ public class AppConfiguration {
}
/**
- * The SSE servlet — a plain HttpServlet, registered alongside RootRest. Serves the per-step console
- * channel keyed by {@code (version, stepId)} (resolving each step's log path from its
- * {@code StepState.logRef} rather than a run-level {@code logFile}), and the run-state channel keyed
- * by {@code version} alone (trailing segment {@code state}) that pushes rail-status snapshots to
- * every connected New-Release tab.
+ * The SSE servlet — a plain HttpServlet, registered alongside RootRest. Serves the run-state channel keyed
+ * by {@code version} (trailing segment {@code state}) that pushes rail-status snapshots to every connected
+ * New-Release tab. Step console output is not streamed; the console-output region polls it from
+ * {@link ReleaseRunRest}.
*/
@Bean
public ServletRegistrationBean<Servlet> sseLogRegistration(ReleaseEngine engine, RunStateStore store) {
- var servlet = new SseLogServlet(logPathForStep(store), broadcasterForStep(engine, store),
- engine::snapshotJson, stateBroadcasterForVersion(engine, store));
+ var servlet = new RunStateSseServlet(engine::snapshotJson, stateBroadcasterForVersion(engine, store));
return new ServletRegistrationBean<>(servlet, "/events/*");
}
- /**
- * That step's on-disk log path, or empty when there's no persisted run for {@code version} or that run
- * has no such {@code stepId}. Package-private for {@code AppConfigurationTest}.
- */
- static BiFunction<String, String, Optional<Path>> logPathForStep(RunStateStore store) {
- return (version, stepId) -> store.load(version).map(rs -> rs.step(stepId))
- .filter(ss -> ss != null && ss.logRef != null).map(ss -> store.stateDir().resolve(ss.logRef));
- }
-
- /**
- * That step's live {@link LogBroadcaster}, or empty when there's no persisted run for {@code version}
- * or that run has no such {@code stepId}. Returning empty (rather than always minting a broadcaster via
- * {@code engine.broadcaster()}'s {@code computeIfAbsent}) lets {@code SseLogServlet} take its immediate
- * "(no active run/step …)" branch for a bogus key instead of blocking a worker thread for the full
- * heartbeat interval. Package-private for {@code AppConfigurationTest}.
- */
- static BiFunction<String, String, Optional<LogBroadcaster>> broadcasterForStep(ReleaseEngine engine,
- RunStateStore store) {
- return (version, stepId) -> store.load(version).filter(rs -> rs.step(stepId) != null)
- .map(rs -> engine.broadcaster(version, stepId));
- }
-
/**
* That version's live {@link RunStateBroadcaster}, or empty when there's no persisted run for
- * {@code version} — same "no active run" fast-path rationale as {@link #broadcasterForStep} above.
+ * {@code version}. Returning empty (rather than always minting a broadcaster via
+ * {@code engine.stateBroadcaster()}'s {@code computeIfAbsent}) lets {@code RunStateSseServlet} take its immediate
+ * "(no active run …)" branch for a bogus version instead of blocking a worker thread for the full heartbeat interval.
* Package-private for {@code AppConfigurationTest}.
*/
static Function<String, Optional<RunStateBroadcaster>> stateBroadcasterForVersion(ReleaseEngine engine,
diff --git a/src/main/java/org/apache/juneau/releng/engine/DropRcService.java b/src/main/java/org/apache/juneau/releng/engine/DropRcService.java
index 333ae61008..877e1507d0 100644
--- a/src/main/java/org/apache/juneau/releng/engine/DropRcService.java
+++ b/src/main/java/org/apache/juneau/releng/engine/DropRcService.java
@@ -21,15 +21,16 @@ import java.nio.file.Path;
import java.time.Instant;
import java.util.List;
import java.util.Map;
-import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.apache.juneau.releng.config.TargetProfile;
-import org.apache.juneau.releng.log.LogBroadcaster;
+import org.apache.juneau.releng.log.RunEventStore;
import org.apache.juneau.releng.log.RunLog;
import org.apache.juneau.releng.nexus.NexusStagingClient;
import org.apache.juneau.releng.util.ProcessRunner;
import org.apache.juneau.releng.util.SvnArgs;
+import org.apache.juneau.rest.server.views.RunEvent.EndStatus;
+import org.apache.juneau.rest.server.views.RunEvent.Level;
/**
* The one coarse Drop-RC action: drop remote state, bump RC, reset from workspace-setup.
@@ -37,7 +38,7 @@ import org.apache.juneau.releng.util.SvnArgs;
public class DropRcService {
/**
- * Pseudo-step id under which Drop-RC's own log file + broadcaster are keyed (it isn't a registry step).
+ * Pseudo-step id under which Drop-RC's own log file is keyed (it isn't a registry step).
*/
public static final String LOG_STEP_ID = "drop-rc";
@@ -48,7 +49,7 @@ public class DropRcService {
private final Path stateDir;
private final NexusStagingClient nexus;
private final TargetProfile target;
- private final BiFunction<String, String, LogBroadcaster> broadcasterFn;
+ private final RunEventStore events;
/**
* Constructor injecting all of this service's collaborators.
@@ -57,8 +58,19 @@ public class DropRcService {
"java:S107" // Constructor-injected collaborators; a parameter object would obscure the wiring.
})
public DropRcService(RunStateStore store, StepRegistry registry, ProcessRunner runner, Path stagingRepo,
- Path stateDir, NexusStagingClient nexus, TargetProfile target,
- BiFunction<String, String, LogBroadcaster> broadcasterFn) {
+ Path stateDir, NexusStagingClient nexus, TargetProfile target) {
+ this(store, registry, runner, stagingRepo, stateDir, nexus, target, new RunEventStore(stateDir));
+ }
+
+ /**
+ * Constructor injecting all of this service's collaborators, including the run-view event store the engine writes to.
+ */
+ @SuppressWarnings({
+ "java:S107" // Constructor-injected collaborators; a parameter object would obscure the wiring.
+ })
+ public DropRcService(RunStateStore store, StepRegistry registry, ProcessRunner runner, Path stagingRepo,
+ Path stateDir, NexusStagingClient nexus, TargetProfile target, RunEventStore events) {
+ this.events = events;
this.store = store;
this.registry = registry;
this.runner = runner;
@@ -66,7 +78,6 @@ public class DropRcService {
this.stateDir = stateDir;
this.nexus = nexus;
this.target = target == null ? TargetProfile.prodDefault() : target;
- this.broadcasterFn = broadcasterFn == null ? (v, s) -> new LogBroadcaster() : broadcasterFn;
}
/**
@@ -74,7 +85,7 @@ public class DropRcService {
*/
private Consumer<String> logSink(RunState rs) {
var path = stateDir.resolve("logs/" + rs.version + "-RC" + rs.rc + "-" + LOG_STEP_ID + ".log");
- var log = new RunLog(path, broadcasterFn.apply(rs.version, LOG_STEP_ID));
+ var log = new RunLog(path);
log.reset();
return log.lineSink();
}
@@ -120,6 +131,9 @@ public class DropRcService {
runner.run(List.of("mvn", "-f", git + "/pom.xml", "release:rollback"), null, null);
rs.rcHistory.add(new RcHistoryEntry(rs.rc, Instant.now().toString(), reason));
+ events.endOpen(rs.version, EndStatus.SKIP);
+ events.note(rs.version, Level.WARN, "RC" + rs.rc + " dropped" + (reason == null || reason.isBlank() ? "" : ": " + reason)
+ + "; continuing with RC" + (rs.rc + 1), null, null);
rs.rc = rs.rc + 1;
rs.status = RunStatus.RUNNING;
rs.nexusRepoId = null;
diff --git a/src/main/java/org/apache/juneau/releng/engine/ReleaseEngine.java b/src/main/java/org/apache/juneau/releng/engine/ReleaseEngine.java
index da720de9e1..7840433f90 100644
--- a/src/main/java/org/apache/juneau/releng/engine/ReleaseEngine.java
+++ b/src/main/java/org/apache/juneau/releng/engine/ReleaseEngine.java
@@ -20,7 +20,9 @@ package org.apache.juneau.releng.engine;
import static org.apache.juneau.commons.utils.Shorts.*;
import java.nio.file.Path;
+import java.time.Duration;
import java.time.Instant;
+import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Map;
import java.util.Optional;
@@ -28,12 +30,17 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.juneau.marshall.marshaller.Json;
import org.apache.juneau.releng.config.TargetProfile;
import org.apache.juneau.releng.email.EmailService;
-import org.apache.juneau.releng.log.LogBroadcaster;
+import org.apache.juneau.releng.log.RunEventStore;
import org.apache.juneau.releng.log.RunLog;
import org.apache.juneau.releng.log.RunStateBroadcaster;
+import org.apache.juneau.releng.log.StepOutputSources;
import org.apache.juneau.releng.milestone.MilestoneService;
import org.apache.juneau.releng.nexus.NexusStagingClient;
import org.apache.juneau.releng.util.ProcessRunner;
+import org.apache.juneau.rest.server.views.ConsoleOutputSource;
+import org.apache.juneau.rest.server.views.RunEvent.DoneStatus;
+import org.apache.juneau.rest.server.views.RunEvent.EndStatus;
+import org.apache.juneau.rest.server.views.RunViewSource;
/**
* Single-active-run orchestrator. One run advances at a time; state is persisted after every step.
@@ -57,8 +64,11 @@ public class ReleaseEngine {
private final SecretResolver secrets;
private final TargetProfile target;
- // In-memory per-step broadcasters, keyed "version/stepId". Lost on restart; log files survive.
- private final Map<String, LogBroadcaster> broadcasters = new ConcurrentHashMap<>();
+ // Serves each step's log file to the console-output region; the log files themselves are the source of truth.
+ private final StepOutputSources stepOutputs;
+
+ // Each run's run-view events, persisted beside the step logs; the file is the source of truth.
+ private final RunEventStore events;
// In-memory per-run run-state broadcasters, keyed by version. Lost on restart; a reconnecting SSE
// client gets a fresh initial snapshot instead (see AppConfiguration's state resolver).
@@ -113,6 +123,8 @@ public class ReleaseEngine {
this.runner = runner;
this.branches = branches;
this.stateDir = stateDir;
+ this.stepOutputs = new StepOutputSources(store);
+ this.events = new RunEventStore(stateDir);
this.stagingRoot = stagingRoot;
this.repoDir = repoDir;
this.committerEmail = committerEmail;
@@ -163,10 +175,38 @@ public class ReleaseEngine {
}
/**
- * One broadcaster per (version, step).
+ * The console-output source for one step's log.
+ *
+ * @param version The run version.
+ * @param stepId The step id.
+ * @return The source, or empty when there is no such run or step, or the step has not written a log yet.
+ */
+ public Optional<ConsoleOutputSource> stepOutput(String version, String stepId) {
+ return stepOutputs.find(version, stepId);
+ }
+
+ /**
+ * The run-view source for one run.
+ *
+ * @param runId The run id: the version with its dots written as underscores.
+ * @return The source, or empty when there is no such run.
+ */
+ public Optional<RunViewSource> runViewSource(String runId) {
+ var run = store.load(runId.replace('_', '.')).filter(rs -> RunEventStore.runId(rs.version).equals(runId));
+ if (run.isEmpty())
+ run = store.loadAll().stream().filter(rs -> RunEventStore.runId(rs.version).equals(runId)).findFirst();
+ return run.map(rs -> events.source(rs.version, () -> isReleased(rs.version)));
+ }
+
+ /**
+ * The store this engine writes run-view events to; shared with {@link DropRcService}.
*/
- public LogBroadcaster broadcaster(String version, String stepId) {
- return broadcasters.computeIfAbsent(version + "/" + stepId, k -> new LogBroadcaster());
+ public RunEventStore runEvents() {
+ return events;
+ }
+
+ private boolean isReleased(String version) {
+ return store.load(version).map(rs -> rs.status == RunStatus.RELEASED).orElse(true);
}
/**
@@ -306,7 +346,7 @@ public class ReleaseEngine {
public Preview preview(String version, String stepId, Map<String, String> form) {
var rs = require(version);
var step = requireStep(stepId);
- return step.preview(context(rs, stepId, form, false));
+ return step.preview(context(rs, stepId, form, false, null));
}
/**
@@ -332,7 +372,8 @@ public class ReleaseEngine {
store.save(rs);
StepResult result;
- var ctx = context(rs, stepId, form, true); // true = reset (truncate) this step's log first
+ var attempt = events.begin(version, stepId, step.title(), registry.ids().indexOf(stepId) + 1);
+ var ctx = context(rs, stepId, form, true, attempt); // true = reset (truncate) this step's log first
ss.logRef = stepLogRelativePath(rs, stepId);
try {
result = step.apply(ctx);
@@ -361,6 +402,7 @@ public class ReleaseEngine {
if (gate != null) {
gate.status = StepStatus.SUCCEEDED;
gate.completedAt = ss.completedAt;
+ events.end(version, VOTE_GATE, EndStatus.OK, elapsedMs(gate.startedAt, gate.completedAt));
}
}
if (stepId.equals("finalize-run")) {
@@ -375,10 +417,48 @@ public class ReleaseEngine {
ss.error = result.message;
rs.status = RunStatus.FAILED;
}
+ recordOutcome(rs, step, ss, attempt);
store.save(rs);
return result;
}
+ /**
+ * Mirrors a step's settled state into the run-view: its test results, then how it ended. A step that finished its
+ * work but waits for a person (the vote gate, a review gate) stays open as {@code waiting}.
+ */
+ private void recordOutcome(RunState rs, ReleaseStep step, StepState ss, String attempt) {
+ var id = step.id();
+ if (step.runsTests()) {
+ var since = parseInstant(ss.startedAt);
+ if (since != null)
+ events.appendAll(rs.version, TestReportEvents.collect(stagingRoot.resolve("git/juneau"), since, attempt));
+ }
+ switch (ss.status) {
+ case AWAITING_VOTE, AWAITING_REVIEW -> events.waiting(rs.version, id, step.title());
+ case FAILED -> events.end(rs.version, id, EndStatus.FAIL, elapsedMs(ss.startedAt, Instant.now().toString()));
+ default -> events.end(rs.version, id, EndStatus.OK, elapsedMs(ss.startedAt, ss.completedAt));
+ }
+ if (ss.status == StepStatus.SUCCEEDED && id.equals("finalize-run"))
+ events.done(rs.version, DoneStatus.OK);
+ }
+
+ private static Instant parseInstant(String iso) {
+ try {
+ return iso == null ? null : Instant.parse(iso);
+ } catch (DateTimeParseException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Milliseconds between two ISO-8601 instants, or -1 when either is missing or unparseable.
+ */
+ private static long elapsedMs(String from, String to) {
+ var a = parseInstant(from);
+ var b = parseInstant(to);
+ return a == null || b == null ? -1 : Math.max(0, Duration.between(a, b).toMillis());
+ }
+
/**
* Mark a step SKIPPED (only steps whose registry entry is skippable).
*/
@@ -391,6 +471,8 @@ public class ReleaseEngine {
return StepResult.fail(stepId + " is not skippable.");
var ss = rs.step(stepId);
ss.status = StepStatus.SKIPPED;
+ events.begin(version, stepId, step.title(), registry.ids().indexOf(stepId) + 1);
+ events.end(version, stepId, EndStatus.SKIP, -1);
store.save(rs);
return StepResult.ok(stepId + " skipped.");
}
@@ -408,6 +490,7 @@ public class ReleaseEngine {
return StepResult.fail(stepId + " is not awaiting review.");
ss.status = StepStatus.SUCCEEDED;
ss.completedAt = Instant.now().toString();
+ events.end(version, stepId, EndStatus.OK, elapsedMs(ss.startedAt, ss.completedAt));
store.save(rs);
return StepResult.ok(stepId + " review confirmed.");
}
@@ -474,6 +557,7 @@ public class ReleaseEngine {
if (current != null && current.status == StepStatus.RUNNING) {
current.status = StepStatus.FAILED;
current.error = "interrupted by server restart";
+ events.end(rs.version, current.id, EndStatus.FAIL, -1);
rs.status = RunStatus.FAILED;
store.save(rs);
}
@@ -492,13 +576,13 @@ public class ReleaseEngine {
* {@code resetLog} is true (an actual apply/resume/re-run, never a preview), the log is truncated first
* so a re-run overwrites in place rather than appending after a stale prior invocation's output.
*/
- private StepContext context(RunState rs, String stepId, Map<String, String> form, boolean resetLog) {
+ private StepContext context(RunState rs, String stepId, Map<String, String> form, boolean resetLog, String attempt) {
var ctx = new StepContext();
ctx.run = rs;
ctx.runner = runner;
ctx.target = target;
ctx.nexus = secrets.nexus();
- var log = new RunLog(stateDir.resolve(stepLogRelativePath(rs, stepId)), broadcaster(rs.version, stepId));
+ var log = new RunLog(stateDir.resolve(stepLogRelativePath(rs, stepId)));
if (resetLog)
log.reset();
ctx.log = log.lineSink();
@@ -514,6 +598,8 @@ public class ReleaseEngine {
ctx.email = email;
ctx.milestone = milestone;
ctx.formInputs = form == null ? Map.of() : form;
+ if (attempt != null)
+ ctx.notes = (level, text, href) -> events.note(rs.version, level, text, href, attempt);
return ctx;
}
diff --git a/src/main/java/org/apache/juneau/releng/engine/ReleaseStep.java b/src/main/java/org/apache/juneau/releng/engine/ReleaseStep.java
index 45e536fa6b..d81ca6e144 100644
--- a/src/main/java/org/apache/juneau/releng/engine/ReleaseStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/ReleaseStep.java
@@ -53,6 +53,13 @@ public interface ReleaseStep {
return false;
}
+ /**
+ * Does apply() run Maven's test phase, leaving Surefire or Failsafe reports for the run-view?
+ */
+ default boolean runsTests() {
+ return false;
+ }
+
/**
* Compute the dry-run preview without mutating anything.
*/
diff --git a/src/main/java/org/apache/juneau/releng/engine/StepContext.java b/src/main/java/org/apache/juneau/releng/engine/StepContext.java
index 660e339750..84900fa8eb 100644
--- a/src/main/java/org/apache/juneau/releng/engine/StepContext.java
+++ b/src/main/java/org/apache/juneau/releng/engine/StepContext.java
@@ -28,6 +28,7 @@ import org.apache.juneau.releng.email.EmailService;
import org.apache.juneau.releng.milestone.MilestoneService;
import org.apache.juneau.releng.nexus.NexusStagingClient;
import org.apache.juneau.releng.util.ProcessRunner;
+import org.apache.juneau.rest.server.views.RunEvent.Level;
/**
* Injected into every {@link ReleaseStep#preview}/{@link ReleaseStep#apply}.
@@ -50,8 +51,47 @@ public class StepContext {
public NexusStagingClient nexus;
public EmailService email;
public MilestoneService milestone;
+ public Notes notes; // Null outside an apply (previews, tests); the note methods then do nothing.
public Map<String, String> formInputs; // developmentVersion, voteOutcome, tally, repoIdOverride, checklist...
+ /**
+ * Receives the notes a step records for the run-view; the engine binds it to the step being applied.
+ */
+ @FunctionalInterface
+ public interface Notes {
+ /**
+ * Records one note.
+ *
+ * @param level The note level.
+ * @param text The note text.
+ * @param href A link for the note, or null.
+ */
+ void note(Level level, String text, String href);
+ }
+
+ /**
+ * Records an informational note under this step in the run-view.
+ */
+ public void note(String text) {
+ note(text, null);
+ }
+
+ /**
+ * Records an informational note with a link under this step in the run-view.
+ */
+ public void note(String text, String href) {
+ if (notes != null)
+ notes.note(Level.INFO, text, href);
+ }
+
+ /**
+ * Records a warning note under this step in the run-view.
+ */
+ public void warnNote(String text) {
+ if (notes != null)
+ notes.note(Level.WARN, text, null);
+ }
+
/**
* Runs a subprocess with output teed to the SSE log (helper for step apply/preview implementations).
*/
diff --git a/src/main/java/org/apache/juneau/releng/engine/TestReportEvents.java b/src/main/java/org/apache/juneau/releng/engine/TestReportEvents.java
new file mode 100644
index 0000000000..632c0f55c2
--- /dev/null
+++ b/src/main/java/org/apache/juneau/releng/engine/TestReportEvents.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.juneau.releng.engine;
+
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import org.apache.juneau.rest.server.views.RunEvent;
+import org.apache.juneau.rest.server.views.report.ReportLimits;
+import org.apache.juneau.rest.server.views.report.ReportResult;
+import org.apache.juneau.rest.server.views.report.ReportTest;
+import org.apache.juneau.rest.server.views.report.SurefireReportReader;
+
+/**
+ * Turns the Surefire and Failsafe reports that a Maven step left in the staging clone into run-view test events.
+ *
+ * <p>
+ * The staging clone is a multi-module build, so the reports are spread over many {@code surefire-reports} folders. Only
+ * report files written since the step started are read, so a report left over from an earlier step is never attributed
+ * to this one.
+ */
+final class TestReportEvents {
+
+ private static final Set<String> REPORT_DIRS = Set.of("surefire-reports", "failsafe-reports");
+
+ // Build output and tool folders that never hold a report folder; skipping them keeps the walk short.
+ private static final Set<String> SKIPPED_DIRS = Set.of(".git", "node_modules", "classes", "test-classes", "generated-sources",
+ "generated-test-sources", "maven-status", "apidocs", "site", "archive-tmp", "lib");
+
+ private static final int MAX_DEPTH = 10;
+ private static final long CLOCK_SLACK_MS = 2000;
+
+ private TestReportEvents() {}
+
+ /**
+ * Reads the reports written under {@code root} since {@code since}.
+ *
+ * @param root The staging clone, or null.
+ * @param since When the step started.
+ * @param stepId The run-view step id the tests belong to.
+ * @return The events (a {@code replace} followed by the tests), or an empty list when no fresh report exists.
+ */
+ static List<RunEvent> collect(Path root, Instant since, String stepId) {
+ if (root == null || ! Files.isDirectory(root))
+ return List.of();
+ var limits = ReportLimits.DEFAULT;
+ var cutoff = since.toEpochMilli() - CLOCK_SLACK_MS;
+ var reader = new SurefireReportReader();
+ var tests = new ArrayList<ReportTest>();
+ var warnings = new ArrayList<String>();
+ var found = new boolean[1];
+ var capped = new boolean[1];
+ try {
+ Files.walkFileTree(root, Set.of(), MAX_DEPTH, new SimpleFileVisitor<>() {
+ @Override /* FileVisitor */
+ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
+ var name = dir.getFileName() == null ? "" : dir.getFileName().toString();
+ if (! dir.equals(root) && SKIPPED_DIRS.contains(name))
+ return FileVisitResult.SKIP_SUBTREE;
+ if (! REPORT_DIRS.contains(name))
+ return FileVisitResult.CONTINUE;
+ try (var files = Files.newDirectoryStream(dir, "TEST-*.xml")) {
+ for (var f : files) {
+ if (Files.getLastModifiedTime(f).toMillis() < cutoff)
+ continue;
+ found[0] = true;
+ if (tests.size() >= limits.maxTests()) {
+ capped[0] = true;
+ break;
+ }
+ var r = reader.read(f, limits);
+ tests.addAll(r.tests());
+ warnings.addAll(r.warnings());
+ }
+ }
+ return FileVisitResult.SKIP_SUBTREE;
+ }
+ });
+ } catch (IOException e) {
+ warnings.add("test reports unreadable: " + e.getClass().getSimpleName());
+ found[0] = true;
+ }
+ if (! found[0])
+ return List.of();
+ if (capped[0])
+ warnings.add("test reports truncated at " + limits.maxTests() + " tests");
+ return new ReportResult(reader.fw(), tests, warnings, capped[0], 0).toEvents(stepId);
+ }
+}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/BuildVerifyStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/BuildVerifyStep.java
index c1446bd59f..15763e9359 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/BuildVerifyStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/BuildVerifyStep.java
@@ -32,6 +32,11 @@ public class BuildVerifyStep implements ReleaseStep {
return "build-verify";
}
+ @Override
+ public boolean runsTests() {
+ return true;
+ }
+
@Override
public String title() {
return "Build & verify";
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/ComposeAnnouncementEmailStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/ComposeAnnouncementEmailStep.java
index 0322124e18..a3cec039ca 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/ComposeAnnouncementEmailStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/ComposeAnnouncementEmailStep.java
@@ -53,6 +53,7 @@ public class ComposeAnnouncementEmailStep implements ReleaseStep {
@Override
public StepResult apply(StepContext ctx) {
var path = ctx.email.compose(EmailTemplate.ANNOUNCEMENT, ctx.run, vars(ctx));
+ ctx.note("Composed the ANNOUNCEMENT email draft: " + path.getFileName());
return StepResult.ok("Opened draft: " + path);
}
}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/ComposeProposeEmailStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/ComposeProposeEmailStep.java
index cf74aeb090..bbb8fdf3b6 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/ComposeProposeEmailStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/ComposeProposeEmailStep.java
@@ -49,6 +49,7 @@ public class ComposeProposeEmailStep implements ReleaseStep {
@Override
public StepResult apply(StepContext ctx) {
var path = ctx.email.compose(EmailTemplate.PROPOSE, ctx.run);
+ ctx.note("Composed the PROPOSE email draft: " + path.getFileName());
return StepResult.ok("Opened draft: " + path);
}
}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/ComposeResultEmailStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/ComposeResultEmailStep.java
index 8821b65455..c52bac9b55 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/ComposeResultEmailStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/ComposeResultEmailStep.java
@@ -54,6 +54,7 @@ public class ComposeResultEmailStep implements ReleaseStep {
@Override
public StepResult apply(StepContext ctx) {
var path = ctx.email.compose(EmailTemplate.RESULT, ctx.run, vars(ctx));
+ ctx.note("Composed the RESULT email draft: " + path.getFileName());
return StepResult.ok("Opened draft: " + path);
}
}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/ComposeVoteEmailStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/ComposeVoteEmailStep.java
index 7670a54a0f..e36b983693 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/ComposeVoteEmailStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/ComposeVoteEmailStep.java
@@ -80,6 +80,7 @@ public class ComposeVoteEmailStep implements ReleaseStep {
if ("(unknown)".equals(data.get("commitHash")) || data.get("srcSha512").isBlank())
ctx.log.accept("Note: RC tag/checksums absent — composing draft with placeholders.");
var path = ctx.email.compose(EmailTemplate.VOTE, ctx.run, data);
+ ctx.note("Composed the VOTE email draft: " + path.getFileName());
return StepResult.ok("Opened draft: " + path);
}
}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/DeploySnapshotStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/DeploySnapshotStep.java
index b2b93d433f..4d37e8aa66 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/DeploySnapshotStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/DeploySnapshotStep.java
@@ -32,6 +32,11 @@ public class DeploySnapshotStep implements ReleaseStep {
return "deploy-snapshot";
}
+ @Override
+ public boolean runsTests() {
+ return true;
+ }
+
@Override
public String title() {
return "Deploy snapshot";
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/GithubReleaseCreateStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/GithubReleaseCreateStep.java
index 66e560d937..965256a42e 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/GithubReleaseCreateStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/GithubReleaseCreateStep.java
@@ -54,16 +54,21 @@ public class GithubReleaseCreateStep implements ReleaseStep {
public StepResult apply(StepContext ctx) {
var tag = "juneau-" + ctx.run.version + "-RC" + ctx.run.rc;
var env = Map.of("GH_TOKEN", ctx.githubToken);
+ var releaseUrl = "https://github.com/" + ctx.target.ghSlug() + "/releases/tag/" + tag;
// Idempotency: treat "already exists" as success.
var exists = ctx.runner.run(List.of("gh", "release", "view", tag, "--repo", ctx.target.ghSlug()), null,
env);
if (exists.ok()) {
ctx.log.accept("GitHub Release already exists for " + tag);
+ ctx.note("The GitHub release " + tag + " already exists", releaseUrl);
return StepResult.ok("Already exists.");
}
var notes = ctx.formInputs.getOrDefault("releaseNotes", "See release notes.");
var res = ctx.exec(List.of("gh", "release", "create", tag, "--repo", ctx.target.ghSlug(), "--title",
ctx.run.version, "--notes", notes), null, env);
- return res.ok() ? StepResult.ok("GitHub Release created.") : StepResult.fail("gh release create failed.");
+ if (! res.ok())
+ return StepResult.fail("gh release create failed.");
+ ctx.note("Created the GitHub release " + tag, releaseUrl);
+ return StepResult.ok("GitHub Release created.");
}
}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/NexusStagingCloseStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/NexusStagingCloseStep.java
index 27ca812c5a..f8edf4f8f3 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/NexusStagingCloseStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/NexusStagingCloseStep.java
@@ -67,6 +67,7 @@ public class NexusStagingCloseStep implements ReleaseStep {
ctx.run.nexusRepoId = id;
ctx.log.accept("Closing Nexus staging repo " + id);
ctx.nexus.close(id);
+ ctx.note("Closed Nexus staging repository " + id);
return StepResult.ok("Closed staging repo " + id + ".");
}
}
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePerformStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePerformStep.java
index e29b82b9b6..f447162831 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePerformStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePerformStep.java
@@ -32,6 +32,11 @@ public class ReleasePerformStep implements ReleaseStep {
return "release-perform";
}
+ @Override
+ public boolean runsTests() {
+ return true;
+ }
+
@Override
public String title() {
return "release:perform";
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePrepareStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePrepareStep.java
index 7aa68e164d..4bc57c8375 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePrepareStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/ReleasePrepareStep.java
@@ -34,6 +34,11 @@ public class ReleasePrepareStep implements ReleaseStep {
return "release-prepare";
}
+ @Override
+ public boolean runsTests() {
+ return true;
+ }
+
@Override
public String title() {
return "release:prepare";
diff --git a/src/main/java/org/apache/juneau/releng/engine/steps/TallyVoteResultStep.java b/src/main/java/org/apache/juneau/releng/engine/steps/TallyVoteResultStep.java
index e8df770f49..cde9048477 100644
--- a/src/main/java/org/apache/juneau/releng/engine/steps/TallyVoteResultStep.java
+++ b/src/main/java/org/apache/juneau/releng/engine/steps/TallyVoteResultStep.java
@@ -47,6 +47,12 @@ public class TallyVoteResultStep implements ReleaseStep {
if (!outcome.equals("passed") && !outcome.equals("rejected"))
return StepResult.fail("voteOutcome must be 'passed' or 'rejected'.");
ctx.log.accept("Vote outcome recorded: " + outcome);
+ var tally = ctx.formInputs.getOrDefault("tally", "").strip();
+ var line = tally.isEmpty() ? "" : " \u2014 " + tally.lines().findFirst().orElse("");
+ if (outcome.equals("passed"))
+ ctx.note("Vote passed" + line);
+ else
+ ctx.warnNote("Vote rejected" + line);
// 'rejected' is routed to Drop-RC by ReleaseEngine.applyStep, not here.
return StepResult.ok("Vote outcome: " + outcome + ".");
}
diff --git a/src/main/java/org/apache/juneau/releng/log/Broadcaster.java b/src/main/java/org/apache/juneau/releng/log/Broadcaster.java
index f420b461df..365cfd0477 100644
--- a/src/main/java/org/apache/juneau/releng/log/Broadcaster.java
+++ b/src/main/java/org/apache/juneau/releng/log/Broadcaster.java
@@ -20,9 +20,8 @@ package org.apache.juneau.releng.log;
import java.util.function.Consumer;
/**
- * Common subscribe shape shared by {@link LogBroadcaster} (console log lines) and
- * {@link RunStateBroadcaster} (run/step status snapshots) so {@link SseLogServlet}'s tail loop can serve
- * either channel without duplicating it.
+ * Subscribe shape of {@link RunStateBroadcaster} (run/step status snapshots), as consumed by
+ * {@link RunStateSseServlet}'s tail loop.
*/
public interface Broadcaster {
diff --git a/src/main/java/org/apache/juneau/releng/log/LogBroadcaster.java b/src/main/java/org/apache/juneau/releng/log/LogBroadcaster.java
deleted file mode 100644
index f683226955..0000000000
--- a/src/main/java/org/apache/juneau/releng/log/LogBroadcaster.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.juneau.releng.log;
-
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.function.Consumer;
-
-/**
- * Per-run in-memory pub/sub of output lines. Subscribers are SSE connections.
- */
-public class LogBroadcaster implements Broadcaster {
-
- private final List<Consumer<String>> subscribers = new CopyOnWriteArrayList<>();
-
- @Override
- public AutoCloseable subscribe(Consumer<String> sink) {
- subscribers.add(sink);
- return () -> subscribers.remove(sink);
- }
-
- /**
- * Sends {@code line} to every current subscriber.
- */
- public void publish(String line) {
- for (var s : subscribers) {
- try {
- s.accept(line);
- } catch (RuntimeException ignore) {
- /* a dead client must not break others */ }
- }
- }
-
- /**
- * Number of currently-subscribed SSE connections.
- */
- public int subscriberCount() {
- return subscribers.size();
- }
-}
diff --git a/src/main/java/org/apache/juneau/releng/log/RunEventStore.java b/src/main/java/org/apache/juneau/releng/log/RunEventStore.java
new file mode 100644
index 0000000000..518e8a1124
--- /dev/null
+++ b/src/main/java/org/apache/juneau/releng/log/RunEventStore.java
@@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.juneau.releng.log;
+
+import static org.apache.juneau.commons.utils.Shorts.*;
+
+import java.io.IOException;
+import java.lang.System.Logger.Level;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.BooleanSupplier;
+import org.apache.juneau.marshall.marshaller.Json;
+import org.apache.juneau.rest.server.views.FileRunViewSource;
+import org.apache.juneau.rest.server.views.RunEvent;
+import org.apache.juneau.rest.server.views.RunEvent.DoneStatus;
+import org.apache.juneau.rest.server.views.RunEvent.EndStatus;
+import org.apache.juneau.rest.server.views.RunEvent.StepState;
+import org.apache.juneau.rest.server.views.RunViewSource;
+
+/**
+ * Persists each release run's run-view events as one JSON Lines file, {@code logs/<version>-events.jsonl} under the state
+ * directory, and serves that file back to the run-view region.
+ *
+ * <p>
+ * The file is the only state: nothing is cached in memory, so a restart, or a second instance over the same directory,
+ * sees the same history. A run spans several candidates and many manual step invocations, so every invocation of a step
+ * becomes its own step in the stream. The first is {@code <stepId>}; a re-run or resume after the step ended is
+ * {@code <stepId>.2}, {@code <stepId>.3} and so on, shown as "(attempt N)". A step of the run-view model cannot reopen
+ * once it has ended, and keeping the earlier attempt visible is more honest than rewriting it.
+ *
+ * <p>
+ * A failure to write an event is logged and dropped; the run-view is a report on the release and must never stop it.
+ */
+public class RunEventStore {
+
+ private static final System.Logger LOG = System.getLogger(RunEventStore.class.getName());
+
+ // One lock per file across all instances, so two stores over one state directory cannot interleave a scan and an append.
+ private static final Map<Path,Object> LOCKS = new ConcurrentHashMap<>();
+
+ private final Path logsDir;
+ private final Map<Path,FileRunViewSource> sources = new ConcurrentHashMap<>();
+
+ /**
+ * Creates a store under {@code stateDir}.
+ *
+ * @param stateDir The state directory; the events live in its {@code logs} folder beside the step logs.
+ */
+ public RunEventStore(Path stateDir) {
+ this.logsDir = stateDir.resolve("logs");
+ }
+
+ /**
+ * The run-view id of a run: its version with dots written as underscores, since a run id has no dots.
+ *
+ * @param version The run version.
+ * @return The run id.
+ */
+ public static String runId(String version) {
+ return version.replace('.', '_');
+ }
+
+ /**
+ * Starts a new attempt of a step.
+ *
+ * @param version The run version.
+ * @param stepId The registry step id.
+ * @param title The step title.
+ * @param ordinal The step's 1-based position in the pipeline.
+ * @return The id of the attempt, which is what {@link #note} acts on. An earlier attempt of the step that is still open
+ * (a gate nobody resolved) is ended as skipped.
+ */
+ public String begin(String version, String stepId, String title, int ordinal) {
+ var file = file(version);
+ synchronized (lock(file)) {
+ var attempts = attempts(file, stepId);
+ var open = openIds(file);
+ for (var previous : attempts)
+ if (open.contains(previous))
+ append(file, RunEvent.end(previous, EndStatus.SKIP)); // superseded by this attempt
+ var attempt = attempts.isEmpty() ? 1 : attempts.size() + 1;
+ var id = attempt == 1 ? stepId : stepId + "." + attempt;
+ append(file, RunEvent.step(id, attempt == 1 ? title : title + " (attempt " + attempt + ")").withN(ordinal));
+ return id;
+ }
+ }
+
+ /**
+ * Marks the latest attempt of a step as blocked on a person.
+ *
+ * @param version The run version.
+ * @param stepId The registry step id.
+ * @param title The step title.
+ */
+ public void waiting(String version, String stepId, String title) {
+ var file = file(version);
+ synchronized (lock(file)) {
+ var attempts = attempts(file, stepId);
+ if (! attempts.isEmpty())
+ append(file, RunEvent.step(last(attempts), title).withState(StepState.WAITING));
+ }
+ }
+
+ /**
+ * Ends the latest attempt of a step; does nothing when the step never ran.
+ *
+ * @param version The run version.
+ * @param stepId The registry step id.
+ * @param status How it ended.
+ * @param ms The duration in milliseconds, or a negative number when unknown.
+ */
+ public void end(String version, String stepId, EndStatus status, long ms) {
+ var file = file(version);
+ synchronized (lock(file)) {
+ var attempts = attempts(file, stepId);
+ if (! attempts.isEmpty()) {
+ var e = RunEvent.end(last(attempts), status);
+ append(file, ms >= 0 ? e.withMs(ms) : e);
+ }
+ }
+ }
+
+ /**
+ * Ends every attempt that is still open, for example when a candidate is dropped.
+ *
+ * @param version The run version.
+ * @param status How they ended.
+ */
+ public void endOpen(String version, EndStatus status) {
+ var file = file(version);
+ synchronized (lock(file)) {
+ for (var open : openIds(file))
+ append(file, RunEvent.end(open, status));
+ }
+ }
+
+ /**
+ * Adds a note.
+ *
+ * @param version The run version.
+ * @param level The note level.
+ * @param text The text, clipped to the event limit.
+ * @param href An optional link, or null.
+ * @param attemptId The attempt the note belongs under, or null for the run.
+ */
+ public void note(String version, RunEvent.Level level, String text, String href, String attemptId) {
+ if (text == null || text.isBlank())
+ return;
+ var e = RunEvent.note(level, text.length() > 1000 ? text.substring(0, 999) + "…" : text);
+ if (href != null && ! href.isBlank())
+ e = e.withHref(href);
+ if (attemptId != null)
+ e = e.withStep(attemptId);
+ var file = file(version);
+ synchronized (lock(file)) {
+ append(file, e);
+ }
+ }
+
+ /**
+ * Appends events as they are, for example one step's test results.
+ *
+ * @param version The run version.
+ * @param events The events.
+ */
+ public void appendAll(String version, Collection<RunEvent> events) {
+ var file = file(version);
+ synchronized (lock(file)) {
+ for (var e : events)
+ append(file, e);
+ }
+ }
+
+ /**
+ * Marks the run finished.
+ *
+ * @param version The run version.
+ * @param status The final status.
+ */
+ public void done(String version, DoneStatus status) {
+ var file = file(version);
+ synchronized (lock(file)) {
+ append(file, RunEvent.done(status));
+ }
+ }
+
+ /**
+ * The source of a run's events.
+ *
+ * @param version The run version.
+ * @param terminal True once the run will produce no more events.
+ * @return The source, which reads an empty stream until the first event is written.
+ */
+ public RunViewSource source(String version, BooleanSupplier terminal) {
+ var file = file(version);
+ return sources.computeIfAbsent(file, f -> FileRunViewSource.create(f).terminal(terminal).build());
+ }
+
+ private Path file(String version) {
+ return logsDir.resolve(version + "-events.jsonl");
+ }
+
+ private static Object lock(Path file) {
+ return LOCKS.computeIfAbsent(file, f -> new Object());
+ }
+
+ private static String last(List<String> attempts) {
+ return attempts.get(attempts.size() - 1);
+ }
+
+ private static void append(Path file, RunEvent event) {
+ try {
+ Files.createDirectories(file.getParent());
+ Files.writeString(file, Json.DEFAULT.write(event.validate().toContractMap()) + "\n", StandardCharsets.UTF_8,
+ StandardOpenOption.CREATE, StandardOpenOption.APPEND);
+ } catch (IOException | RuntimeException e) {
+ LOG.log(Level.WARNING, "Dropped a run-view event for " + file.getFileName() + ": " + e.getMessage());
+ }
+ }
+
+ /**
+ * The ids of the attempts of {@code stepId}, oldest first.
+ */
+ private static List<String> attempts(Path file, String stepId) {
+ List<String> out = new ArrayList<>();
+ for (var id : scan(file).keySet())
+ if (id.equals(stepId) || (id.startsWith(stepId + ".") && id.substring(stepId.length() + 1).chars().allMatch(Character::isDigit)))
+ out.add(id);
+ return out;
+ }
+
+ private static List<String> openIds(Path file) {
+ List<String> out = new ArrayList<>();
+ scan(file).forEach((id, open) -> {
+ if (open)
+ out.add(id);
+ });
+ return out;
+ }
+
+ /**
+ * Every step id in the file in first-appearance order, mapped to whether it is still open.
+ */
+ private static Map<String,Boolean> scan(Path file) {
+ Map<String,Boolean> out = new LinkedHashMap<>();
+ if (! Files.isRegularFile(file))
+ return out;
+ try {
+ for (var line : Files.readAllLines(file, StandardCharsets.UTF_8)) {
+ if (! (line.contains("\"ev\":\"step\"") || line.contains("\"ev\":\"end\"")))
+ continue;
+ Map<?,?> m = Json.DEFAULT.read(line, Map.class);
+ var ev = m.get("ev");
+ var id = (String)m.get("id");
+ if ("step".equals(ev))
+ out.putIfAbsent(id, true);
+ else if ("end".equals(ev))
+ out.computeIfPresent(id, (k, v) -> false);
+ }
+ } catch (IOException | RuntimeException e) {
+ LOG.log(Level.WARNING, "Cannot scan " + file.getFileName() + ": " + e.getMessage());
+ }
+ return out;
+ }
+}
diff --git a/src/main/java/org/apache/juneau/releng/log/RunLog.java b/src/main/java/org/apache/juneau/releng/log/RunLog.java
index 2b0f637598..7a99b522da 100644
--- a/src/main/java/org/apache/juneau/releng/log/RunLog.java
+++ b/src/main/java/org/apache/juneau/releng/log/RunLog.java
@@ -28,19 +28,17 @@ import java.util.function.Consumer;
import org.apache.juneau.releng.engine.StepState;
/**
- * Appends output lines to the current RC's log file and fans them out to the {@link LogBroadcaster}.
+ * Appends output lines to the current RC's log file; the console-output region reads that file back (see {@link StepOutputSources}).
*/
public class RunLog {
private final Path file;
- private final LogBroadcaster broadcaster;
/**
- * Creates a log backed by {@code file}, fanning out appended lines to {@code broadcaster}.
+ * Creates a log backed by {@code file}.
*/
- public RunLog(Path file, LogBroadcaster broadcaster) {
+ public RunLog(Path file) {
this.file = file;
- this.broadcaster = broadcaster;
try {
Files.createDirectories(file.getParent());
} catch (IOException e) {
@@ -49,7 +47,7 @@ public class RunLog {
}
/**
- * Append one line (newline-terminated) to disk, flushed, then broadcast it live.
+ * Append one line (newline-terminated) to disk, flushed.
*/
public synchronized void append(String line) {
try {
@@ -58,12 +56,11 @@ public class RunLog {
} catch (IOException e) {
throw isex(e, "Cannot append to log %s", file);
}
- broadcaster.publish(line);
}
/**
* Truncates this step's log file to empty, so it always reflects only the most recent run. A no-op if
- * the file doesn't exist yet. Already-connected SSE clients keep seeing old lines until they reconnect.
+ * the file doesn't exist yet. A console already reading the old content is told to reload.
*/
public synchronized void reset() {
try {
@@ -97,11 +94,4 @@ public class RunLog {
public Path file() {
return file;
}
-
- /**
- * The {@link LogBroadcaster} this instance publishes appended lines to.
- */
- public LogBroadcaster broadcaster() {
- return broadcaster;
- }
}
diff --git a/src/main/java/org/apache/juneau/releng/log/SseLogServlet.java b/src/main/java/org/apache/juneau/releng/log/RunStateSseServlet.java
similarity index 54%
rename from src/main/java/org/apache/juneau/releng/log/SseLogServlet.java
rename to src/main/java/org/apache/juneau/releng/log/RunStateSseServlet.java
index 63bc23afff..5065ba62f7 100644
--- a/src/main/java/org/apache/juneau/releng/log/SseLogServlet.java
+++ b/src/main/java/org/apache/juneau/releng/log/RunStateSseServlet.java
@@ -20,83 +20,59 @@ package org.apache.juneau.releng.log;
import static org.apache.juneau.commons.utils.Shorts.*;
import java.io.IOException;
import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
import java.util.Optional;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
-import java.util.function.BiFunction;
import java.util.function.Function;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
/**
- * Streams {@code text/event-stream} for two channels — per-step console log, and run/step-status
- * snapshots — registered as one servlet since both live under the same {@code /events/*} URL space.
+ * Streams the run/step-status snapshots as {@code text/event-stream}: on connect the run's current snapshot, then
+ * every later snapshot from that version's {@link RunStateBroadcaster}. Step console output is not streamed here; the
+ * console-output region polls it from {@code ReleaseRunRest}.
*
- * <p>The console channel replays that step's on-disk log on connect, then tails that step's
- * {@link LogBroadcaster} live. The state channel (trailing segment {@value #STATE_SEGMENT}) sends the
- * run's current snapshot on connect, then tails that version's {@link RunStateBroadcaster} live.
- *
- * <p>Mapped at {@code /events/*}; the two trailing path segments are {@code {version}/{stepId}}, where
- * {@code {stepId}} may instead be the literal {@value #STATE_SEGMENT} to select the state channel.
+ * <p>Mapped at {@code /events/*}; the two trailing path segments are {@code {version}/state}.
*/
-public class SseLogServlet extends HttpServlet {
+public class RunStateSseServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final long HEARTBEAT_MS = 25_000;
/**
- * Trailing-segment sentinel selecting the run-state channel instead of a per-step console.
+ * The trailing path segment that selects the state channel.
*/
public static final String STATE_SEGMENT = "state";
/**
- * SSE comment frame sent when no log line arrives within the heartbeat interval (keeps the connection alive).
+ * An SSE comment frame, sent when nothing was published for {@value #HEARTBEAT_MS} ms, so proxies keep the
+ * connection open and a dead client is noticed by the failed write.
*/
public static final String HEARTBEAT = ": heartbeat\n\n";
- /**
- * (version, stepId) -> that step's current-RC log Path (from RunStateStore's StepState.logRef).
- */
- private final transient BiFunction<String, String, Optional<Path>> logPathForStep;
- /**
- * (version, stepId) -> that step's LogBroadcaster.
- */
- private final transient BiFunction<String, String, Optional<LogBroadcaster>> broadcasterForStep;
- /**
- * version -> that run's current snapshot, as JSON.
- */
private final transient Function<String, Optional<String>> initialStateJsonForVersion;
- /**
- * version -> that run's RunStateBroadcaster.
- */
private final transient Function<String, Optional<RunStateBroadcaster>> stateBroadcasterForVersion;
/**
- * Console-only constructor (no state channel); used where a caller has no run-state wiring to offer.
- */
- public SseLogServlet(BiFunction<String, String, Optional<Path>> logPathForStep,
- BiFunction<String, String, Optional<LogBroadcaster>> broadcasterForStep) {
- this(logPathForStep, broadcasterForStep, version -> Optional.empty(), version -> Optional.empty());
- }
-
- /**
- * Full constructor, wiring both the per-step console channel and the run-state channel.
+ * Wires the two lookups the state channel needs.
+ *
+ * @param initialStateJsonForVersion {@code version} to that run's current snapshot JSON, or empty when there is
+ * no persisted run.
+ * @param stateBroadcasterForVersion {@code version} to that run's live broadcaster, or empty when there is no
+ * persisted run.
*/
- public SseLogServlet(BiFunction<String, String, Optional<Path>> logPathForStep,
- BiFunction<String, String, Optional<LogBroadcaster>> broadcasterForStep,
- Function<String, Optional<String>> initialStateJsonForVersion,
+ public RunStateSseServlet(Function<String, Optional<String>> initialStateJsonForVersion,
Function<String, Optional<RunStateBroadcaster>> stateBroadcasterForVersion) {
- this.logPathForStep = logPathForStep;
- this.broadcasterForStep = broadcasterForStep;
this.initialStateJsonForVersion = initialStateJsonForVersion;
this.stateBroadcasterForVersion = stateBroadcasterForVersion;
}
/**
- * SSE frame for a (possibly multi-line) payload: each physical line gets its own {@code data:} prefix.
+ * Frames {@code payload} as one SSE event, one {@code data:} line per payload line.
+ *
+ * @param payload The event payload.
+ * @return The frame, ending in a blank line.
*/
public static String sse(String payload) {
var sb = new StringBuilder();
@@ -112,52 +88,25 @@ public class SseLogServlet extends HttpServlet {
})
protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
var seg = trailingTwoSegments(req.getPathInfo());
- var version = seg[0];
- var stepId = seg[1];
+ if (! STATE_SEGMENT.equals(seg[1])) {
+ resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
+ return;
+ }
resp.setContentType("text/event-stream");
resp.setCharacterEncoding("UTF-8");
resp.setHeader("Cache-Control", "no-cache");
resp.setHeader("Connection", "keep-alive");
try {
- var out = resp.getWriter();
-
- if (STATE_SEGMENT.equals(stepId)) {
- streamState(version, out);
- return;
- }
-
- // 1) Replay this step's on-disk log (handles reload, step reselection, restart, and post-vote
- // reconnect). Each step's log is dedicated to that step alone, so replay is always
- // small/bounded, never a whole-RC file.
- var logPath = logPathForStep.apply(version, stepId).orElse(null);
- if (logPath != null && Files.isRegularFile(logPath)) {
- for (var line : Files.readAllLines(logPath))
- out.print(sse(line));
- out.flush();
- }
-
- // 2) Tail live via that step's broadcaster.
- var bc = broadcasterForStep.apply(version, stepId).orElse(null);
- if (bc == null) {
- out.print(sse("(no active run/step for " + version + "/" + stepId + ")"));
- out.flush();
- return;
- }
- tail(bc, out);
+ streamState(seg[0], resp.getWriter());
} catch (IOException e) {
- // SSE is one-way and best-effort: a broken pipe (client navigated away) or an unreadable log
- // file just ends the stream. There's nothing to retry, so close quietly instead of letting the
- // exception escape doGet as a 500.
- if (!resp.isCommitted())
+ // SSE is one-way and best-effort: a broken pipe (client navigated away) just ends the stream.
+ // There's nothing to retry, so close quietly instead of letting the exception escape doGet as a 500.
+ if (! resp.isCommitted())
resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
}
- /**
- * The state channel: sends {@code version}'s current snapshot on connect, then tails that version's
- * {@link RunStateBroadcaster} live.
- */
private void streamState(String version, PrintWriter out) {
var initial = initialStateJsonForVersion.apply(version).orElse(null);
if (initial != null) {
@@ -173,9 +122,6 @@ public class SseLogServlet extends HttpServlet {
tail(bc, out);
}
- /**
- * Tails {@code bc} to {@code out}, emitting a heartbeat when idle, until the client disconnects.
- */
private void tail(Broadcaster bc, PrintWriter out) {
var queue = new LinkedBlockingQueue<String>();
var subscription = bc.subscribe(queue::offer);
@@ -206,7 +152,7 @@ public class SseLogServlet extends HttpServlet {
}
/**
- * Splits {@code /{version}/{stepId}} into {@code [version, stepId]}; either may be empty if absent.
+ * Splits {@code /{version}/{channel}} into {@code [version, channel]}; either may be empty if absent.
*/
private static String[] trailingTwoSegments(String pathInfo) {
if (ib(pathInfo))
diff --git a/src/main/java/org/apache/juneau/releng/log/StepOutputSources.java b/src/main/java/org/apache/juneau/releng/log/StepOutputSources.java
new file mode 100644
index 0000000000..8c20e1c7ee
--- /dev/null
+++ b/src/main/java/org/apache/juneau/releng/log/StepOutputSources.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.juneau.releng.log;
+
+import java.nio.file.Path;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.format.DateTimeParseException;
+import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.juneau.releng.engine.RunStateStore;
+import org.apache.juneau.releng.engine.StepState;
+import org.apache.juneau.rest.server.views.ConsoleOutputLine.Style;
+import org.apache.juneau.rest.server.views.ConsoleOutputSource;
+import org.apache.juneau.rest.server.views.FileConsoleOutputSource;
+import org.apache.juneau.rest.server.views.FileConsoleOutputSource.Status;
+
+/**
+ * Serves each release step's own log file as a console-output source.
+ *
+ * <p>
+ * The file path always comes from the persisted {@link StepState#logRef}, never from the request, so a request can
+ * only choose among the logs of runs and steps that exist. One {@link FileConsoleOutputSource} is kept per log file
+ * because its line index lives in the instance; the status header is recomputed from the stored step state on every
+ * request, so it follows the step as it runs and settles.
+ */
+public class StepOutputSources {
+
+ private final RunStateStore store;
+ private final Map<Path, FileConsoleOutputSource> sources = new ConcurrentHashMap<>();
+
+ /**
+ * Creates the registry over the store the engine persists runs to.
+ *
+ * @param store The run state store.
+ */
+ public StepOutputSources(RunStateStore store) {
+ this.store = store;
+ }
+
+ /**
+ * Finds the console-output source for one step's log.
+ *
+ * @param version The run version.
+ * @param stepId The step id.
+ * @return The source, or empty when there is no such run or step, or the step has not written a log yet.
+ */
+ public Optional<ConsoleOutputSource> find(String version, String stepId) {
+ var step = store.load(version).map(rs -> rs.step(stepId)).orElse(null);
+ if (step == null || step.logRef == null)
+ return Optional.empty();
+ var root = store.stateDir().toAbsolutePath().normalize();
+ var file = root.resolve(step.logRef).normalize();
+ if (! file.startsWith(root))
+ return Optional.empty();
+ return Optional.of(sources.computeIfAbsent(file, f -> FileConsoleOutputSource.create(f).status(() -> status(version, stepId)).build()));
+ }
+
+ /**
+ * Maps a step's persisted state onto the console header.
+ *
+ * <p>
+ * Only a step that has settled (succeeded, failed or skipped) or is parked waiting for a person is terminal, so the
+ * console stops polling then. A step that has not started yet stays non-terminal so its output appears when it runs.
+ *
+ * @param version The run version.
+ * @param stepId The step id.
+ * @return The status.
+ */
+ Status status(String version, String stepId) {
+ var step = store.load(version).map(rs -> rs.step(stepId)).orElse(null);
+ if (step == null)
+ return new Status("MISSING", Style.MUTED, true, null, null);
+ var started = parse(step.startedAt);
+ return switch (step.status) {
+ case PENDING -> new Status("PENDING", Style.MUTED, false, null, null);
+ case RUNNING -> new Status("RUNNING", Style.ACCENT, false, started, null);
+ case SUCCEEDED -> settled("SUCCEEDED", Style.SUCCESS, step, started);
+ case FAILED -> settled("FAILED", Style.ERROR, step, started);
+ case SKIPPED -> settled("SKIPPED", Style.MUTED, step, started);
+ case AWAITING_VOTE -> settled("AWAITING VOTE", Style.WARN, step, started);
+ case AWAITING_REVIEW -> settled("AWAITING REVIEW", Style.WARN, step, started);
+ };
+ }
+
+ private static Status settled(String state, Style style, StepState step, Instant started) {
+ var completed = parse(step.completedAt);
+ var duration = started != null && completed != null ? Duration.between(started, completed).toMillis() : null;
+ return new Status(state, style, true, started, duration);
+ }
+
+ private static Instant parse(String iso) {
+ if (iso == null)
+ return null;
+ try {
+ return Instant.parse(iso);
+ } catch (DateTimeParseException e) {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/org/apache/juneau/releng/rest/ReleaseRest.java b/src/main/java/org/apache/juneau/releng/rest/ReleaseRest.java
index a85f4be3d2..d32bb97cd2 100644
--- a/src/main/java/org/apache/juneau/releng/rest/ReleaseRest.java
+++ b/src/main/java/org/apache/juneau/releng/rest/ReleaseRest.java
@@ -43,6 +43,7 @@ import org.apache.juneau.rest.server.view.View;
import org.apache.juneau.rest.server.view.freemarker.FreemarkerMixin;
import org.apache.juneau.rest.server.view.freemarker.FreemarkerViewRenderer;
import org.apache.juneau.rest.server.view.freemarker.console.ConsoleFreemarkerMixin;
+import org.apache.juneau.rest.server.staticfile.WebJarsMixin;
import org.apache.juneau.rest.server.views.ViewsMixin;
import jakarta.servlet.http.HttpServletRequest;
@@ -60,9 +61,10 @@ import jakarta.servlet.http.HttpServletRequest;
* {@link DataTablesQuery#run} against a fresh {@link InMemoryBeanQueryContext} session built from
* {@link ReleaseListService#list()}. Toolkit assets are served by the composed {@link ViewsMixin} at this resource's
* mount and pulled in by the page's {@code toolkit="views"} pack; the composed {@link DataTablesMixin} serves the
- * {@code /juneau-datatables.js} glue that defines {@code JuneauDataTables.ajax()}.
+ * {@code /juneau-datatables.js} glue that defines {@code JuneauDataTables.ajax()}, and the composed {@link WebJarsMixin}
+ * serves the jQuery, DataTables and Buttons libraries the card's asset packs load.
*/
-@Rest(path = "/releases", title = "Releases", responseProcessors = FreemarkerViewRenderer.class, mixins = { ViewsMixin.class, DataTablesMixin.class })
+@Rest(path = "/releases", title = "Releases", responseProcessors = FreemarkerViewRenderer.class, mixins = { ViewsMixin.class, DataTablesMixin.class, WebJarsMixin.class })
public class ReleaseRest extends BasicRestResource {
/**
diff --git a/src/main/java/org/apache/juneau/releng/rest/ReleaseRunRest.java b/src/main/java/org/apache/juneau/releng/rest/ReleaseRunRest.java
index 20cd19b78c..6fce90eac8 100644
--- a/src/main/java/org/apache/juneau/releng/rest/ReleaseRunRest.java
+++ b/src/main/java/org/apache/juneau/releng/rest/ReleaseRunRest.java
@@ -20,7 +20,9 @@ package org.apache.juneau.releng.rest;
import static org.apache.juneau.commons.utils.Shorts.*;
import static org.apache.juneau.commons.utils.StringUtils.escapeForScript;
+import java.io.IOException;
import java.util.Map;
+import java.util.Optional;
import org.apache.juneau.commons.inject.Bean;
import org.apache.juneau.marshall.marshaller.Json;
import org.apache.juneau.http.Content;
@@ -28,10 +30,17 @@ import org.apache.juneau.http.Path;
import org.apache.juneau.http.response.Conflict;
import org.apache.juneau.http.response.NotFound;
import org.apache.juneau.rest.server.Mutating;
+import org.apache.juneau.rest.server.OpSwagger;
import org.apache.juneau.rest.server.Rest;
import org.apache.juneau.rest.server.RestGet;
import org.apache.juneau.rest.server.RestPost;
+import org.apache.juneau.rest.server.RestRequest;
+import org.apache.juneau.rest.server.RestResponse;
import org.apache.juneau.rest.server.servlet.BasicRestResource;
+import org.apache.juneau.rest.server.views.ConsoleOutputEndpoints;
+import org.apache.juneau.rest.server.views.RunViewMixin;
+import org.apache.juneau.rest.server.views.RunViewSource;
+import org.apache.juneau.rest.server.views.ViewsMixin;
import org.apache.juneau.rest.server.view.View;
import org.apache.juneau.rest.server.view.freemarker.FreemarkerMixin;
import org.apache.juneau.rest.server.view.freemarker.FreemarkerViewRenderer;
@@ -52,8 +61,8 @@ import jakarta.servlet.http.HttpServletRequest;
* history and access logs. The boundary refuses that shape from a hostile page; this closes the accidental use of it.
*/
@Rest(path = "/runs", title = "New Release", responseProcessors = FreemarkerViewRenderer.class,
- disableContentParam = "true")
-public class ReleaseRunRest extends BasicRestResource {
+ disableContentParam = "true", mixins = ViewsMixin.class)
+public class ReleaseRunRest extends BasicRestResource implements RunViewMixin {
private final ReleaseEngine engine;
private final DropRcService dropRc;
@@ -127,6 +136,35 @@ public class ReleaseRunRest extends BasicRestResource {
return escapeForScript(Json.of(meta));
}
+ /**
+ * One page of a step's console output, in the console-output lines contract. The step's own log file is the
+ * source, so the page reads the same lines after a restart as during the run.
+ */
+ @RestGet(path = "/{version}/steps/{stepId}/output/lines", summary = "Step console output lines", swagger = @OpSwagger(ignore = true))
+ public void outputLines(@Path("version") String version, @Path("stepId") String stepId, RestRequest req, RestResponse res)
+ throws IOException {
+ ConsoleOutputEndpoints.lines(engine.stepOutput(version, stepId), req, res);
+ }
+
+ /**
+ * The run-view events of a run, served by {@link RunViewMixin}. The run id is the version with its dots written as
+ * underscores, since a run id has no dots.
+ */
+ @Override /* RunViewMixin */
+ public Optional<RunViewSource> runViewSource(String runId, RestRequest req) {
+ return engine.runViewSource(runId);
+ }
+
+ /**
+ * A step's whole console output as JSONL, one line record per JSONL line, named {@code <version>-<stepId>.jsonl}
+ * with the version's dots written as underscores (the download name is a log id, which has no dots).
+ */
+ @RestGet(path = "/{version}/steps/{stepId}/output/download", summary = "Step console output download", swagger = @OpSwagger(ignore = true))
+ public void outputDownload(@Path("version") String version, @Path("stepId") String stepId, RestResponse res)
+ throws IOException {
+ ConsoleOutputEndpoints.download(engine.stepOutput(version, stepId), version.replace('.', '_') + "-" + stepId, res);
+ }
+
/**
* JSON RunState for polling / initial page data.
*/
diff --git a/src/main/resources/static/css/new-release.css b/src/main/resources/static/css/new-release.css
index dc15b52003..01b79de06d 100644
--- a/src/main/resources/static/css/new-release.css
+++ b/src/main/resources/static/css/new-release.css
@@ -32,8 +32,7 @@
triad is overridden by base.ftlh's nested <@token> declarations to this
app's own danger palette (matching .tag.armed/.pill.invalid) rather than
the framework's Bootstrap-maroon default, so both are reused as-is.
- 3. Per-step console styling (shared by all 3 options).
- 4. Layout-specific rules for option A (rail), B (stepper), C (datatable),
+ 3. Layout-specific rules for option A (rail), B (stepper), C (datatable),
clearly namespaced/commented per section.
========================================================================== */
@@ -136,67 +135,6 @@
white-space: nowrap;
}
-/* ==========================================================================
- Per-step console (shared by all 3 options)
- ========================================================================== */
-
-.rm-console {
- background: #1e1e1e;
- color: #d4d4d4;
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
- font-size: 0.75rem;
- line-height: 1.65;
- padding: 12px 14px;
- border-radius: var(--jc-radius);
- flex: 1 1 0%;
- min-height: 0;
- overflow-y: auto;
- white-space: pre-wrap;
- overflow-wrap: break-word;
-}
-
-.rm-console .l-cmd { color: #7ec9ff; }
-.rm-console .l-ok { color: #8fd19e; }
-.rm-console .l-warn { color: #e8c766; }
-.rm-console .l-muted { color: #9a9a9a; }
-
-.rm-console .rm-cursor {
- display: inline-block;
- width: 6px;
- height: 12px;
- background: #8fd19e;
- vertical-align: text-bottom;
- margin-left: 1px;
- animation: rm-blink 1s steps(1) infinite;
-}
-
-@keyframes rm-blink { 50% { opacity: 0; } }
-
-.rm-console-empty {
- color: #8a8a8a;
- font-style: italic;
- font-size: 0.75rem;
- font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
-}
-
-.rm-console-label {
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-size: 0.6875rem;
- text-transform: uppercase;
- letter-spacing: 0.3px;
- color: var(--jc-text-muted);
- margin: 14px 0 6px;
-}
-
-.rm-console-label .rm-console-hint {
- text-transform: none;
- letter-spacing: 0;
- font-size: 0.6875rem;
- color: var(--jc-text-muted);
-}
-
/* ==========================================================================
Shared step-detail bits (title row, description, action buttons)
========================================================================== */
@@ -285,6 +223,10 @@
OPTION A — left rail + right detail/console
========================================================================== */
+.rm-runview-card {
+ margin: 0 0 16px;
+}
+
.rm-rail-layout {
display: grid;
grid-template-columns: 340px minmax(0, 1fr);
@@ -355,8 +297,7 @@
}
.rm-detail-col > .rm-step-title-row,
-.rm-detail-col > .rm-actions-row,
-.rm-detail-col > .rm-console-label {
+.rm-detail-col > .rm-actions-row {
flex: 0 0 auto;
}
@@ -498,12 +439,6 @@ tr.step-detail-row td {
border-color: var(--jc-tag-amber-border);
}
-/* new-release.js renders the console into a <pre>, not the mockup's <div> —
- reset the browser default block margin so .rm-console's own padding governs spacing. */
-pre.rm-console {
- margin: 0;
-}
-
/* A review-gate step held after its read-only work ran — reuses the same paused affordance as the
vote gate, since both are "done its work, awaiting a human". */
.tag.status.awaiting-review {
diff --git a/src/main/resources/static/datatables/dataTables.dataTables.min.css b/src/main/resources/static/datatables/dataTables.dataTables.min.css
deleted file mode 100644
index a16238fe78..0000000000
--- a/src/main/resources/static/datatables/dataTables.dataTables.min.css
+++ /dev/null
@@ -1 +0,0 @@
-:root{--dt-row-selected: 13, 110, 253;--dt-row-selected-text: 255, 255, 255;--dt-row-selected-link: 9, 10, 11;--dt-row-stripe: 0, 0, 0;--dt-row-hover: 0, 0, 0;--dt-column-ordering: 0, 0, 0;--dt-html-background: white}:root.dark{--dt-html-background: rgb(33, 37, 41)}table.dataTable td.dt-control{text-align:center;cursor:pointer}table.dataTable td.dt-control:before{display:inline-block;box-sizing:border-box;content:"";border-top:5px solid transparent;border-left:10px solid rgba(0, 0, 0, 0. [...]
diff --git a/src/main/resources/static/datatables/dataTables.min.js b/src/main/resources/static/datatables/dataTables.min.js
deleted file mode 100644
index 7ef0c676ec..0000000000
--- a/src/main/resources/static/datatables/dataTables.min.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/*! DataTables 2.1.8
- * © SpryMedia Ltd - datatables.net/license
- */
-!function(n){"use strict";var a;"function"==typeof define&&define.amd?define(["jquery"],function(t){return n(t,window,document)}):"object"==typeof exports?(a=require("jquery"),"undefined"==typeof window?module.exports=function(t,e){return t=t||window,e=e||a(t),n(e,t,t.document)}:module.exports=n(a,window,window.document)):window.DataTable=n(jQuery,window,document)}(function(H,W,_){"use strict";function f(t){var e=parseInt(t,10);return!isNaN(e)&&isFinite(t)?e:null}function s(t,e,n,a){var [...]
\ No newline at end of file
diff --git a/src/main/resources/static/datatables/jquery.min.js b/src/main/resources/static/datatables/jquery.min.js
deleted file mode 100644
index 7f37b5d991..0000000000
--- a/src/main/resources/static/datatables/jquery.min.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! jQuery v3.7.1 | (c) OpenJS Foundation and other contributors | jquery.org/license */
-!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(ie,e){"use strict";var oe=[],r=Object.getPrototypeOf,ae=oe.slice,g=oe.flat?function(e){return oe.flat.call(e)}:function(e){return oe.concat.apply([],e)},s=oe.push,se=oe.indexOf,n={},i=n.toString,ue=n.hasOwnProperty,o=ue [...]
diff --git a/src/main/resources/static/js/new-release.js b/src/main/resources/static/js/new-release.js
index 43305e9102..2f14174af5 100644
--- a/src/main/resources/static/js/new-release.js
+++ b/src/main/resources/static/js/new-release.js
@@ -85,9 +85,20 @@
const metaEl = document.getElementById('nr-step-meta');
const STEP_META = metaEl ? JSON.parse(metaEl.textContent) : {};
- // Exactly one EventSource at a time — one console visible at a time. Switching the selected
- // step closes the old connection and opens a new one against that step's own /events/{version}/{stepId}.
- let es = null;
+ // The whole-run progress view: one run-view region, fed by the run's persisted event stream. It polls and
+ // stops itself once the run is released; the per-step console below is a separate region.
+ const runViewEl = document.getElementById('nr-runview');
+ if (runViewEl && globalThis.JuneauViews?.runView) {
+ JuneauViews.runView.mount(runViewEl, {
+ eventsUrl: '/rest/runs/juneau-run-view/' + encodeURIComponent(runViewEl.dataset.runId) + '/events',
+ refreshMs: 3000,
+ title: 'Run progress'
+ }, {});
+ }
+
+ // Exactly one console-output region at a time — one console visible at a time. Switching the selected
+ // step aborts the old region's controller (which destroys it) and mounts a new one over that step's own log.
+ let consoleAbort = null;
function statusOf(stepId) {
const el = layout.querySelector('.rm-rail-item[data-step="' + stepId + '"]');
@@ -145,13 +156,20 @@
}
function connectConsole(stepId) {
- if (es) es.close();
+ if (consoleAbort) consoleAbort.abort();
const consoleEl = document.getElementById('nr-console');
if (!consoleEl) return;
- consoleEl.textContent = '';
- // Replay-then-tail, scoped to this one step (SseLogServlet).
- es = new EventSource('/events/' + encodeURIComponent(version) + '/' + encodeURIComponent(stepId));
- es.onmessage = (e) => { consoleEl.textContent += e.data + '\n'; consoleEl.scrollTop = consoleEl.scrollHeight; };
+ const base = '/rest/runs/' + encodeURIComponent(version) + '/steps/' + encodeURIComponent(stepId) + '/output/';
+ const meta = STEP_META[stepId] || { title: stepId };
+ consoleAbort = new AbortController();
+ // The region polls the lines endpoint, tails while the step runs, and stops once the step settles.
+ JuneauViews.consoleOutput.mount(consoleEl, {
+ linesUrl: base + 'lines',
+ downloadUrl: base + 'download',
+ tail: 2000,
+ rows: 20,
+ title: meta.title + ' output'
+ }, { signal: consoleAbort.signal });
}
globalThis.nrSelect = function (stepId) {
@@ -160,8 +178,7 @@
document.getElementById('nr-detail').innerHTML =
'<div class="rm-step-title-row" id="nr-detail-title-row">' + topRowHtml(stepId, status) + '</div>' +
'<div class="rm-actions-row" id="nr-actions">' + renderActions(stepId, status) + '</div>' +
- '<div class="rm-console-label"><span>Console output — this step only</span></div>' +
- '<pre id="nr-console" class="rm-console"></pre>';
+ '<div id="nr-console"></div>';
connectConsole(stepId);
};
@@ -206,10 +223,10 @@
location.reload();
};
- // Live rail updates: a second EventSource, independent of the per-step console one above, so every
+ // Live rail updates: an EventSource, independent of the per-step console region above, so every
// connected New-Release tab — including a passive second browser that never clicks anything — tracks
// run/step status as it changes, with no polling or page reload. Opened once for the page's lifetime
- // (not reopened on step reselection); never touches #nr-console or its own EventSource.
+ // (not reopened on step reselection); never touches #nr-console.
const STATUS_CLASS = (s) => s.toLowerCase().replace(/_/g, '-');
// Swaps el's single status class for statusClass, leaving its other (non-status) classes alone. Used on
@@ -240,7 +257,7 @@
// Keep the currently-selected step's own status tag + action buttons correct (e.g. running ->
// succeeded unlocks Re-run; pending -> awaiting-vote swaps in the vote form) — but leave the console
- // <pre> and its EventSource alone; only reselecting a different step touches those (nrSelect above).
+ // region alone; only reselecting a different step touches it (nrSelect above).
if (selected) {
const status = STATUS_CLASS(selected.status);
const titleRow = document.getElementById('nr-detail-title-row');
diff --git a/src/main/resources/templates/new-release.ftlh b/src/main/resources/templates/new-release.ftlh
index e0e8e77a94..ba857fb6ed 100644
--- a/src/main/resources/templates/new-release.ftlh
+++ b/src/main/resources/templates/new-release.ftlh
@@ -18,7 +18,7 @@
<#assign _navTab = navTab!'new/input'>
<#assign _subtab = subtab!'input'>
<#assign hasRun = run??>
-<@page tab=_navTab css=assetUrl("/css/new-release.css") init=assetUrl("/js/new-release.js")>
+<@page tab=_navTab toolkit="views" css=assetUrl("/css/new-release.css") init=assetUrl("/js/new-release.js")>
<div class="jc-page-header">
<h1>New Release</h1>
<p class="jc-page-sub">Cut an Apache Juneau release candidate, from input through vote and publish.</p>
@@ -46,6 +46,10 @@
</div>
</div>
+ <div class="jc-card rm-runview-card">
+ <div id="nr-runview" data-run-id="${run.version?replace('.', '_')}"></div>
+ </div>
+
<div class="rm-rail-layout" data-version="${run.version}" data-rc="${run.rc}">
<div class="rm-rail-col" id="nr-rail">
<#list run.steps as s>
diff --git a/src/main/resources/templates/releases.ftlh b/src/main/resources/templates/releases.ftlh
index 0dd71c9619..5c4c259858 100644
--- a/src/main/resources/templates/releases.ftlh
+++ b/src/main/resources/templates/releases.ftlh
@@ -16,43 +16,35 @@
-->
<@page tab="releases" toolkit="views"
- css="/datatables/dataTables.dataTables.min.css,https://cdn.datatables.net/buttons/3.2.0/css/buttons.dataTables.min.css"
- init="/datatables/jquery.min.js,/datatables/dataTables.min.js,https://cdn.datatables.net/buttons/3.2.0/js/dataTables.buttons.min.js,https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js,https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js,https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.min.js,https://cdn.datatables.net/buttons/3.2.0/js/buttons.html5.min.js,/js/releases-detail.js">
+ init="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js,https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js,https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.min.js,/js/releases-detail.js">
<div class="jc-page-header">
<h1>All Releases</h1>
<p class="jc-page-sub">Every Apache Juneau release, from the current vote candidate back through GA history.</p>
</div>
- <@card type="datatables" id="releases">
+ <@card type="datatables" id="releases" requires="datatables-buttons">
{
- contractVersion: '1',
- layout: 'wide',
- view: {
- contractVersion: '5',
- id: 'releases',
- rowType: 'Release',
- dataMode: 'server',
- dataUrl: '/rest/releases/data',
- defaultOrder: [ { data: 'version', dir: 'desc' } ],
- columns: [
- { data: 'version', title: 'Version', orderable: true, searchable: true, className: 'version-cell', pinned: true },
- { data: 'rc', title: 'RC', orderable: true, searchable: true },
- { data: 'status', title: 'Status', orderable: true, searchable: true, render: { id: 'pill', meta: { field: 'status' } } },
- { data: 'stage', title: 'Stage', orderable: true, searchable: true, render: { id: 'pill', meta: { field: 'stage' } } },
- { data: 'voteCloses', title: 'Vote closes', orderable: true, searchable: true, render: { id: 'ts-zulu' }, formats: [ 'ts-zulu', 'datetime', 'date' ] },
- { data: 'released', title: 'Released', orderable: true, searchable: true, render: { id: 'date' }, formats: [ 'date', 'datetime', 'ts-zulu' ] },
- { data: 'githubReleaseUrl', title: 'GitHub', orderable: false, searchable: true, render: { id: 'linked' }, href: '{githubReleaseUrl}', defaultVisible: false },
- { data: 'milestoneUrl', title: 'Milestone', orderable: false, searchable: true, render: { id: 'linked' }, href: '{milestoneUrl}', defaultVisible: false }
- ],
- ribbon: [
- { type: 'option', id: 'dropped-only', title: 'Dropped only', group: 'filters', column: 'status', value: 'DROPPED', persist: true, symbol: 'filter_alt' },
- { type: 'export', buttons: [ 'copy', 'csv' ], optional: [ 'excel', 'pdf' ] },
- { type: 'refresh' }
- ],
- columnConfig: true,
- primary: true
- },
+ rowType: 'Release',
+ dataMode: 'server',
+ dataUrl: '/rest/releases/data',
+ defaultOrder: [ { data: 'version', dir: 'desc' } ],
+ columns: [
+ { data: 'version', title: 'Version', orderable: true, searchable: true, className: 'version-cell', pinned: true },
+ { data: 'rc', title: 'RC', orderable: true, searchable: true },
+ { data: 'status', title: 'Status', orderable: true, searchable: true, render: { id: 'pill', meta: { field: 'status' } } },
+ { data: 'stage', title: 'Stage', orderable: true, searchable: true, render: { id: 'pill', meta: { field: 'stage' } } },
+ { data: 'voteCloses', title: 'Vote closes', orderable: true, searchable: true, render: { id: 'ts-zulu' }, formats: [ 'ts-zulu', 'datetime', 'date' ] },
+ { data: 'released', title: 'Released', orderable: true, searchable: true, render: { id: 'date' }, formats: [ 'date', 'datetime', 'ts-zulu' ] },
+ { data: 'githubReleaseUrl', title: 'GitHub', orderable: false, searchable: true, render: { id: 'linked' }, href: '{githubReleaseUrl}', defaultVisible: false },
+ { data: 'milestoneUrl', title: 'Milestone', orderable: false, searchable: true, render: { id: 'linked' }, href: '{milestoneUrl}', defaultVisible: false }
+ ],
+ ribbon: [
+ { type: 'option', id: 'dropped-only', title: 'Dropped only', group: 'filters', column: 'status', value: '$eq(DROPPED)', persist: true, symbol: 'filter_alt' },
+ { type: 'export', buttons: [ 'copy', 'csv' ], optional: [ 'excel', 'pdf' ] },
+ { type: 'refresh' }
+ ],
+ columnConfig: true,
+ primary: true,
detail: {
- contractVersion: '1',
endpoint: '/rest/releases/expand/{id}',
icon: 'release',
title: '{version}',
diff --git a/src/test/java/org/apache/juneau/releng/AppConfigurationTest.java b/src/test/java/org/apache/juneau/releng/AppConfigurationTest.java
index b9d9139bb4..a9be561731 100644
--- a/src/test/java/org/apache/juneau/releng/AppConfigurationTest.java
+++ b/src/test/java/org/apache/juneau/releng/AppConfigurationTest.java
@@ -67,34 +67,6 @@ class AppConfigurationTest {
return ReleaseEngine.forTests(new RunStateStore(dir), StepRegistry.standard(branches), runner, branches, dir);
}
- @Test
- void a01_broadcasterResolverIsEmptyForUnknownVersionAndStep(@TempDir Path dir) {
- var store = new RunStateStore(dir);
- var eng = engine(dir);
- var resolver = AppConfiguration.broadcasterForStep(eng, store);
- assertTrue(resolver.apply("nope", "nope").isEmpty());
- }
-
- @Test
- void a02_broadcasterResolverIsEmptyForKnownVersionButUnknownStep(@TempDir Path dir) {
- var store = new RunStateStore(dir);
- var eng = engine(dir);
- eng.start("9.2.1", null);
- var resolver = AppConfiguration.broadcasterForStep(eng, store);
- assertTrue(resolver.apply("9.2.1", "not-a-real-step").isEmpty());
- }
-
- @Test
- void a03_broadcasterResolverIsPresentForRealActiveRunAndStep(@TempDir Path dir) {
- var store = new RunStateStore(dir);
- var eng = engine(dir);
- eng.start("9.2.1", null);
- var resolver = AppConfiguration.broadcasterForStep(eng, store);
- var bc = resolver.apply("9.2.1", "preflight");
- assertTrue(bc.isPresent());
- assertSame(eng.broadcaster("9.2.1", "preflight"), bc.get());
- }
-
@Test
void b01_stateBroadcasterResolverIsEmptyForUnknownVersion(@TempDir Path dir) {
var store = new RunStateStore(dir);
@@ -114,22 +86,6 @@ class AppConfigurationTest {
assertSame(eng.stateBroadcaster("9.2.1"), bc.get());
}
- @Test
- void c01_logPathResolverIsEmptyForUnknownVersionAndStep(@TempDir Path dir) {
- var store = new RunStateStore(dir);
- var resolver = AppConfiguration.logPathForStep(store);
- assertTrue(resolver.apply("nope", "nope").isEmpty());
- }
-
- @Test
- void c02_logPathResolverIsEmptyForKnownVersionButUnknownStep(@TempDir Path dir) {
- var store = new RunStateStore(dir);
- var eng = engine(dir);
- eng.start("9.2.1", null);
- var resolver = AppConfiguration.logPathForStep(store);
- assertTrue(resolver.apply("9.2.1", "not-a-real-step").isEmpty());
- }
-
@Test
void d01_nexusClientUsesKeychainCredsWhenBothPresent() {
var fallbackCalled = new boolean[] { false };
diff --git a/src/test/java/org/apache/juneau/releng/engine/DropRcServiceTest.java b/src/test/java/org/apache/juneau/releng/engine/DropRcServiceTest.java
index 19ff56cd07..297b47394f 100644
--- a/src/test/java/org/apache/juneau/releng/engine/DropRcServiceTest.java
+++ b/src/test/java/org/apache/juneau/releng/engine/DropRcServiceTest.java
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map;
import org.apache.juneau.marshall.marshaller.Json;
import org.apache.juneau.releng.config.TargetProfile;
-import org.apache.juneau.releng.log.LogBroadcaster;
import org.apache.juneau.releng.nexus.NexusStagingClient;
import org.apache.juneau.releng.util.ProcessRunner;
import org.junit.jupiter.api.Test;
@@ -79,7 +78,7 @@ class DropRcServiceTest {
seededThroughReleasePrepare(store);
var svc = new DropRcService(store, StepRegistry.standard(new BranchResolver(runner(), "/repo")), runner(),
Path.of("/staging/git/juneau"), dir, NexusStagingClient.forTests((m, p, b) -> ""),
- TargetProfile.prodDefault(), (v, s) -> new LogBroadcaster());
+ TargetProfile.prodDefault());
var preview = svc.preview("9.2.1");
assertTrue(preview.lines.stream().anyMatch(l -> l.contains("orgapachejuneau-1042")));
assertTrue(preview.lines.stream().anyMatch(l -> l.contains("juneau-9.2.1-RC1")));
@@ -92,7 +91,7 @@ class DropRcServiceTest {
seededThroughReleasePrepare(store);
var svc = new DropRcService(store, StepRegistry.standard(new BranchResolver(runner(), "/repo")), runner(),
Path.of("/staging/git/juneau"), dir, NexusStagingClient.forTests((m, p, b) -> ""),
- TargetProfile.prodDefault(), (v, s) -> new LogBroadcaster());
+ TargetProfile.prodDefault());
svc.apply("9.2.1", "vote rejected: -1 jdoe", () -> "avail", () -> "pw");
@@ -127,8 +126,7 @@ class DropRcServiceTest {
eng.stateBroadcaster("9.2.1").subscribe(json -> seen.add(Json.DEFAULT.read(json, RunStateSnapshot.class)));
var svc = new DropRcService(store, StepRegistry.standard(branches), runner(), Path.of("/staging/git/juneau"),
- dir, NexusStagingClient.forTests((m, p, b) -> ""), TargetProfile.prodDefault(),
- (v, s) -> new LogBroadcaster());
+ dir, NexusStagingClient.forTests((m, p, b) -> ""), TargetProfile.prodDefault());
svc.apply("9.2.1", "vote rejected: -1 jdoe", () -> "avail", () -> "pw");
diff --git a/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineRunViewTest.java b/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineRunViewTest.java
new file mode 100644
index 0000000000..3fdf1b4225
--- /dev/null
+++ b/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineRunViewTest.java
@@ -0,0 +1,333 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.juneau.releng.engine;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Consumer;
+import org.apache.juneau.releng.config.TargetProfile;
+import org.apache.juneau.releng.nexus.NexusStagingClient;
+import org.apache.juneau.releng.util.ProcessRunner;
+import org.apache.juneau.rest.server.views.RunEvent;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+/**
+ * The engine's mirror of each step into the run-view event stream: one step per invocation, how it ended, the notes it
+ * recorded, and the test results of the Maven steps.
+ */
+class ReleaseEngineRunViewTest {
+
+ private static final String V = "9.2.1";
+
+ private static final String REPORT = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <testsuite name="org.example.FooTest" tests="2" failures="%d" errors="0" skipped="0" time="0.5">
+ <testcase name="passes" classname="org.example.FooTest" time="0.1"/>
+ <testcase name="breaks" classname="org.example.FooTest" time="0.2">%s</testcase>
+ </testsuite>
+ """;
+
+ private ProcessRunner runner(Path dir, int verifyExit, boolean writeReport) {
+ return new ProcessRunner() {
+ @Override
+ public List<String> runLines(List<String> c) {
+ return List.of();
+ }
+
+ @Override
+ public String runText(List<String> c) {
+ return "";
+ }
+
+ @Override
+ public ProcResult run(List<String> c, String s, Map<String,String> e) {
+ if (c.contains("ls-remote"))
+ return new ProcResult(0, "sha\trefs/heads/juneau-9.2.1-branch\n");
+ if (c.contains("verify")) {
+ if (writeReport)
+ writeReport(dir, verifyExit != 0);
+ return new ProcResult(verifyExit, "");
+ }
+ return new ProcResult(0, "ok");
+ }
+
+ @Override
+ public ProcResult run(List<String> c, String s, Map<String,String> e, Consumer<String> k) {
+ return run(c, s, e);
+ }
+ };
+ }
+
+ private static Path reportsDir(Path dir) {
+ return dir.resolve("staging/git/juneau/juneau-core/target/surefire-reports");
+ }
+
+ private static Path writeReport(Path dir, boolean failing) {
+ try {
+ var reports = reportsDir(dir);
+ Files.createDirectories(reports);
+ var file = reports.resolve("TEST-org.example.FooTest.xml");
+ Files.writeString(file, REPORT.formatted(failing ? 1 : 0, failing ? "<failure message=\"boom\">trace</failure>" : ""));
+ return file;
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ private ReleaseEngine engine(Path dir, ProcessRunner runner) {
+ var branches = new BranchResolver(runner, "/repo");
+ return ReleaseEngine.forTests(new RunStateStore(dir), StepRegistry.standard(branches), runner, branches, dir);
+ }
+
+ private ReleaseEngine engine(Path dir) {
+ return engine(dir, runner(dir, 0, false));
+ }
+
+ private void satisfyAllPredecessorsOf(Path dir, String stepId) {
+ var store = new RunStateStore(dir);
+ var rs = store.load(V).orElseThrow();
+ var ids = StepRegistry.standard(new BranchResolver(runner(dir, 0, false), "/repo")).ids();
+ for (var i = 0; i < ids.indexOf(stepId); i++)
+ rs.step(ids.get(i)).status = StepStatus.SUCCEEDED;
+ store.save(rs);
+ }
+
+ private List<RunEvent> events(ReleaseEngine eng) {
+ return eng.runViewSource(V.replace('.', '_')).orElseThrow().page(null, 5000).events();
+ }
+
+ /** One compact token per event: {@code step:id}, {@code end:id:status}, {@code note:level:step}, {@code test:status}. */
+ private List<String> summary(ReleaseEngine eng) {
+ var out = new ArrayList<String>();
+ for (var e : events(eng)) {
+ var m = e.toContractMap();
+ switch (e.kind()) {
+ case STEP -> out.add("step:" + m.get("id") + (m.containsKey("status") ? ":" + m.get("status") : ""));
+ case END -> out.add("end:" + m.get("id") + ":" + m.get("status"));
+ case NOTE -> out.add("note:" + m.get("level") + ":" + m.get("step"));
+ case TEST -> out.add("test:" + m.get("status"));
+ default -> out.add(e.kind().name().toLowerCase());
+ }
+ }
+ return out;
+ }
+
+ private Map<String,Object> first(ReleaseEngine eng, RunEvent.Kind kind) {
+ return events(eng).stream().filter(e -> e.kind() == kind).findFirst().orElseThrow().toContractMap();
+ }
+
+ @Test
+ void a01_aSuccessfulStepIsAStepThenAnOkEnd(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+ eng.apply(V, "preflight", Map.of());
+
+ assertEquals(List.of("step:preflight", "end:preflight:ok"), summary(eng));
+ var step = first(eng, RunEvent.Kind.STEP);
+ assertEquals(1, step.get("n"));
+ assertEquals(eng.registry().byId("preflight").title(), step.get("title"));
+ assertTrue(first(eng, RunEvent.Kind.END).containsKey("ms"));
+ }
+
+ @Test
+ void a02_aFailedStepEndsFailAndAResumeIsANewAttempt(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "tally-vote-result");
+
+ assertFalse(eng.apply(V, "tally-vote-result", Map.of()).success);
+ assertTrue(eng.apply(V, "tally-vote-result", Map.of("voteOutcome", "passed", "tally", "+3 binding\nsecond line")).success);
+
+ assertEquals(List.of("step:tally-vote-result", "end:tally-vote-result:fail", "step:tally-vote-result.2",
+ "note:info:tally-vote-result.2", "end:tally-vote-result.2:ok"), summary(eng).stream().filter(s -> ! s.startsWith("end:vote-gate")).toList());
+ var steps = events(eng).stream().filter(e -> e.kind() == RunEvent.Kind.STEP).map(e -> (String)e.toContractMap().get("title")).toList();
+ assertEquals(List.of("Tally vote result", "Tally vote result (attempt 2)"), steps);
+ }
+
+ @Test
+ void a03_theVoteGateStaysOpenAsWaitingUntilTheTallyPasses(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "vote-gate");
+
+ eng.apply(V, "vote-gate", Map.of());
+ assertEquals(List.of("step:vote-gate", "step:vote-gate:waiting"), summary(eng));
+
+ eng.apply(V, "tally-vote-result", Map.of("voteOutcome", "passed", "tally", "+3 binding\nsecond line"));
+ var tail = summary(eng).subList(2, summary(eng).size());
+ assertEquals(List.of("step:tally-vote-result", "note:info:tally-vote-result", "end:vote-gate:ok", "end:tally-vote-result:ok"), tail);
+ var note = events(eng).stream().filter(e -> e.kind() == RunEvent.Kind.NOTE).findFirst().orElseThrow().toContractMap();
+ assertEquals("Vote passed — +3 binding", note.get("text"), "only the first line of the tally");
+ }
+
+ @Test
+ void a04_aRejectedTallyIsAWarningAndLeavesTheGateWaiting(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "vote-gate");
+ eng.apply(V, "vote-gate", Map.of());
+
+ eng.apply(V, "tally-vote-result", Map.of("voteOutcome", "rejected"));
+
+ var s = summary(eng);
+ assertTrue(s.contains("note:warn:tally-vote-result"), s.toString());
+ assertFalse(s.contains("end:vote-gate:ok"), s.toString());
+ }
+
+ @Test
+ void a05_aReviewGateWaitsThenEndsWhenConfirmed(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "javadoc-verify");
+
+ eng.apply(V, "javadoc-verify", Map.of());
+ assertEquals(List.of("step:javadoc-verify", "step:javadoc-verify:waiting"), summary(eng));
+
+ eng.confirmReview(V, "javadoc-verify");
+ assertEquals("end:javadoc-verify:ok", summary(eng).get(2));
+ }
+
+ @Test
+ void a06_aSkippedStepIsAStepThenASkipEnd(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+
+ eng.skip(V, "test-workspace-verify");
+
+ assertEquals(List.of("step:test-workspace-verify", "end:test-workspace-verify:skip"), summary(eng));
+ }
+
+ @Test
+ void a07_composedEmailsAreNotesUnderTheirStep(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "compose-propose-email");
+
+ eng.apply(V, "compose-propose-email", Map.of());
+
+ assertEquals(List.of("step:compose-propose-email", "note:info:compose-propose-email", "end:compose-propose-email:ok"), summary(eng));
+ var text = (String)first(eng, RunEvent.Kind.NOTE).get("text");
+ assertTrue(text.startsWith("Composed the PROPOSE email draft: "), text);
+ assertFalse(text.contains(dir.toString()), "a file name, not a path");
+ }
+
+ @Test
+ void b01_aMavenStepFeedsItsFreshSurefireReportsBeforeItEnds(@TempDir Path dir) {
+ var eng = engine(dir, runner(dir, 0, true));
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "build-verify");
+
+ eng.apply(V, "build-verify", Map.of());
+
+ assertEquals(List.of("step:build-verify", "replace", "test:pass", "test:pass", "end:build-verify:ok"), summary(eng));
+ var test = first(eng, RunEvent.Kind.TEST);
+ assertEquals("build-verify", test.get("step"));
+ assertEquals("surefire", test.get("fw"));
+ assertEquals("org.example.FooTest", test.get("suite"));
+ }
+
+ @Test
+ void b02_aFailingMavenStepKeepsTheFailedTestsAndEndsFail(@TempDir Path dir) {
+ var eng = engine(dir, runner(dir, 1, true));
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "build-verify");
+
+ assertFalse(eng.apply(V, "build-verify", Map.of()).success);
+
+ assertEquals(List.of("step:build-verify", "replace", "test:pass", "test:fail", "end:build-verify:fail"), summary(eng));
+ }
+
+ @Test
+ void b03_aReportLeftByAnEarlierRunIsNotAttributedToTheStep(@TempDir Path dir) throws IOException {
+ var stale = writeReport(dir, true);
+ Files.setLastModifiedTime(stale, FileTime.fromMillis(1_000));
+ var eng = engine(dir);
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "build-verify");
+
+ eng.apply(V, "build-verify", Map.of());
+
+ assertEquals(List.of("step:build-verify", "end:build-verify:ok"), summary(eng));
+ }
+
+ @Test
+ void c01_finalizingTheRunIsDoneAndMakesTheSourceTerminal(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "finalize-run");
+ var source = eng.runViewSource("9_2_1").orElseThrow();
+ assertFalse(source.page(null, 100).terminal());
+
+ eng.apply(V, "finalize-run", Map.of());
+
+ var s = summary(eng);
+ assertEquals(List.of("step:finalize-run", "end:finalize-run:ok", "done"), s);
+ assertTrue(eng.runViewSource("9_2_1").orElseThrow().page(null, 100).terminal());
+ }
+
+ @Test
+ void c02_aRunNobodyStartedHasNoSource(@TempDir Path dir) {
+ var eng = engine(dir);
+ eng.start(V, null);
+ assertTrue(eng.runViewSource("9_9_9").isEmpty());
+ assertTrue(eng.runViewSource("9_2_1").isPresent());
+ assertTrue(eng.runViewSource("9_2_1").orElseThrow().page(null, 100).events().isEmpty(), "nothing has run yet");
+ }
+
+ @Test
+ void c03_aStepInterruptedByARestartEndsFail(@TempDir Path dir) {
+ var eng = engine(dir);
+ var rs = eng.start(V, null);
+ eng.runEvents().begin(V, "preflight", "Preflight", 1);
+ var store = new RunStateStore(dir);
+ rs = store.load(V).orElseThrow();
+ rs.step("preflight").status = StepStatus.RUNNING;
+ rs.currentStepId = "preflight";
+ store.save(rs);
+
+ eng.recoverOnBoot();
+
+ assertEquals(List.of("step:preflight", "end:preflight:fail"), summary(eng));
+ }
+
+ @Test
+ void c04_droppingTheCandidateEndsOpenStepsAndSaysSo(@TempDir Path dir) {
+ var runner = runner(dir, 0, false);
+ var eng = engine(dir, runner);
+ eng.start(V, null);
+ satisfyAllPredecessorsOf(dir, "vote-gate");
+ eng.apply(V, "vote-gate", Map.of());
+ var drop = new DropRcService(new RunStateStore(dir), eng.registry(), runner, dir.resolve("staging/git/juneau"), dir,
+ NexusStagingClient.forTests((m, p, b) -> ""), TargetProfile.prodDefault(), eng.runEvents());
+
+ drop.apply(V, "vote rejected", () -> "me", () -> "pw");
+
+ var s = summary(eng);
+ assertEquals(List.of("step:vote-gate", "step:vote-gate:waiting", "end:vote-gate:skip", "note:warn:null"), s);
+ var text = (String)events(eng).get(events(eng).size() - 1).toContractMap().get("text");
+ assertEquals("RC1 dropped: vote rejected; continuing with RC2", text);
+ }
+}
diff --git a/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineTest.java b/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineTest.java
index cf5602c791..80364f4927 100644
--- a/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineTest.java
+++ b/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineTest.java
@@ -210,14 +210,13 @@ class ReleaseEngineTest {
}
@Test
- void b05_eachStepGetsItsOwnBroadcasterAndLogPath(@TempDir Path dir) {
+ void b05_eachStepGetsItsOwnLogPath(@TempDir Path dir) {
var eng = engine(dir);
eng.start("9.2.1", null);
eng.apply("9.2.1", "preflight", Map.of());
eng.apply("9.2.1", "compose-propose-email", Map.of());
eng.apply("9.2.1", "workspace-setup", Map.of());
assertNotEquals(eng.state("9.2.1").step("preflight").logRef, eng.state("9.2.1").step("workspace-setup").logRef);
- assertNotSame(eng.broadcaster("9.2.1", "preflight"), eng.broadcaster("9.2.1", "workspace-setup"));
}
/**
diff --git a/src/test/java/org/apache/juneau/releng/engine/TestReportEventsTest.java b/src/test/java/org/apache/juneau/releng/engine/TestReportEventsTest.java
new file mode 100644
index 0000000000..dbb78c551e
--- /dev/null
+++ b/src/test/java/org/apache/juneau/releng/engine/TestReportEventsTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.juneau.releng.engine;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileTime;
+import java.time.Instant;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+class TestReportEventsTest {
+
+ private static final String XML = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <testsuite name="org.example.FooTest" tests="1" failures="0" errors="0" skipped="0" time="0.1">
+ <testcase name="passes" classname="org.example.FooTest" time="0.1"/>
+ </testsuite>
+ """;
+
+ private static Path report(Path root, String module, String dirName) throws Exception {
+ var dir = root.resolve(module).resolve("target").resolve(dirName);
+ Files.createDirectories(dir);
+ return Files.writeString(dir.resolve("TEST-org.example.FooTest.xml"), XML);
+ }
+
+ @Test
+ void a01_aFreshReportBecomesTestEventsForTheStep(@TempDir Path root) throws Exception {
+ report(root, "core", "surefire-reports");
+ var events = TestReportEvents.collect(root, Instant.now().minusSeconds(60), "build");
+ assertTrue(events.stream().anyMatch(e -> "test".equals(e.toContractMap().get("ev"))), events.toString());
+ }
+
+ @Test
+ void a02_failsafeReportsAreReadToo(@TempDir Path root) throws Exception {
+ report(root, "it", "failsafe-reports");
+ assertFalse(TestReportEvents.collect(root, Instant.now().minusSeconds(60), "build").isEmpty());
+ }
+
+ @Test
+ void a03_aReportOlderThanTheStepIsIgnored(@TempDir Path root) throws Exception {
+ Files.setLastModifiedTime(report(root, "core", "surefire-reports"), FileTime.fromMillis(1_000));
+ assertTrue(TestReportEvents.collect(root, Instant.now(), "build").isEmpty());
+ }
+
+ @Test
+ void a04_noReportsOrNoDirectoryIsEmpty(@TempDir Path root) {
+ assertTrue(TestReportEvents.collect(root, Instant.now(), "build").isEmpty());
+ assertTrue(TestReportEvents.collect(root.resolve("missing"), Instant.now(), "build").isEmpty());
+ }
+
+ @Test
+ void a05_reportsUnderClassesAreNotWalked(@TempDir Path root) throws Exception {
+ var dir = root.resolve("core/target/classes/surefire-reports");
+ Files.createDirectories(dir);
+ Files.writeString(dir.resolve("TEST-x.xml"), XML);
+ assertTrue(TestReportEvents.collect(root, Instant.now().minusSeconds(60), "build").isEmpty());
+ }
+}
diff --git a/src/test/java/org/apache/juneau/releng/log/RunEventStoreTest.java b/src/test/java/org/apache/juneau/releng/log/RunEventStoreTest.java
new file mode 100644
index 0000000000..f4355c4635
--- /dev/null
+++ b/src/test/java/org/apache/juneau/releng/log/RunEventStoreTest.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.juneau.releng.log;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import org.apache.juneau.rest.server.views.RunEvent;
+import org.apache.juneau.rest.server.views.RunEvent.DoneStatus;
+import org.apache.juneau.rest.server.views.RunEvent.EndStatus;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+class RunEventStoreTest {
+
+ private static List<RunEvent> read(RunEventStore store, boolean terminal) {
+ return store.source("9.2.1", () -> terminal).page(null, 1000).events();
+ }
+
+ private static String ids(List<RunEvent> events) {
+ var sb = new StringBuilder();
+ for (var e : events) {
+ var m = e.toContractMap();
+ sb.append(m.get("ev")).append(':').append(m.getOrDefault("id", "")).append(m.containsKey("status") ? ":" + m.get("status") : "").append(' ');
+ }
+ return sb.toString().trim();
+ }
+
+ @Test
+ void a01_runIdReplacesDots() {
+ assertEquals("9_2_1", RunEventStore.runId("9.2.1"));
+ }
+
+ @Test
+ void a02_beginEndWritesAStepAndItsEnd(@TempDir Path dir) {
+ var store = new RunEventStore(dir);
+ assertEquals("build", store.begin("9.2.1", "build", "Build", 3));
+ store.end("9.2.1", "build", EndStatus.OK, 1200);
+ assertEquals("step:build end:build:ok", ids(read(store, false)));
+ }
+
+ @Test
+ void a03_aSecondAttemptGetsADottedIdAndTitle(@TempDir Path dir) {
+ var store = new RunEventStore(dir);
+ store.begin("9.2.1", "build", "Build", 3);
+ store.end("9.2.1", "build", EndStatus.FAIL, -1);
+ assertEquals("build.2", store.begin("9.2.1", "build", "Build", 3));
+ assertEquals("build.3", store.begin("9.2.1", "build", "Build", 3));
+ var events = read(store, false);
+ assertEquals("step:build end:build:fail step:build.2 end:build.2:skip step:build.3", ids(events));
+ assertEquals("Build (attempt 3)", events.get(4).toContractMap().get("title"));
+ }
+
+ @Test
+ void a04_waitingMarksTheLatestAttemptWaiting(@TempDir Path dir) {
+ var store = new RunEventStore(dir);
+ store.begin("9.2.1", "gate", "Gate", 1);
+ store.waiting("9.2.1", "gate", "Gate");
+ assertEquals("step:gate step:gate:waiting", ids(read(store, false)));
+ }
+
+ @Test
+ void a05_endOfAStepThatNeverRanIsIgnored(@TempDir Path dir) {
+ var store = new RunEventStore(dir);
+ store.end("9.2.1", "nope", EndStatus.OK, 1);
+ assertTrue(read(store, false).isEmpty());
+ }
+
+ @Test
+ void a06_endOpenEndsEveryOpenAttempt(@TempDir Path dir) {
+ var store = new RunEventStore(dir);
+ store.begin("9.2.1", "a", "A", 1);
+ store.begin("9.2.1", "b", "B", 2);
+ store.end("9.2.1", "a", EndStatus.OK, 1);
+ store.endOpen("9.2.1", EndStatus.SKIP);
+ assertEquals("step:a step:b end:a:ok end:b:skip", ids(read(store, false)));
+ }
+
+ @Test
+ void a07_noteIsClippedAndBlankNotesAreDropped(@TempDir Path dir) {
+ var store = new RunEventStore(dir);
+ store.note("9.2.1", RunEvent.Level.INFO, "x".repeat(5000), null, null);
+ store.note("9.2.1", RunEvent.Level.INFO, " ", null, null);
+ store.note("9.2.1", RunEvent.Level.WARN, "see", "https://example.org/r", null);
+ var events = read(store, false);
+ assertEquals(2, events.size());
+ assertEquals(1000, ((String)events.get(0).toContractMap().get("text")).length());
+ assertEquals("https://example.org/r", events.get(1).toContractMap().get("href"));
+ }
+
+ @Test
+ void a08_theSourceIsTerminalWhenTheSupplierSaysSo(@TempDir Path dir) {
+ var store = new RunEventStore(dir);
+ store.done("9.2.1", DoneStatus.OK);
+ assertEquals(1, read(store, false).size());
+ assertTrue(new RunEventStore(dir).source("9.2.1", () -> true).page(null, 10).terminal());
+ }
+
+ @Test
+ void a09_aNewInstanceOverTheSameDirectoryContinuesTheHistory(@TempDir Path dir) {
+ new RunEventStore(dir).begin("9.2.1", "build", "Build", 1);
+ assertEquals("build.2", new RunEventStore(dir).begin("9.2.1", "build", "Build", 1));
+ assertTrue(Files.isRegularFile(dir.resolve("logs/9.2.1-events.jsonl")));
+ }
+
+ @Test
+ void a10_anUnwritableDirectoryNeverThrows(@TempDir Path dir) throws Exception {
+ Files.writeString(dir.resolve("logs"), "a file where the folder should be");
+ var store = new RunEventStore(dir);
+ assertDoesNotThrow(() -> store.begin("9.2.1", "build", "Build", 1));
+ }
+}
diff --git a/src/test/java/org/apache/juneau/releng/log/RunLogTest.java b/src/test/java/org/apache/juneau/releng/log/RunLogTest.java
index e64650674a..d931f79c7a 100644
--- a/src/test/java/org/apache/juneau/releng/log/RunLogTest.java
+++ b/src/test/java/org/apache/juneau/releng/log/RunLogTest.java
@@ -20,8 +20,6 @@ package org.apache.juneau.releng.log;
import static org.junit.jupiter.api.Assertions.*;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -31,50 +29,33 @@ class RunLogTest {
// convention is applied by the caller when constructing one RunLog per step.
@Test
- @SuppressWarnings({
- "try" // Subscription is held only so close() unsubscribes at scope exit; the body never reads it.
- })
- void a01_appendsToDiskAndFansOutToBroadcaster(@TempDir Path dir) throws Exception {
- var bc = new LogBroadcaster();
- var got = new ArrayList<String>();
- try (var subscription = bc.subscribe(got::add)) {
- var log = new RunLog(dir.resolve("9.2.1-RC1-preflight.log"), bc);
+ void a01_appendsToDiskOneLinePerAppend(@TempDir Path dir) throws Exception {
+ var log = new RunLog(dir.resolve("9.2.1-RC1-preflight.log"));
- log.append("line one");
- log.append("line two");
+ log.append("line one");
+ log.append("line two");
- var onDisk = Files.readString(dir.resolve("9.2.1-RC1-preflight.log"));
- assertEquals("line one\nline two\n", onDisk);
- assertEquals(List.of("line one", "line two"), got);
- }
+ assertEquals("line one\nline two\n", Files.readString(dir.resolve("9.2.1-RC1-preflight.log")));
}
@Test
void a02_sizeReportsCurrentByteOffset(@TempDir Path dir) {
- var log = new RunLog(dir.resolve("9.2.1-RC1-preflight.log"), new LogBroadcaster());
+ var log = new RunLog(dir.resolve("9.2.1-RC1-preflight.log"));
log.append("abc");
assertEquals(4, log.size()); // "abc\n"
}
@Test
- @SuppressWarnings({
- "try" // Subscription is held only so close() unsubscribes at scope exit; the body never reads it.
- })
- void a03_lineSinkFeedsBothDiskAndBroadcaster(@TempDir Path dir) throws Exception {
- var bc = new LogBroadcaster();
- var got = new ArrayList<String>();
- try (var subscription = bc.subscribe(got::add)) {
- var log = new RunLog(dir.resolve("9.2.1-RC1-preflight.log"), bc);
- log.lineSink().accept("x");
- assertEquals("x\n", Files.readString(dir.resolve("9.2.1-RC1-preflight.log")));
- assertEquals(List.of("x"), got);
- }
+ void a03_lineSinkAppendsToDisk(@TempDir Path dir) throws Exception {
+ var log = new RunLog(dir.resolve("9.2.1-RC1-preflight.log"));
+ log.lineSink().accept("x");
+ assertEquals("x\n", Files.readString(dir.resolve("9.2.1-RC1-preflight.log")));
}
@Test
void b01_resetTruncatesOnDiskContentForInPlaceOverwrite(@TempDir Path dir) throws Exception {
// An ad-hoc re-run overwrites the step's log from scratch.
- var log = new RunLog(dir.resolve("9.2.1-RC1-release-prepare.log"), new LogBroadcaster());
+ var log = new RunLog(dir.resolve("9.2.1-RC1-release-prepare.log"));
log.append("first invocation, line 1");
log.append("first invocation, line 2");
@@ -88,7 +69,7 @@ class RunLogTest {
void b02_resetOnANeverWrittenLogIsANoOp(@TempDir Path dir) {
// A step's first-ever invocation also calls reset() before appending; must not fail
// just because the file doesn't exist yet.
- var log = new RunLog(dir.resolve("9.2.1-RC1-build-verify.log"), new LogBroadcaster());
+ var log = new RunLog(dir.resolve("9.2.1-RC1-build-verify.log"));
assertDoesNotThrow(log::reset);
log.append("first line ever");
assertEquals("first line ever\n", contentsOrEmpty(dir.resolve("9.2.1-RC1-build-verify.log")));
diff --git a/src/test/java/org/apache/juneau/releng/log/SseLogServletTest.java b/src/test/java/org/apache/juneau/releng/log/RunStateSseServletTest.java
similarity index 76%
rename from src/test/java/org/apache/juneau/releng/log/SseLogServletTest.java
rename to src/test/java/org/apache/juneau/releng/log/RunStateSseServletTest.java
index b33b3bbfde..15b227ce53 100644
--- a/src/test/java/org/apache/juneau/releng/log/SseLogServletTest.java
+++ b/src/test/java/org/apache/juneau/releng/log/RunStateSseServletTest.java
@@ -29,27 +29,27 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.junit.jupiter.api.Test;
-class SseLogServletTest {
+class RunStateSseServletTest {
@Test
void a01_framesALineAsAnSseDataEvent() {
- assertEquals("data: hello\n\n", SseLogServlet.sse("hello"));
+ assertEquals("data: hello\n\n", RunStateSseServlet.sse("hello"));
}
@Test
void a02_framesMultilinePayloadWithPerLineDataPrefix() {
- assertEquals("data: a\ndata: b\n\n", SseLogServlet.sse("a\nb"));
+ assertEquals("data: a\ndata: b\n\n", RunStateSseServlet.sse("a\nb"));
}
@Test
void a03_heartbeatIsAnSseComment() {
- assertEquals(": heartbeat\n\n", SseLogServlet.HEARTBEAT);
+ assertEquals(": heartbeat\n\n", RunStateSseServlet.HEARTBEAT);
}
@Test
void a04_stateSegmentConstantIsNeverARealStepId() {
- // StepRegistry.standard()'s 24 step ids never collide with this; doGet's routing relies on that.
- assertEquals("state", SseLogServlet.STATE_SEGMENT);
+ // the state channel is selected by this trailing segment.
+ assertEquals("state", RunStateSseServlet.STATE_SEGMENT);
}
private HttpServletRequest requestFor(String pathInfo) {
@@ -68,29 +68,24 @@ class SseLogServletTest {
}
@Test
- void b01_consoleOnlyConstructorTreatsStateSegmentAsNoActiveRun() throws IOException {
- // The 2-arg (pre-existing) constructor defaults the state resolvers to always-empty, so a client
- // hitting .../state against a servlet built the old way gets the same graceful fallback as an
- // unknown step — never a 500 or an unrecognized-route surprise.
- var servlet = new SseLogServlet((v, s) -> Optional.empty(), (v, s) -> Optional.empty());
- var capture = new java.io.StringWriter();
- var out = new PrintWriter(capture);
+ void b01_aChannelOtherThanStateIs404() {
+ var servlet = new RunStateSseServlet(v -> Optional.empty(), v -> Optional.empty());
+ var resp = mock(HttpServletResponse.class);
- servlet.doGet(requestFor("/9.2.1/state"), responseWriting(out));
+ servlet.doGet(requestFor("/9.2.1/preflight"), resp);
- assertEquals(SseLogServlet.sse("(no active run for 9.2.1)"), capture.toString());
+ verify(resp).setStatus(HttpServletResponse.SC_NOT_FOUND);
}
@Test
void b02_stateChannelSendsNoActiveRunWhenNoBroadcasterResolves() throws IOException {
- var servlet = new SseLogServlet((v, s) -> Optional.empty(), (v, s) -> Optional.empty(),
- v -> Optional.empty(), v -> Optional.empty());
+ var servlet = new RunStateSseServlet(v -> Optional.empty(), v -> Optional.empty());
var capture = new java.io.StringWriter();
var out = new PrintWriter(capture);
servlet.doGet(requestFor("/9.2.1/state"), responseWriting(out));
- assertEquals(SseLogServlet.sse("(no active run for 9.2.1)"), capture.toString());
+ assertEquals(RunStateSseServlet.sse("(no active run for 9.2.1)"), capture.toString());
}
/**
@@ -138,8 +133,7 @@ class SseLogServletTest {
var writer = new FailableWriter(initialSeen, updateSeen);
try (var out = new PrintWriter(writer)) {
var bc = new RunStateBroadcaster();
- var servlet = new SseLogServlet((v, s) -> Optional.empty(), (v, s) -> Optional.empty(),
- v -> Optional.of("INITIAL_SNAPSHOT"), v -> Optional.of(bc));
+ var servlet = new RunStateSseServlet(v -> Optional.of("INITIAL_SNAPSHOT"), v -> Optional.of(bc));
var req = requestFor("/9.2.1/state");
var resp = responseWriting(out);
@@ -162,7 +156,7 @@ class SseLogServletTest {
worker.join(2000);
assertFalse(worker.isAlive(), "the tail loop must exit once writes to the client start failing");
- assertEquals(SseLogServlet.sse("INITIAL_SNAPSHOT") + SseLogServlet.sse("UPDATED_SNAPSHOT"),
+ assertEquals(RunStateSseServlet.sse("INITIAL_SNAPSHOT") + RunStateSseServlet.sse("UPDATED_SNAPSHOT"),
writer.captured.toString());
}
}
diff --git a/src/test/java/org/apache/juneau/releng/log/StepOutputSourcesTest.java b/src/test/java/org/apache/juneau/releng/log/StepOutputSourcesTest.java
new file mode 100644
index 0000000000..b581e5bef6
--- /dev/null
+++ b/src/test/java/org/apache/juneau/releng/log/StepOutputSourcesTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juneau.releng.log;
+
+import static org.junit.jupiter.api.Assertions.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import org.apache.juneau.releng.engine.RunState;
+import org.apache.juneau.releng.engine.RunStateStore;
+import org.apache.juneau.releng.engine.StepStatus;
+import org.apache.juneau.rest.server.views.ConsoleOutputLine.Style;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+class StepOutputSourcesTest {
+
+ private static final String VERSION = "9.2.1";
+ private static final String STEP = "preflight";
+
+ private RunStateStore storeWithRun(Path dir, StepStatus status, String logRef) {
+ var store = new RunStateStore(dir);
+ var rs = RunState.create(VERSION, "juneau-9.2.1-branch", List.of(STEP, "workspace-setup"));
+ var step = rs.step(STEP);
+ step.status = status;
+ step.logRef = logRef;
+ step.startedAt = "2026-10-08T10:00:00Z";
+ if (status != StepStatus.RUNNING && status != StepStatus.PENDING)
+ step.completedAt = "2026-10-08T10:01:23Z";
+ store.save(rs);
+ return store;
+ }
+
+ @Test
+ void a01_unknownRunStepOrNeverWrittenLogHasNoSource(@TempDir Path dir) {
+ var store = storeWithRun(dir, StepStatus.PENDING, null);
+ var sources = new StepOutputSources(store);
+ assertTrue(sources.find("nope", STEP).isEmpty());
+ assertTrue(sources.find(VERSION, "not-a-step").isEmpty());
+ assertTrue(sources.find(VERSION, STEP).isEmpty(), "no logRef until the step first runs");
+ }
+
+ @Test
+ void a02_logRefEscapingTheStateDirIsRefused(@TempDir Path dir) throws Exception {
+ var outside = Files.writeString(dir.getParent().resolve("outside-" + dir.getFileName() + ".log"), "secret\n");
+ var store = storeWithRun(dir, StepStatus.SUCCEEDED, "../" + outside.getFileName());
+ assertTrue(new StepOutputSources(store).find(VERSION, STEP).isEmpty());
+ }
+
+ @Test
+ void a03_servesTheStepLogAsLinesAndKeepsOneSourcePerLog(@TempDir Path dir) throws Exception {
+ Files.createDirectories(dir.resolve("logs"));
+ Files.writeString(dir.resolve("logs/step.log"), "first\nsecond\n");
+ var sources = new StepOutputSources(storeWithRun(dir, StepStatus.SUCCEEDED, "logs/step.log"));
+
+ var src = sources.find(VERSION, STEP).orElseThrow();
+ var page = src.page(null, 100);
+
+ var contract = page.toContractMap();
+ assertEquals(2, ((List<?>)contract.get("lines")).size());
+ assertEquals(Boolean.TRUE, contract.get("terminal"));
+ assertSame(src, sources.find(VERSION, STEP).orElseThrow());
+ }
+
+ @Test
+ void b01_statusFollowsTheStoredStepState(@TempDir Path dir) {
+ var expect = Map.of(
+ StepStatus.PENDING, List.of("PENDING", false),
+ StepStatus.RUNNING, List.of("RUNNING", false),
+ StepStatus.SUCCEEDED, List.of("SUCCEEDED", true),
+ StepStatus.FAILED, List.of("FAILED", true),
+ StepStatus.SKIPPED, List.of("SKIPPED", true),
+ StepStatus.AWAITING_VOTE, List.of("AWAITING VOTE", true),
+ StepStatus.AWAITING_REVIEW, List.of("AWAITING REVIEW", true));
+ for (var e : expect.entrySet()) {
+ var sources = new StepOutputSources(storeWithRun(dir, e.getKey(), "logs/step.log"));
+ var st = sources.status(VERSION, STEP);
+ assertEquals(e.getValue().get(0), st.state(), e.getKey().name());
+ assertEquals(e.getValue().get(1), st.terminal(), e.getKey().name());
+ }
+ }
+
+ @Test
+ void b02_settledStepReportsStyleAndServerDuration(@TempDir Path dir) {
+ var st = new StepOutputSources(storeWithRun(dir, StepStatus.FAILED, "logs/step.log")).status(VERSION, STEP);
+ assertEquals(Style.ERROR, st.stateStyle());
+ assertEquals(Instant.parse("2026-10-08T10:00:00Z"), st.startedAt());
+ assertEquals(83_000L, st.durationMs());
+ }
+
+ @Test
+ void b03_runningStepHasNoDurationYet(@TempDir Path dir) {
+ var st = new StepOutputSources(storeWithRun(dir, StepStatus.RUNNING, "logs/step.log")).status(VERSION, STEP);
+ assertEquals(Style.ACCENT, st.stateStyle());
+ assertNull(st.durationMs());
+ }
+
+ @Test
+ void b04_unparseableTimestampsDegradeToNoDuration(@TempDir Path dir) {
+ var store = storeWithRun(dir, StepStatus.SUCCEEDED, "logs/step.log");
+ var rs = store.load(VERSION).orElseThrow();
+ rs.step(STEP).startedAt = "not-a-time";
+ store.save(rs);
+ var st = new StepOutputSources(store).status(VERSION, STEP);
+ assertNull(st.startedAt());
+ assertNull(st.durationMs());
+ }
+}
diff --git a/src/test/java/org/apache/juneau/releng/rest/ReleaseRestTest.java b/src/test/java/org/apache/juneau/releng/rest/ReleaseRestTest.java
index be574c2af4..a4836e4f23 100644
--- a/src/test/java/org/apache/juneau/releng/rest/ReleaseRestTest.java
+++ b/src/test/java/org/apache/juneau/releng/rest/ReleaseRestTest.java
@@ -152,31 +152,34 @@ class ReleaseRestTest {
}
/**
- * DataTables Buttons' HTML5 export reads {@code window.JSZip} / {@code window.pdfMake} as
- * {@code buttons.html5.min.js} initializes, so those scripts must be included and ordered before it.
- * Asserts the served page carries the JSZip, pdfMake, and pdfMake {@code vfs_fonts} includes, each ahead
- * of {@code buttons.html5.min.js}.
+ * The page gets jQuery, DataTables and Buttons from the asset packs its card declares (served as WebJars),
+ * each exactly once and in dependency order, with nothing bundled or fetched from a CDN. Excel/PDF export
+ * still loads JSZip and pdfMake through {@code init=}; Buttons reads them lazily, when an export runs.
*/
@Test
- void b02_pageIncludesExportDependencyScriptsBeforeButtonsHtml5() throws Exception {
+ void b02_pageLoadsPackAssetsOnceInDependencyOrder() throws Exception {
try (var client = client(rest(List.of(release("9.2.1", "RELEASED"))))) {
try (var resp = client.request("GET", "/").run()) {
assertEquals(200, resp.getStatusCode());
var body = resp.getBodyAsString();
- var jszipIdx = body.indexOf("jszip.min.js");
- var pdfmakeIdx = body.indexOf("pdfmake.min.js");
- var vfsIdx = body.indexOf("vfs_fonts.min.js");
+ var jqueryIdx = body.indexOf("jquery.min.js");
+ var dataTablesIdx = body.indexOf("dataTables.min.js");
+ var buttonsIdx = body.indexOf("dataTables.buttons.min.js");
var buttonsHtml5Idx = body.indexOf("buttons.html5.min.js");
- assertTrue(jszipIdx >= 0, "Missing jszip.min.js script include: " + body);
- assertTrue(pdfmakeIdx >= 0, "Missing pdfmake.min.js script include: " + body);
- assertTrue(vfsIdx >= 0, "Missing vfs_fonts.min.js script include: " + body);
+ assertTrue(jqueryIdx >= 0, "Missing jquery.min.js script include: " + body);
+ assertTrue(dataTablesIdx >= 0, "Missing dataTables.min.js script include: " + body);
+ assertTrue(buttonsIdx >= 0, "Missing dataTables.buttons.min.js script include: " + body);
assertTrue(buttonsHtml5Idx >= 0, "Missing buttons.html5.min.js script include: " + body);
- assertTrue(jszipIdx < buttonsHtml5Idx,
- "jszip.min.js must be included before buttons.html5.min.js: " + body);
- assertTrue(pdfmakeIdx < buttonsHtml5Idx,
- "pdfmake.min.js must be included before buttons.html5.min.js: " + body);
- assertTrue(vfsIdx < buttonsHtml5Idx,
- "vfs_fonts.min.js must be included before buttons.html5.min.js: " + body);
+ assertTrue(jqueryIdx < dataTablesIdx, "jQuery must precede DataTables: " + body);
+ assertTrue(dataTablesIdx < buttonsIdx, "DataTables must precede Buttons: " + body);
+ assertEquals(jqueryIdx, body.lastIndexOf("jquery.min.js"), "jQuery loaded more than once: " + body);
+ assertEquals(dataTablesIdx, body.lastIndexOf("dataTables.min.js"), "DataTables loaded more than once: " + body);
+ assertTrue(body.contains("/webjars/"), "Pack assets should be served as WebJars: " + body);
+ assertFalse(body.contains("cdn.datatables.net"), "Buttons must not come from the CDN: " + body);
+ assertFalse(body.contains("/datatables/jquery.min.js"), "Bundled jQuery should be gone: " + body);
+ assertTrue(body.contains("jszip.min.js"), "Missing jszip.min.js script include: " + body);
+ assertTrue(body.contains("pdfmake.min.js"), "Missing pdfmake.min.js script include: " + body);
+ assertTrue(body.contains("vfs_fonts.min.js"), "Missing vfs_fonts.min.js script include: " + body);
}
}
}
@@ -251,9 +254,12 @@ class ReleaseRestTest {
try (var resp = client.request("GET", "/").run()) {
assertEquals(200, resp.getStatusCode());
var body = resp.getBodyAsString();
- assertPage(body).isValid().hasCard("releases", "datatables");
- assertTrue(body.contains("\"contractVersion\":\"5\""), "Missing lifted VIEW_META view contract: " + body);
- assertTrue(body.contains("\"id\":\"releases\""), "Missing view id in the lifted catalog: " + body);
+ var table = assertPage(body).isValid().hasCard("releases", "datatables").card("releases").getMap("table");
+ assertNull(table.get("contractVersion"), "Catalog-form cards carry no hand-written contract version: " + table);
+ assertNull(table.get("view"), "Catalog-form cards carry no pre-built view: " + table);
+ assertNull(table.get("layout"), "Catalog-form cards carry no layout: " + table);
+ assertNull(table.getMap("detail").get("contractVersion"), "The console stamps detail's contract version: " + table);
+ assertEquals("/rest/releases/data", table.getString("dataUrl"), body);
assertTrue(body.contains("version-cell"), body);
assertTrue(body.contains("/rest/releases/expand/{id}"), body);
assertTrue(body.contains("releases-detail"), body);
diff --git a/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestOutputTest.java b/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestOutputTest.java
new file mode 100644
index 0000000000..62103dc882
--- /dev/null
+++ b/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestOutputTest.java
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.juneau.releng.rest;
+
+import static org.junit.jupiter.api.Assertions.*;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.Map;
+import org.apache.juneau.commons.inject.StackOverlay;
+import org.apache.juneau.releng.config.TargetProfile;
+import org.apache.juneau.releng.engine.BranchResolver;
+import org.apache.juneau.releng.engine.DropRcService;
+import org.apache.juneau.releng.engine.ReleaseEngine;
+import org.apache.juneau.releng.engine.RunStateStore;
+import org.apache.juneau.releng.engine.StepRegistry;
+import org.apache.juneau.releng.nexus.NexusStagingClient;
+import org.apache.juneau.releng.util.ProcessRunner;
+import org.apache.juneau.rest.mock.MockRestClient;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+/**
+ * Serves a step's console output through the console-output lines and download endpoints, and checks the New Release
+ * page wires the console-output region instead of its own log renderer.
+ */
+class ReleaseRunRestOutputTest {
+
+ private ProcessRunner okRunner() {
+ return new ProcessRunner() {
+ @Override
+ public List<String> runLines(List<String> c) {
+ return List.of();
+ }
+
+ @Override
+ public String runText(List<String> c) {
+ return "";
+ }
+
+ @Override
+ public ProcResult run(List<String> c, String s, Map<String, String> e) {
+ if (c.contains("ls-remote"))
+ return new ProcResult(0, "sha\trefs/heads/juneau-9.2.1-branch\n");
+ return new ProcResult(0, "ok");
+ }
+
+ @Override
+ public ProcResult run(List<String> c, String s, Map<String, String> e, java.util.function.Consumer<String> k) {
+ return run(c, s, e);
+ }
+ };
+ }
+
+ private ReleaseEngine engine;
+
+ @SuppressWarnings({
+ "resource" // Caller owns and closes the returned MockRestClient (via try-with-resources).
+ })
+ private MockRestClient client(Path dir) {
+ var runner = okRunner();
+ var branches = new BranchResolver(runner, "/repo");
+ var store = new RunStateStore(dir);
+ var registry = StepRegistry.standard(branches);
+ engine = ReleaseEngine.forTests(store, registry, runner, branches, dir);
+ var dropRc = new DropRcService(store, registry, runner, dir.resolve("staging/git/juneau"), dir,
+ NexusStagingClient.forTests((m, p, b) -> ""), TargetProfile.prodDefault());
+ return MockRestClient.builder(new ReleaseRunRest(engine, dropRc)).overridingBeanStore(new StackOverlay()).build();
+ }
+
+ @Test
+ void a01_linesEndpointServesTheStepLogInTheConsoleOutputContract(@TempDir Path dir) throws Exception {
+ try (var client = client(dir)) {
+ engine.start("9.2.1", null);
+ engine.apply("9.2.1", "preflight", Map.of());
+ try (var resp = client.request("GET", "/9.2.1/steps/preflight/output/lines").run()) {
+ assertEquals(200, resp.getStatusCode());
+ var body = resp.getBodyAsString();
+ assertTrue(body.contains("\"contractVersion\":\"1\""), body);
+ assertTrue(body.contains("Resolved target branch"), body);
+ assertTrue(body.contains("\"terminal\":true"), body);
+ assertTrue(body.contains("SUCCEEDED"), body);
+ }
+ }
+ }
+
+ @Test
+ void a02_unknownRunOrStepIs404(@TempDir Path dir) throws Exception {
+ try (var client = client(dir)) {
+ engine.start("9.2.1", null);
+ try (var resp = client.request("GET", "/9.9.9/steps/preflight/output/lines").run()) {
+ assertEquals(404, resp.getStatusCode());
+ }
+ try (var resp = client.request("GET", "/9.2.1/steps/not-a-step/output/lines").run()) {
+ assertEquals(404, resp.getStatusCode());
+ }
+ try (var resp = client.request("GET", "/9.2.1/steps/preflight/output/lines").run()) {
+ assertEquals(404, resp.getStatusCode(), "a step that has not run has no log yet");
+ }
+ }
+ }
+
+ @Test
+ void a03_downloadIsTheWholeLogAsJsonl(@TempDir Path dir) throws Exception {
+ try (var client = client(dir)) {
+ engine.start("9.2.1", null);
+ engine.apply("9.2.1", "preflight", Map.of());
+ try (var resp = client.request("GET", "/9.2.1/steps/preflight/output/download").run()) {
+ assertEquals(200, resp.getStatusCode());
+ assertEquals("application/jsonl", resp.header("Content-Type").orElse(""));
+ assertTrue(resp.header("Content-Disposition").orElse("").contains(".jsonl"));
+ assertTrue(resp.getBodyAsString().contains("Resolved target branch"));
+ }
+ }
+ }
+
+ @Test
+ void c01_runViewEventsEndpointServesTheRunsEvents(@TempDir Path dir) throws Exception {
+ try (var client = client(dir)) {
+ engine.start("9.2.1", null);
+ engine.apply("9.2.1", "preflight", Map.of());
+ try (var resp = client.request("GET", "/juneau-run-view/9_2_1/events").run()) {
+ assertEquals(200, resp.getStatusCode());
+ var body = resp.getBodyAsString();
+ assertTrue(body.contains("\"preflight\""), body);
+ assertTrue(body.contains("\"end\""), body);
+ }
+ }
+ }
+
+ @Test
+ void c02_runViewEventsForAnUnknownRunIs404(@TempDir Path dir) throws Exception {
+ try (var client = client(dir)) {
+ engine.start("9.2.1", null);
+ try (var resp = client.request("GET", "/juneau-run-view/9_9_9/events").run()) {
+ assertEquals(404, resp.getStatusCode());
+ }
+ }
+ }
+
+ @Test
+ void b01_pageLoadsTheViewsToolkitAndNoLongerOwnsALogRenderer(@TempDir Path dir) throws Exception {
+ try (var client = client(dir)) {
+ engine.start("9.2.1", null);
+ try (var resp = client.request("GET", "/?tab=exec").run()) {
+ assertEquals(200, resp.getStatusCode());
+ var body = resp.getBodyAsString();
+ assertTrue(body.contains("juneau-console-output.js"), "the views toolkit must be loaded: " + body);
+ }
+ }
+ for (var path : List.of("/static/js/new-release.js", "/static/css/new-release.css", "/templates/new-release.ftlh")) {
+ try (var in = ReleaseRunRestOutputTest.class.getResourceAsStream(path)) {
+ var text = new String(in.readAllBytes(), java.nio.charset.StandardCharsets.UTF_8);
+ assertFalse(text.contains("rm-console"), path);
+ assertFalse(text.contains("/events/' + encodeURIComponent(version) + '/' + encodeURIComponent(stepId)"), path);
+ if (path.endsWith(".js"))
+ assertTrue(text.contains("JuneauViews.consoleOutput.mount(") && text.contains("JuneauViews.runView.mount("), path);
+ if (path.endsWith(".ftlh"))
+ assertTrue(text.contains("nr-runview"), path);
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java b/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
index c3a080afc2..c58be69751 100644
--- a/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
+++ b/src/test/java/org/apache/juneau/releng/rest/ReleaseRunRestTest.java
@@ -35,7 +35,6 @@ import org.apache.juneau.releng.engine.RunStateStore;
import org.apache.juneau.releng.engine.RunStatus;
import org.apache.juneau.releng.engine.StepRegistry;
import org.apache.juneau.releng.engine.StepStatus;
-import org.apache.juneau.releng.log.LogBroadcaster;
import org.apache.juneau.releng.milestone.MilestoneService;
import org.apache.juneau.releng.nexus.NexusMockModel;
import org.apache.juneau.releng.nexus.NexusMockRest;
@@ -88,8 +87,7 @@ class ReleaseRunRestTest {
var registry = StepRegistry.standard(branches);
var engine = ReleaseEngine.forTests(store, registry, runner, branches, dir);
var dropRc = new DropRcService(store, registry, runner, dir.resolve("staging/git/juneau"), dir,
- NexusStagingClient.forTests((m, p, b) -> ""), TargetProfile.prodDefault(),
- (v, s) -> new LogBroadcaster());
+ NexusStagingClient.forTests((m, p, b) -> ""), TargetProfile.prodDefault());
return new ReleaseRunRest(engine, dropRc);
}
@@ -148,7 +146,7 @@ class ReleaseRunRestTest {
"test@apache.org", new EmailService(dir, runner), new MilestoneService(), secrets,
TargetProfile.prodDefault());
var dropRc = new DropRcService(store, registry, runner, dir.resolve("staging/git/juneau"), dir, nexus,
- TargetProfile.prodDefault(), (v, s) -> new LogBroadcaster());
+ TargetProfile.prodDefault());
return new ReleaseRunRest(engine, dropRc);
}