Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,37 @@ jobs:
name: backend-tests
runs-on: windows-latest
timeout-minutes: 60
defaults:
run:
shell: pwsh
env:
COREPACK_ENABLE_DOWNLOAD_PROMPT: '0'
NODE_OPTIONS: --max-old-space-size=6144
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Checkout plugin development CLI for cross-repository acceptance

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 低 插件仓库只做了检出,没有安装它自己的依赖。如果 tools/dev.mjs 或它调用的打包流程会导入插件仓库自身的 npm 依赖,CI 中的跨仓库验收会因缺少 node_modules 失败,而本地验证时这些依赖通常已经装好。请确认 CI 下该验收确实能运行。如果需要依赖,应在 .ci/OpenTest-Plugins 中执行 pnpm install --frozen-lockfile。另外,检出目录位于工作区内,请确认它不会被根目录的 pnpm workspace 或其他检查扫描到。

uses: actions/checkout@v7
with:
repository: crysound/OpenTest-Plugins
ref: c8e62659fac4543eb8cd22d8211a25b1bf59761e
path: .ci/OpenTest-Plugins
persist-credentials: false
- uses: actions/setup-node@v7
with:
node-version: 22
package-manager-cache: false
- name: Prepare frontend acceptance dependencies
run: |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 中 这个 job 使用 pwsh。GitHub Actions 只会在脚本末尾检查最后一个命令的 $LASTEXITCODE。$ErrorActionPreference = 'stop' 对原生命令的非零退出码不起作用,所以 corepack enable、corepack prepare 或 pnpm install --frozen-lockfile 失败后,脚本仍会继续执行。最终结果只取决于 pnpm build:sdk,真实的失败原因会被掩盖,甚至可能在部分依赖缺失时继续进入 Maven 阶段。

建议在脚本开头加入 $PSNativeCommandUseErrorActionPreference = $true(PowerShell 7.3+),或在每条命令后检查 if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }。

corepack enable
corepack prepare pnpm@10.6.5 --activate
pnpm install --frozen-lockfile

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 中 插件仓库的依赖可能没有安装。

这一步只在宿主仓库根目录执行了 pnpm install,检出到 .ci/OpenTest-Plugins 的插件仓库没有安装依赖。验收测试会调用插件仓库的 tools/dev.mjs。如果它或它触发的插件前端构建依赖插件仓库自己的 node_modules(例如构建工具),那么在 CI 的干净检出中会失败。本地验证通过,很可能是因为同级仓库已经装好了依赖。描述也说明 Windows 远程验证尚未完成。

建议:

  • 确认 dev.mjs 是否只依赖 Node 内置模块和宿主产物;
  • 如果不是,增加一步:pnpm install --frozen-lockfile --dir .ci/OpenTest-Plugins(或进入该目录执行),并让 CI 实际跑通一次后再合入。

pnpm build:sdk
- uses: actions/setup-java@v6
with:
distribution: zulu
java-version: '21'
cache: maven
- name: Build and test backend
run: mvn -B --no-transfer-progress --fail-at-end -f apps/backend/pom.xml verify
run: mvn -B --no-transfer-progress --fail-at-end -f apps/backend/pom.xml "-Dopentest.plugins.repository=${{ github.workspace }}/.ci/OpenTest-Plugins" verify
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.junit.jupiter.api.io.TempDir;
import org.springframework.test.util.ReflectionTestUtils;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;

Expand Down Expand Up @@ -58,7 +59,8 @@ void darwinLoadsPosixPathsWithoutTheWindowsSubstringMatch() throws Exception {
try {
System.setProperty("os.name", "Darwin");
loader.loadDlls();
nativeLoading.verify(() -> NativeLoader.loader(library.toString()), times(1));
String expectedPath = nativeDirectory + File.separator + "nested/library.dylib";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 低 期望值从 library.toString() 改成了手工拼接的 nativeDirectory + File.separator + "nested/library.dylib"。这是在固化实现中的字符串拼接方式,而不是验证路径语义:在 Windows 上运行这个 Darwin 分支测试时,会得到 ...\nested/library.dylib 这样混用分隔符的路径。PR 描述也没有说明这项改动的原因。

如果改动是因为 macOS 临时目录的符号链接,建议像其他测试一样在用例开头对临时目录执行 toRealPath(),期望值继续使用 library.toString()。如果实现确实应输出这种格式,请在描述中说明。

nativeLoading.verify(() -> NativeLoader.loader(expectedPath), times(1));
nativeLoading.verifyNoMoreInteractions();
} finally {
if (previous == null) System.clearProperty("os.name"); else System.setProperty("os.name", previous);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class ConcurrentFileManager implements AutoCloseable {
new ConcurrentHashMap<>();
private final ConcurrentMap<String, FileConsumerState> fileConsumers =
new ConcurrentHashMap<>();
private final Object writeAdmissionMonitor = new Object();
private final Object fileConsumerMonitor = new Object();
private final Map<Byte, ContextualFileWriterFactory> writerFactories =
new ConcurrentHashMap<>();
Expand Down Expand Up @@ -672,10 +673,14 @@ private ThreadPoolExecutor createFileExecutor() {
while (acceptingWrites.get() && !executor.isShutdown()) {
try {
if (executor.getQueue().offer(task, 100L, TimeUnit.MILLISECONDS)) {
// Close may win while offer is waiting. A task already consumed or discarded
// owns its existing completion; otherwise reject and let the caller release it.
if ((!acceptingWrites.get() || executor.isShutdown()) && executor.remove(task)) {
throw new RejectedExecutionException("fileManager is shutting down");
synchronized (writeAdmissionMonitor) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 中 新增的监视器没有改变语义。

改动后的分支逻辑与原来的 if ((!accepting || isShutdown) && remove) throw; return; 完全等价,唯一区别是检查期间持有 writeAdmissionMonitor。

这把锁不能带来更强的保证,原因如下:

  • beginManagerClose 在设置 acceptingWrites=false 后立即释放该锁,随后才执行 shutdown 或清空队列。
  • acceptingWrites 本身就是原子变量。
  • 任务归属已经由 executor.remove(task) 与 worker 取出或 drain 之间的原子性决定。

因此无论生产者先拿到锁还是关闭线程先拿到锁,结果都与无锁时相同。

另一方面,这个改动引入了 writeAdmissionMonitor → fileConsumerMonitor 的嵌套加锁顺序。之后如果有路径在持有 fileConsumerMonitor 时调用 beginManagerClose,或提交写任务,就会出现锁顺序反转。

建议:

  • 在 PR 中说明这把锁要消除的具体交错序列,并补一个在旧实现上会失败的测试;
  • 如果说明不了,就去掉 writeAdmissionMonitor,保持原实现,避免增加锁复杂度。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 低 新的同步块与原来的单行条件在判定结果上等价。它额外提供的唯一保证是:在“检查标志”和 remove(task) 之间,beginManagerClose 不能翻转 acceptingWrites。但如果翻转发生在这个窗口内,任务只是留在队列里,由关闭流程处理。这与翻转发生在检查之后、return 之前的情况相同,而后一种情况仍然存在。同时,关闭流程对队列的清空和 shutdown 似乎发生在 beginManagerClose 释放锁之后,不受这把锁保护。

请在代码注释或 PR 描述中说明这把锁具体消除了哪条交错路径。如果确实存在问题,也请补充对应测试(见测试文件中的意见)。另外,原来解释任务所有权的注释被删掉了,建议保留,便于后续维护者理解“任务已被 worker 取走时由其负责完成”的约定。

if (!acceptingWrites.get() || executor.isShutdown()) {
if (executor.remove(task)) {
throw new RejectedExecutionException(
"fileManager is shutting down");
}
return;
}
}
return;
}
Expand Down Expand Up @@ -929,12 +934,14 @@ private void completeFileConsumers(Throwable failure) {
}

private boolean beginManagerClose() {
synchronized (fileConsumerMonitor) {
if (!closed.compareAndSet(false, true)) {
return false;
synchronized (writeAdmissionMonitor) {
synchronized (fileConsumerMonitor) {
if (!closed.compareAndSet(false, true)) {
return false;
}
acceptingWrites.set(false);
return true;
}
acceptingWrites.set(false);
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
import com.opentest.platform.file.writer.FileWriter;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Field;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
Expand Down Expand Up @@ -57,6 +63,79 @@ void cancelRejectsBlockedAdmissionAndReleasesEveryQueuedBorrow() throws Exceptio
closeWithBlockedProducer(true);
}

@Test
void workerClaimedAdmissionIsNotRejectedOrDiscarded() throws Exception {
ConcurrentFileManager manager = new ConcurrentFileManager(
new ConcurrentFileManagerConfig(1, 1, 3600L, 3600L));
BlockingWriter writer = new BlockingWriter();
manager.setBlockOnQueueFull(true);
manager.registerWriterFactory(TYPE, (fileName, append) -> writer);
manager.init();
try {
ThreadPoolExecutor admissionOwner = managerExecutor(manager);
RejectedExecutionHandler handler = admissionOwner.getRejectedExecutionHandler();
OfferThenShutdownExecutor worker = OfferThenShutdownExecutor.create();
AtomicInteger completions = new AtomicInteger();
TestData offered = new TestData();
offered.addWriteCompletionCallback(error -> completions.incrementAndGet());
FileWriteTask task = new FileWriteTask(writer, offered,
new FileWriteObserver() {
@Override public void onEnqueued(Data data) { }
@Override public void onCompleted(Data data, Throwable failure) { }
}, failure -> { });

handler.rejectedExecution(task, worker);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 中 这个测试不能作为回归测试。

把它放到改动前的实现上运行:

  • offer 成功后 isShutdown() 返回 true;
  • remove() 返回 false;
  • 旧代码同样不抛异常,直接返回。

所以它在旧代码上也能通过,无法证明生产代码的改动修复了什么。

此外,模拟本身前后不一致:remove() 固定返回 false,表示任务已被 worker 取走,但任务实际仍留在队列里,随后又由测试手动 poll 并 run。“没有被丢弃”这一点是测试代码自己保证的,并不是被测对象保证的。

测试还通过反射读取私有字段 fileExecutors,字段重命名时会在运行期才失败。

**建议:**改为驱动真实的 close 与阻塞 admission 竞争,并断言 completion 恰好触发一次、调用方没有重复释放。

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 中 这个测试在修改前的实现上同样会通过。在该场景中,acceptingWrites 为 true,offer 后 isShutdown() 变为 true,remove 返回 false。旧条件 (!accepting || isShutdown()) && remove(task) 结果为 false,不抛异常,直接 return;新代码走的也是 return。另外,测试完全没有调用 beginManagerClose,也没有涉及新增的 writeAdmissionMonitor。因此它无法作为本次并发修复的回归测试。

建议补充一个能区分新旧实现的测试:用闩锁让生产者停在 offer 成功之后、条件检查之前,然后并发调用 close()/closeNow(),断言任务恰好被执行一次,或被拒绝并释放一次,不会重复完成,也不会泄漏。

assertEquals(1, worker.getQueue().size());
assertEquals(task, worker.getQueue().poll());
writer.release.countDown();
task.run();
assertEquals(1, completions.get());
} finally {
writer.release.countDown();
manager.closeNow();
}
}

@SuppressWarnings("unchecked")
private static ThreadPoolExecutor managerExecutor(ConcurrentFileManager manager)
throws Exception {
Field field = ConcurrentFileManager.class.getDeclaredField("fileExecutors");
field.setAccessible(true);
return ((List<ThreadPoolExecutor>) field.get(manager)).getFirst();
}

private static final class OfferThenShutdownExecutor extends ThreadPoolExecutor {
private final AtomicBoolean shutdownObserved = new AtomicBoolean();

private OfferThenShutdownExecutor(BlockingQueue<Runnable> queue) {
super(0, 1, 0L, TimeUnit.MILLISECONDS, queue);
}

static OfferThenShutdownExecutor create() {
AtomicReference<OfferThenShutdownExecutor> owner = new AtomicReference<>();
BlockingQueue<Runnable> queue = new ArrayBlockingQueue<>(1) {
@Override
public boolean offer(Runnable task, long timeout, TimeUnit unit)
throws InterruptedException {
boolean offered = super.offer(task, timeout, unit);
owner.get().shutdownObserved.set(true);
return offered;
}
};
OfferThenShutdownExecutor executor = new OfferThenShutdownExecutor(queue);
owner.set(executor);
return executor;
}

@Override public boolean isShutdown() {
return shutdownObserved.get();
}

@Override public boolean remove(Runnable task) {
return false;
}
}

private void closeWithBlockedProducer(boolean cancel) throws Exception {
try (Fixture fixture = new Fixture()) {
AtomicInteger completions = new AtomicInteger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void generatedContractKeepsLegacyPackageNamesAndFieldNumbers() {
"DynamicResultChannel",
"ResultChannelsAdded",
"RecordingStorageStatus",
"MathChannelErrorMsg",
"Response",
"Request"
), descriptor.getMessageTypes().stream()
Expand Down Expand Up @@ -80,7 +81,8 @@ void generatedContractKeepsLegacyPackageNamesAndFieldNumbers() {
"resultChannelsAdded", 4,
"recordingStorageStatus", 5,
"mmapReadyMsg", 6,
"executionMessage", 7
"executionMessage", 7,
"mathChannelErrorMsg", 8
));
assertFieldNumbers(CommonProto.Request.getDescriptor(), Map.of(
"dashboardId", 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.opentest.runtime.loader;

import com.opentest.plugin.api.OpenTestBackendPlugin;
import com.opentest.dashboard.api.measurement.DashboardProvider;
import com.opentest.runtime.JsonFiles;
import javax.tools.ToolProvider;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.util.jar.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;

/** Compiles an independent author against public SDK locations only; no host/test classpath. */
public final class TestEditingPluginJar {
Expand Down Expand Up @@ -66,7 +69,7 @@ public void register(BackendPluginRegistry registry) {
config -> { throw new AssertionError("Discovery declared inputs"); },
(config, facts) -> { throw new AssertionError("Discovery bound inputs"); }));
registry.measureEditing("measure", Config.class, new GraphicEditing<Config>(query -> { throw new AssertionError("Discovery projected graphic"); }));
registry.measureEditing("measure", Config.class, new LimitXAxis<Config>((config, result, selection) -> { throw new AssertionError("Discovery projected Limit X"); }));
registry.measureEditing("measure", Config.class, new LimitXAxis<Config>(query -> { throw new AssertionError("Discovery projected Limit X"); }));
registry.measureEditing("measure", Config.class, new ReferenceUnits<Config>(new CurrentResultReferenceUnits() {
public Change compare(Map<String,Object> previous, Map<String,Object> current) { throw new AssertionError("Discovery compared units"); }
public Set<String> affectedInputs(String algorithm, String result, Map<String,Object> parameters,
Expand All @@ -83,7 +86,7 @@ public CompletionStage<Void> start(BackendPluginContext context) {
""".replace("__MODE__", mode).replace("__ID__", pluginId);
Files.writeString(source, author, StandardCharsets.UTF_8);
String sdk = Path.of(OpenTestBackendPlugin.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString()
+ File.pathSeparator + Path.of(com.opentest.dashboard.api.measurement.DashboardProvider.class
+ File.pathSeparator + Path.of(DashboardProvider.class
.getProtectionDomain().getCodeSource().getLocation().toURI());
int exit = ToolProvider.getSystemJavaCompiler().run(null, null, null, "--release", "21", "-encoding", "UTF-8",
"-proc:none", "-classpath", sdk, "-d", classes.toString(), source.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ void declaredClassesCannotHideDifferentActualGenericTypes(String mode) throws Ex
var bundle = bundle("org.test.invalid", PROVIDER, "level", "1", mode);
queue(bundle);
try (PluginRuntime runtime = runtime(bundle)) {
assertEquals("RECOVERY", runtime.candidate().path("status").asText());
assertEquals("PLUGINS_NOT_READY", assertThrows(PluginFailure.class, runtime::dashboardProviders).code());
assertEquals("APP_READY", runtime.candidate().path("status").asText());
assertIsolated(runtime, bundle);
assertEquals("DASHBOARD_PROVIDER_NOT_ACTIVE", assertThrows(PluginFailure.class, () -> runtime.dashboardProvider(PROVIDER)).code());
var snapshot = runtime.snapshot(false).toString();
assertTrue(snapshot.contains("Measurement provider type arguments do not match its registration"), snapshot);
}
}

@ParameterizedTest @ValueSource(strings = {"provider"})
void duplicateProviderIdentityRejectsTheWholeCandidate(String collision) throws Exception {
void duplicateProviderIdentityIsolatesTheConflictingPlugin(String collision) throws Exception {
var a = bundle("org.test.a", PROVIDER, "level", "1", "valid");
var b = bundle("org.test.b", collision.equals("provider") ? PROVIDER : "org.example.other:gain",
collision.equals("mapping-different-scene") ? "other" : "level", "1", "valid");
Expand All @@ -101,9 +102,13 @@ void duplicateProviderIdentityRejectsTheWholeCandidate(String collision) throws
initial.requestInstall(b.descriptor(), "install-b", generation(initial));
}
try (PluginRuntime runtime = runtime(a, b)) {
assertEquals("RECOVERY", runtime.candidate().path("status").asText());
assertEquals("BACKEND_CORE_READY", runtime.candidate().path("status").asText());
assertIsolated(runtime, b);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 低 测试固定了“先到者保留、后到者隔离”的规则,但没有锁定判定依据。

org.test.a 与 org.test.b 同时满足以下两个条件:

  • 安装顺序在前;
  • 插件 ID 字典序在前。

因此测试无法区分实际规则是按安装顺序、按 ID 排序,还是依赖目录遍历顺序。如果是最后一种,测试在不同文件系统上可能不稳定。

建议:

  • 调整构造,让安装顺序与 ID 顺序相反,从而锁定预期规则;
  • 在 ADR 或设计记录中写明重复 Provider 时保留哪一方。

duplicateResultAlgorithmAcrossProvidersIsolatesThePlugin 存在同样的情况。

assertTrue(runtime.snapshot(false).toString().contains("重复"));
assertThrows(PluginFailure.class, runtime::dashboardProviders);
runtime.report(report(runtime, a));
assertTrue(runtime.ready());
assertEquals("org.test.a", runtime.dashboardProviders().path("providers").get(0).path("pluginId").asText());
assertEquals(1, runtime.dashboardProviders().path("providers").size());
}
}

Expand Down Expand Up @@ -135,7 +140,8 @@ void duplicateProviderIdentityRejectsTheWholeCandidate(String collision) throws
var mismatch = bundle("org.test.version", PROVIDER, "level", "2", "valid");
queue(mismatch);
try (PluginRuntime runtime = runtime(mismatch)) {
assertEquals("RECOVERY", runtime.candidate().path("status").asText());
assertEquals("APP_READY", runtime.candidate().path("status").asText());
assertIsolated(runtime, mismatch);
assertTrue(runtime.snapshot(false).toString().contains("版本"));
}
var valid = bundle("org.test.valid", "org.example.valid:gain", "level", "1", "valid");
Expand Down Expand Up @@ -187,25 +193,33 @@ void duplicateProviderIdentityRejectsTheWholeCandidate(String collision) throws
}

@ParameterizedTest @ValueSource(strings={"ownership-duplicate", "ownership-missing", "ownership-empty"})
void invalidResultAlgorithmRegistrationRejectsTheCandidate(String mode) throws Exception {
void invalidResultAlgorithmRegistrationIsolatesThePlugin(String mode) throws Exception {
var bundle = bundle("org.test.invalid-owner", PROVIDER, "level", "1", mode);
queue(bundle);
try (var runtime = runtime(bundle)) {
assertEquals("RECOVERY", runtime.candidate().path("status").asText());
assertEquals("APP_READY", runtime.candidate().path("status").asText());
assertIsolated(runtime, bundle);
assertTrue(runtime.dashboardProviderForAnalysis("sample-analysis").isEmpty());
}
}

@Test void duplicateResultAlgorithmAcrossProvidersRejectsTheCandidate() throws Exception {
@Test void duplicateResultAlgorithmAcrossProvidersIsolatesThePlugin() throws Exception {
var first = bundle("org.test.first-owner", PROVIDER, "level", "1", "ownership");
var second = bundle("org.test.second-owner", "org.example.other:gain", "level", "1", "ownership");
try (var initial = runtime(first, second)) {
initial.requestInstall(first.descriptor(), "install-first", generation(initial));
initial.requestInstall(second.descriptor(), "install-second", generation(initial));
}
try (var runtime = runtime(first, second)) {
assertEquals("RECOVERY", runtime.candidate().path("status").asText());
assertEquals("BACKEND_CORE_READY", runtime.candidate().path("status").asText());
assertIsolated(runtime, second);
assertTrue(runtime.snapshot(false).toString().contains("sample-analysis"));
runtime.report(report(runtime, first));
assertTrue(runtime.ready());
assertSame(runtime.dashboardProvider(PROVIDER).registration(),
runtime.dashboardProviderForAnalysis("sample-analysis").orElseThrow().registration());
assertEquals("DASHBOARD_PROVIDER_NOT_ACTIVE", assertThrows(PluginFailure.class,
() -> runtime.dashboardProvider("org.example.other:gain")).code());
}
}

Expand All @@ -225,11 +239,12 @@ void invalidResultAlgorithmRegistrationRejectsTheCandidate(String mode) throws E
}

@ParameterizedTest @ValueSource(strings={"catalog-duplicate", "catalog-missing", "catalog-multi-duplicate", "catalog-empty"})
void catalogRegistrationRejectsDuplicateAndUnregisteredMeasurements(String mode) throws Exception {
void catalogRegistrationIsolatesDuplicateAndUnregisteredMeasurements(String mode) throws Exception {
var bundle = bundle("org.test.catalog", PROVIDER, "level", "1", mode);
queue(bundle);
try (var runtime = runtime(bundle)) {
assertEquals("RECOVERY", runtime.candidate().path("status").asText());
assertEquals("APP_READY", runtime.candidate().path("status").asText());
assertIsolated(runtime, bundle);
assertTrue(runtime.measureResultCatalogs().isEmpty());
}
}
Expand Down Expand Up @@ -284,4 +299,13 @@ private static ObjectNode report(PluginRuntime runtime, TestPluginJar.Bundle bun
.put("contributionId", "measure").put("componentId", "contributions/measure/demo")));
return report;
}
private static void assertIsolated(PluginRuntime runtime, TestPluginJar.Bundle bundle) {
String id = bundle.descriptor().path("pluginId").asText();
var snapshot = runtime.snapshot(false);
assertEquals("BACKEND_ACTIVATION_FAILED", snapshot.path("pluginFailures").path(id).path("code").asText(), snapshot.toString());
for (var plugin : runtime.candidate().path("plugins")) {
assertFalse(id.equals(plugin.path("pluginId").asText()), "Failed plugin must not be offered to the frontend");
}
}

}
Loading
Loading