-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathdut-details.R
executable file
·117 lines (96 loc) · 3.92 KB
/
dut-details.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env Rscript
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
# Display details for the 'Device Under Test', for all data sets being processed.
suppressMessages(suppressWarnings(library(tidyr))) # for gather().
library(tibble)
suppressMessages(suppressWarnings(library(plyr))) # rbind.fill
# So we can plot multiple graphs
library(gridExtra) # together.
suppressMessages(suppressWarnings(library(ggpubr))) # for ggtexttable.
suppressMessages(library(jsonlite)) # to load the data.
render_dut_details <- function()
{
# A list of all the known results files we might find the information inside.
resultsfiles=c(
"k8s-parallel.json",
"k8s-scaling.json",
"k8s-rapid.json"
)
data=c()
stats=c()
stats_names=c()
# For each set of results
for (currentdir in resultdirs) {
count=1
dirstats=c()
datasetname=c()
for (resultsfile in resultsfiles) {
fname=paste(inputdir, currentdir, resultsfile, sep="/")
if ( !file.exists(fname)) {
#warning(paste("Skipping non-existent file: ", fname))
next
}
# Derive the name from the test result dirname
datasetname=basename(currentdir)
# Import the data
fdata=fromJSON(fname)
if (length(fdata$'kubectl-version') != 0 ) {
# We have kata-runtime data
dirstats=tibble("Client Ver"=as.character(fdata$'kubectl-version'$clientVersion$gitVersion))
dirstats=cbind(dirstats, "Server Ver"=as.character(fdata$'kubectl-version'$serverVersion$gitVersion))
numnodes= nrow(fdata$'kubectl-get-nodes'$items)
dirstats=cbind(dirstats, "No. nodes"=as.character(numnodes))
if (numnodes != 0) {
first_node=fdata$'kubectl-get-nodes'$items[1,]
dirstats=cbind(dirstats, "- Node0 name"=as.character(first_node$metadata$name))
havekata=first_node$metadata$labels$'katacontainers.io/kata-runtime'
if ( is.null(havekata) ) {
dirstats=cbind(dirstats, " Have Kata"=as.character('false'))
} else {
dirstats=cbind(dirstats, " Have Kata"=as.character(havekata))
}
dirstats=cbind(dirstats, " CPUs"=as.character(first_node$status$capacity$cpu))
dirstats=cbind(dirstats, " Memory"=as.character(first_node$status$capacity$memory))
dirstats=cbind(dirstats, " MaxPods"=as.character(first_node$status$capacity$pods))
dirstats=cbind(dirstats, " PodCIDR"=as.character(first_node$spec$podCIDR))
dirstats=cbind(dirstats, " runtime"=as.character(first_node$status$nodeInfo$containerRuntimeVersion))
dirstats=cbind(dirstats, " kernel"=as.character(first_node$status$nodeInfo$kernelVersion))
dirstats=cbind(dirstats, " kubeProxy"=as.character(first_node$status$nodeInfo$kubeProxyVersion))
dirstats=cbind(dirstats, " Kubelet"=as.character(first_node$status$nodeInfo$kubeletVersion))
dirstats=cbind(dirstats, " OS"=as.character(first_node$status$nodeInfo$osImage))
}
break
}
}
if ( length(dirstats) == 0 ) {
cat(paste("No valid data found for directory ", currentdir, "\n\n"))
}
# use plyr rbind.fill so we can combine disparate version info frames
stats=rbind.fill(stats, dirstats)
stats_names=rbind(stats_names, datasetname)
}
if ( length(stats_names) == 0 ) {
cat("No system details found\n\n")
return()
}
rownames(stats) = stats_names
# Rotate the tibble so we get data dirs as the columns
spun_stats = as_tibble(cbind(What=names(stats), t(stats)))
# Build us a text table of numerical results
# Set up as left hand justify, so the node data indent renders.
tablefontsize=8
tbody.style = tbody_style(hjust=0, x=0.1, size=tablefontsize)
stats_plot = suppressWarnings(ggtexttable(data.frame(spun_stats, check.names=FALSE),
theme=ttheme(base_size=tablefontsize, tbody.style=tbody.style),
rows=NULL
))
# It may seem odd doing a grid of 1x1, but it should ensure we get a uniform format and
# layout to match the other charts and tables in the report.
master_plot = grid.arrange(
stats_plot,
nrow=1,
ncol=1 )
}
render_dut_details()