Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8287008: Improve tests for thread dumps in JSON format #8784

Closed
wants to merge 5 commits into from

Conversation

AlanBateman
Copy link
Contributor

@AlanBateman AlanBateman commented May 19, 2022

This change is mostly test infrastructure and improvements to the testing of thread dumps in JSON format. It also tweaks the thread dump format so that the process identifier and thread identifiers are a type string rather than number.

The tests for thread dumps added by JEP 425 are changed to use the test infrastructure library. The tests for JEP 428 will also make use of this test infrastructure.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 reviewer)

Issue

  • JDK-8287008: Improve tests for thread dumps in JSON format

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8784/head:pull/8784
$ git checkout pull/8784

Update a local copy of the PR:
$ git checkout pull/8784
$ git pull https://git.openjdk.java.net/jdk pull/8784/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 8784

View PR using the GUI difftool:
$ git pr show -t 8784

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8784.diff

@bridgekeeper
Copy link

bridgekeeper bot commented May 19, 2022

👋 Welcome back alanb! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented May 19, 2022

@AlanBateman The following labels will be automatically applied to this pull request:

  • jmx
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org jmx jmx-dev@openjdk.org labels May 19, 2022
@AlanBateman
Copy link
Contributor Author

/label remove imx

@openjdk
Copy link

openjdk bot commented May 19, 2022

@AlanBateman
The label imx is not a valid label.
These labels are valid:

  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

@AlanBateman
Copy link
Contributor Author

/label remove jmx

@openjdk openjdk bot removed the jmx jmx-dev@openjdk.org label May 19, 2022
@openjdk
Copy link

openjdk bot commented May 19, 2022

@AlanBateman
The jmx label was successfully removed.

@AlanBateman AlanBateman marked this pull request as ready for review May 19, 2022 11:15
@openjdk openjdk bot added the rfr Pull request is ready for review label May 19, 2022
@mlbridge
Copy link

mlbridge bot commented May 19, 2022

Webrevs

@plummercj
Copy link
Contributor

It would be useful if ThreadDump.java contained a comment with a description of the JSON file syntax. It could either be in the form of a simple dump or as a simple syntactic description.

@AlanBateman
Copy link
Contributor Author

AlanBateman commented May 19, 2022

It would be useful if ThreadDump.java contained a comment with a description of the JSON file syntax. It could either be in the form of a simple dump or as a simple syntactic description.

Still TBD on where the JSON "schema" will be specified, it might be HotSpotDiagnosMXBean.dumpThreads as it will needed by tools that parse the JSON text. So when we do that then I think we can reference it from the test class.

@plummercj
Copy link
Contributor

Ok, but I was mostly hoping to have it to make reviewing this PR easier.

@AlanBateman
Copy link
Contributor Author

AlanBateman commented May 19, 2022

If we use JSON schema then it will something like this, does that help?

{
  "type": "object",
  "properties": {
    "threadDump": {
      "type": "object",
      "properties": {
        "processId": {
          "type": "integer",
          "description": "The native process id of the Java virtual machine."
        },
        "time": {
          "type": "string",
          "description": "The time in ISO 8601 format when the thread dump was generated."
        },
        "runtimeVersion": {
          "type": "string",
          "description": "The runtime version, see java.lang.Runtime.version()."
        },
        "threadContainers": {
          "type": "array",
          "description": "The array of thread containers.",
          "items": [
            {
              "type": "object",
              "properties": {
                "container": {
                  "type": "string",
                  "description": "The container name. The container name is unique."
                },
                "parent": {
                  "type": ["string", "null"],
                  "description": "The parent container name or null for the root container."
                },
                "owner": {
                  "type": ["integer", "null"],
                  "description": "The thread identifier of the owner thread or null if not owned."
                },
                "threads": {
                  "type": "array",
                  "description": "The array of threads in the thread container.",
                  "items": [
                    {
                      "type": "object",
                      "properties": {
                        "tid": {
                          "type": "integer",
                          "description": "The thread identifier, see java.lang.Thread.threadId()."
                        },
                        "name": {
                          "type": "string",
                          "description": "The thread name."
                        },
                        "stack": {
                          "type": "array",
                          "description": "The thread stack. The first element is the top of the stack.",
                          "items": [
                            {
                              "type": "string",
                              "description": "A stack trace element, see java.lang.StackTraceElement."
                            }
                          ]
                        }
                      },
                      "required": [
                        "tid",
                        "name",
                        "stack"
                      ]
                    }
                  ]
                },
                "threadCount": {
                  "type": "integer",
                  "description": "The number of threads in the thread container."
                }
              },
              "required": [
                "container",
                "parent",
                "owner",
                "threads",
                "threadCount"
              ]
            }
          ]
        }
      },
      "required": [
        "processId",
        "time",
        "runtimeVersion",
        "threadContainers"
      ]
    }
  },
  "required": [
    "threadDump"
  ]
}

@plummercj
Copy link
Contributor

I think a short example dump would actually be easier to read alongside the code.

@AlanBateman
Copy link
Contributor Author

I think a short example dump would actually be easier to read alongside the code.

That's a good idea. I've updated the class description to include an example and also a code example of how it can be used in tests. The thread dump example collapses several objects to avoid it getting too unwieldily.

I've started PR8807 to document the format.

@AlanBateman
Copy link
Contributor Author

AlanBateman commented May 23, 2022

I've updated the patch to generate the process and thread identifiers as strings rather than numbers (as JSON numbers that are integers don't have the required range). The test infra and DumpThreads.java test are expanded a bit and now test the processId, time and runtimeVersion fields.

@openjdk
Copy link

openjdk bot commented May 23, 2022

@AlanBateman This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8287008: Improve tests for thread dumps in JSON format

Reviewed-by: cjplummer

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 53 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 23, 2022
@AlanBateman
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented May 24, 2022

Going to push as commit 15f1583.
Since your change was applied there have been 57 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 24, 2022
@openjdk openjdk bot closed this May 24, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 24, 2022
@openjdk
Copy link

openjdk bot commented May 24, 2022

@AlanBateman Pushed as commit 15f1583.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

3 participants