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