后端(四面9分批次): 版本地板自述并排 ASCII 巡检标签,锁跳过 javadoc 计数改回实测值
- ClientVersionGuardFilter 4 条中文自述旁并排 [client-version-floor]:中文签名在容器日志 换编码后整条 grep 失效,巡检只认 ASCII;判定逻辑与响应体一字未改 - ClientVersionFloorConfigTest 加第 10 例:逐行钉"带中文自述必须并排 ASCII 标签", 并含"内存里摘掉一处就掉数"的非零对照(mvn 实跑 tests=10 failures=0 errors=0) - LockSkipWitness javadoc 的 27 处/12 文件是旧数,按本轮实扫改成 28 处/11 个文件
This commit is contained in:
@@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.read.ListAppender;
|
||||
import com.nanri.aiimage.testutil.SourceScan;
|
||||
import io.micrometer.core.instrument.Counter;
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
import java.io.InputStream;
|
||||
@@ -238,6 +239,40 @@ class ClientVersionFloorConfigTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 巡检锚点必须是 ASCII:日志级别再对、写得再清楚,容器日志换了编码之后 grep 抓不到就等于没上线。
|
||||
* 所以每条中文自述旁边都并排一条 {@code [client-version-floor]},这条判据钉的是"并排"这件事本身
|
||||
* ——摘掉任意一处都要红,而不是只数一遍总数(总数会被注释喂,故先剥注释)。
|
||||
*/
|
||||
@Test
|
||||
void everyFloorLogCarriesTheAsciiPatrolTag() {
|
||||
String body = SourceScan.withoutComments(SourceScan.sourceText("ClientVersionGuardFilter.java"));
|
||||
int cnTag = countIn(body, "[版本地板]");
|
||||
int asciiTag = countIn(body, "[client-version-floor]");
|
||||
assertThat(cnTag).as("剥掉注释后含中文自述标签的 log 语句数,改动措辞或搬文件都会让这里不等于 4").isEqualTo(4);
|
||||
assertThat(asciiTag).as("ASCII 巡检标签条数必须与中文标签一致").isEqualTo(cnTag);
|
||||
for (String line : body.split("\n")) {
|
||||
if (line.contains("[版本地板]")) {
|
||||
assertThat(line).as("这一行只带了中文标签,巡检那条 grep 就抓不到它")
|
||||
.contains("[client-version-floor]");
|
||||
}
|
||||
}
|
||||
// 非零对照:在内存里摘掉一处 ASCII 标签,上面"条数一致"必须不再成立
|
||||
String cut = body.replaceFirst(Pattern.quote("[client-version-floor] "), "");
|
||||
assertThat(countIn(cut, "[client-version-floor]")).as("摘掉一处后计数应变成 3,否则这条判据是恒真的")
|
||||
.isEqualTo(cnTag - 1);
|
||||
}
|
||||
|
||||
private static int countIn(String text, String needle) {
|
||||
int at = 0;
|
||||
int hits = 0;
|
||||
while ((at = text.indexOf(needle, at)) >= 0) {
|
||||
hits++;
|
||||
at += needle.length();
|
||||
}
|
||||
return hits;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 助手
|
||||
|
||||
private ClientVersionGuardFilter filter(String minVersion, boolean enforce, boolean rejectUnreported,
|
||||
|
||||
Reference in New Issue
Block a user