8238375: JFR Test TestJcmdStartFlushInterval is not run

Reviewed-by: egahlin, mseledtsov
This commit is contained in:
Christoph Langer 2020-02-05 06:33:57 +00:00
parent c09e02193b
commit d6aeda7b24

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package jdk.jfr.jcmd; package jdk.jfr.jcmd;
import java.lang.reflect.Method;
import java.time.Duration; import java.time.Duration;
import jdk.jfr.FlightRecorder; import jdk.jfr.FlightRecorder;
@ -36,15 +37,18 @@ import jdk.jfr.Recording;
* @key jfr * @key jfr
* @requires vm.hasJFR * @requires vm.hasJFR
* @library /test/lib /test/jdk * @library /test/lib /test/jdk
* @run main/othervm jdk.jfr.jcmd.TestJcmdStartReadOnlyFile * @modules jdk.jfr/jdk.jfr:open
* @run main/othervm jdk.jfr.jcmd.TestJcmdStartFlushInterval
*/ */
public class TestJcmdStartFlushInterval { public class TestJcmdStartFlushInterval {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
JcmdHelper.jcmd("JFR.start","flush-interval=1s"); JcmdHelper.jcmd("JFR.start", "flush-interval=2s");
Method getFlushIntervalMethod = Recording.class.getDeclaredMethod("getFlushInterval");
getFlushIntervalMethod.setAccessible(true);
for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) { for (Recording r : FlightRecorder.getFlightRecorder().getRecordings()) {
Duration d = r.getFlushInterval(); Duration d = (Duration)getFlushIntervalMethod.invoke(r);
if (d.equals(Duration.ofSeconds(1))) { if (d.equals(Duration.ofSeconds(2))) {
return; //OK return; //OK
} else { } else {
throw new Exception("Unexpected flush-interval=" + d); throw new Exception("Unexpected flush-interval=" + d);