Skip to content

Commit

Permalink
report: separate release metadata
Browse files Browse the repository at this point in the history
Report release metadata separately from `componentVersions`.
Test `componentVersions` and `release` values in the report.

PR-URL: #25826
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
richardlau authored and addaleax committed Feb 1, 2019
1 parent 704a440 commit 1007416
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
10 changes: 6 additions & 4 deletions doc/api/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ is provided below for reference.
"glibcVersionRuntime": "2.17",
"glibcVersionCompiler": "2.17",
"wordSize": "64 bit",
"arch": "x64",
"platform": "linux",
"componentVersions": {
"node": "12.0.0-pre",
"v8": "7.1.302.28-node.5",
Expand All @@ -50,10 +52,10 @@ is provided below for reference.
"napi": "3",
"llhttp": "1.0.1",
"http_parser": "2.8.0",
"openssl": "1.1.0j",
"arch": "x64",
"platform": "linux",
"release": "node"
"openssl": "1.1.0j"
},
"release": {
"name": "node"
},
"osVersion": "Linux 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018",
"machine": "Linux 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018test_machine x86_64"
Expand Down
33 changes: 27 additions & 6 deletions src/node_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ static void PrintGCStatistics(JSONWriter* writer, Isolate* isolate);
static void PrintSystemInformation(JSONWriter* writer);
static void PrintLoadedLibraries(JSONWriter* writer);
static void PrintComponentVersions(JSONWriter* writer);
static void PrintRelease(JSONWriter* writer);
static void LocalTime(TIME_TYPE* tm_struct);

// Global variables
Expand Down Expand Up @@ -341,10 +342,15 @@ static void PrintVersionInformation(JSONWriter* writer) {

// Report Process word size
writer->json_keyvalue("wordSize", sizeof(void*) * 8);
writer->json_keyvalue("arch", node::per_process::metadata.arch);
writer->json_keyvalue("platform", node::per_process::metadata.platform);

// Report deps component versions
PrintComponentVersions(writer);

// Report release metadata.
PrintRelease(writer);

// Report operating system and machine information (Windows)
#ifdef _WIN32
{
Expand Down Expand Up @@ -724,12 +730,27 @@ static void PrintComponentVersions(JSONWriter* writer) {
NODE_VERSIONS_KEYS(V)
#undef V

// Some extra information that is not present in node_metadata.
writer->json_keyvalue("arch", NODE_ARCH);
writer->json_keyvalue("platform", NODE_PLATFORM);
writer->json_keyvalue("release", NODE_RELEASE);
if (NODE_VERSION_IS_LTS != 0)
writer->json_keyvalue("lts", NODE_VERSION_LTS_CODENAME);
writer->json_objectend();
}

// Report runtime release information.
static void PrintRelease(JSONWriter* writer) {
writer->json_objectstart("release");
writer->json_keyvalue("name", node::per_process::metadata.release.name);
#if NODE_VERSION_IS_LTS
writer->json_keyvalue("lts", node::per_process::metadata.release.lts);
#endif

#ifdef NODE_HAS_RELEASE_URLS
writer->json_keyvalue("headersUrl",
node::per_process::metadata.release.headers_url);
writer->json_keyvalue("sourceUrl",
node::per_process::metadata.release.source_url);
#ifdef _WIN32
writer->json_keyvalue("libUrl", node::per_process::metadata.release.lib_url);
#endif // _WIN32
#endif // NODE_HAS_RELEASE_URLS

writer->json_objectend();
}

Expand Down
3 changes: 3 additions & 0 deletions test/common/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function validateContent(data) {
'libuv', 'environmentVariables', 'sharedObjects'].forEach((section) => {
assert(report.hasOwnProperty(section));
});

assert.deepStrictEqual(report.header.componentVersions, process.versions);
assert.deepStrictEqual(report.header.release, process.release);
}

module.exports = { findReports, validate, validateContent };

0 comments on commit 1007416

Please sign in to comment.