Skip to content

Commit 5370f80

Browse files
committed
xapi-idl: Avoid printing cli output when testing
Use cram tests to expect the desired output of the command instead This reduces the amount of text displayed when running tests, which makes locating the errors in the logs easier When the output of the tools changes deliberately, the expect files can be changed with `dune runtest --auto-promote` Signed-off-by: Pau Ruiz Safont <[email protected]>
1 parent 4bfdf7e commit 5370f80

File tree

19 files changed

+809
-44
lines changed

19 files changed

+809
-44
lines changed

ocaml/xapi-idl/cluster/cli-help.t

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
$ ./cluster_cli.exe --help=plain
2+
NAME
3+
cluster_cli - A CLI for the cluster API. This tool is not intended to
4+
be used as an end user tool
5+
6+
SYNOPSIS
7+
cluster_cli [COMMAND] …
8+
9+
COMMANDS
10+
Observer.create [OPTION]… dbg uuid name_label dict endpoints bool
11+
12+
Observer.destroy [OPTION]… dbg uuid
13+
14+
Observer.init [OPTION]… dbg
15+
16+
Observer.set_attributes [OPTION]… dbg uuid dict
17+
18+
Observer.set_compress_tracing_files [OPTION]… dbg bool
19+
20+
Observer.set_enabled [OPTION]… dbg uuid bool
21+
22+
Observer.set_endpoints [OPTION]… dbg uuid endpoints
23+
24+
Observer.set_export_interval [OPTION]… dbg float
25+
26+
Observer.set_host_id [OPTION]… dbg string
27+
28+
Observer.set_max_file_size [OPTION]… dbg int
29+
30+
Observer.set_max_spans [OPTION]… dbg int
31+
32+
Observer.set_max_traces [OPTION]… dbg int
33+
34+
Observer.set_trace_log_dir [OPTION]… dbg string
35+
36+
UPDATES.get [OPTION]… dbg timeout
37+
Get updates from corosync-notifyd, this blocking call will return
38+
when there is an update from corosync-notifyd or it is timed out
39+
after timeout_p seconds
40+
41+
create [OPTION]… dbg init_config
42+
Creates the cluster. The call takes the initial config of the
43+
initial host to add to the cluster. This will be the address on
44+
which the rings will be created.
45+
46+
declare-changed-addrs [OPTION]… dbg changed_members
47+
Declare that one or more hosts in the cluster have changed
48+
address. Only use this command if unable to rejoin the cluster
49+
using `enable` because the IPv4 addresses of all nodes this node
50+
previously saw are now invalid. If any one of these addresses
51+
remains valid on an enabled node then this action is unnecessary.
52+
53+
declare-dead [OPTION]… dbg dead_members
54+
Declare that some hosts in the cluster are permanently dead.
55+
Removes the hosts from the cluster. If the hosts do attempt to
56+
rejoin the cluster in future, this may lead to fencing of other
57+
hosts and/or data loss or data corruption.
58+
59+
destroy [OPTION]… dbg
60+
Destroys a created cluster
61+
62+
diagnostics [OPTION]… dbg
63+
Returns diagnostic information about the cluster
64+
65+
disable [OPTION]… dbg
66+
Stop the cluster on this host; leave the rest of the cluster
67+
enabled. The cluster can be reenabled either by restarting the
68+
host, or by calling the `enable` API call.
69+
70+
enable [OPTION]… dbg init_config
71+
Rejoins the cluster following a call to `disable`. The parameter
72+
passed is the cluster config to use (optional fields set to None
73+
unless updated) in case it changed while the host was disabled.
74+
(Note that changing optional fields isn't yet supported, TODO)
75+
76+
join [OPTION]… dbg token new_member tls_config existing_members
77+
Adds a node to an initialised cluster. Takes the IPv4 address of
78+
the new member and a list of the addresses of all the existing
79+
members.
80+
81+
leave [OPTION]… dbg
82+
Causes this host to permanently leave the cluster, but leaves the
83+
rest of the cluster enabled. This is not a temporary removal - if
84+
the admin wants the hosts to rejoin the cluster again, he will
85+
have to call `join` rather than `enable`.
86+
87+
set-tls-verification [OPTION]… dbg server_pem_path
88+
trusted_bundle_path cn enabled
89+
Enable or disable TLS verification for xapi/clusterd
90+
communication. The trusted_bundle_path is ignored when
91+
verification is disabled and can be empty
92+
93+
switch-cluster-stack [OPTION]… dbg cluster_stack
94+
Switch cluster stack version to the target
95+
96+
COMMON OPTIONS
97+
--help[=FMT] (default=auto)
98+
Show this help in format FMT. The value FMT must be one of auto,
99+
pager, groff or plain. With auto, the format is pager or plain
100+
whenever the TERM env var is dumb or undefined.
101+
102+
--version
103+
Show version information.
104+
105+
EXIT STATUS
106+
cluster_cli exits with:
107+
108+
0 on success.
109+
110+
123 on indiscriminate errors reported on standard error.
111+
112+
124 on command line parsing errors.
113+
114+
125 on unexpected internal errors (bugs).
115+

ocaml/xapi-idl/cluster/dune

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
xapi-idl
2828
xapi-idl.cluster))
2929

30-
(rule
31-
(alias runtest)
32-
(deps (:x cluster_cli.exe))
30+
(cram
3331
(package xapi-idl)
34-
(action (run %{x} --help=plain)))
32+
(deps cluster_cli.exe))

ocaml/xapi-idl/example/cli-help.t

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
$ ./example.exe --help=plain
2+
NAME
3+
Example-service
4+
5+
SYNOPSIS
6+
Example-service [OPTION]…
7+
8+
DESCRIPTION
9+
This is an example service which demonstrates the configuration
10+
mechanism.
11+
12+
OPTIONS
13+
--config=VAL (absent=/etc/example.exe.conf)
14+
Location of configuration file
15+
16+
--config-dir=VAL (absent=/etc/example.exe.conf.d)
17+
Location of directory containing configuration file fragments
18+
19+
--default-format=VAL (absent=vhd)
20+
Default format for disk files
21+
22+
--disable-logging-for=VAL
23+
A space-separated list of debug modules to suppress logging from
24+
25+
--inventory=VAL (absent=/etc/xensource-inventory)
26+
Location of the inventory file
27+
28+
--log=VAL (absent=syslog:daemon)
29+
Where to write log messages
30+
31+
--loglevel=VAL (absent=debug)
32+
Log level
33+
34+
--ls=VAL (absent=/bin/ls)
35+
program used to list things
36+
37+
--pidfile=VAL (absent=/var/run/example.exe.pid)
38+
Filename to write process PID
39+
40+
--queue-name=VAL (absent=org.xen.xapi.ffs)
41+
Comma-separated list of queue names to listen on
42+
43+
--search-path=VAL
44+
Search path for resources
45+
46+
--sh=VAL (absent=/bin/sh)
47+
interpreter for arcane programming language
48+
49+
--socket-path=VAL (absent=/var/xapi/socket)
50+
Path of listening socket
51+
52+
--sr-mount-path=VAL (absent=/mnt)
53+
Default mountpoint for mounting remote filesystems
54+
55+
--switch-path=VAL (absent=/var/run/message-switch/sock)
56+
Unix domain socket path on localhost where the message switch is
57+
listening
58+
59+
--timeslice=VAL (absent=0.05)
60+
timeslice in seconds
61+
62+
--use-switch=VAL (absent=true)
63+
true if the message switch is to be enabled
64+
65+
COMMON OPTIONS
66+
These options are common to all services.
67+
68+
--help[=FMT] (default=auto)
69+
Show this help in format FMT. The value FMT must be one of auto,
70+
pager, groff or plain. With auto, the format is pager or plain
71+
whenever the TERM env var is dumb or undefined.
72+
73+
--version
74+
Show version information.
75+
76+
EXIT STATUS
77+
Example-service exits with:
78+
79+
0 on success.
80+
81+
123 on indiscriminate errors reported on standard error.
82+
83+
124 on command line parsing errors.
84+
85+
125 on unexpected internal errors (bugs).
86+
87+
BUGS
88+
Check bug reports at http://github.com/xapi-project/xen-api
89+
90+

ocaml/xapi-idl/example/dune

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
)
1010
(preprocess (pps ppx_deriving_rpc)))
1111

12-
(rule
13-
(alias runtest)
14-
(deps (:x example.exe))
12+
(cram
1513
(package xapi-idl)
16-
(action (run %{x} --help=plain)))
14+
(deps example.exe))

ocaml/xapi-idl/gpumon/cli-help.t

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
$ ./gpumon_cli.exe --help=plain
2+
NAME
3+
gpumon_cli - A CLI for the GPU monitoring API. This allows scripting
4+
of the gpumon daemon for testing and debugging. This tool is not
5+
intended to be used as an end user tool
6+
7+
SYNOPSIS
8+
gpumon_cli [COMMAND] …
9+
10+
COMMANDS
11+
get_pgpu_metadata [OPTION]… debug_info pgpu_address
12+
Gets the metadata for a pGPU, given its address (PCI bus ID).
13+
14+
get_pgpu_vgpu_compatibility [OPTION]… debug_info
15+
nvidia_pgpu_metadata nvidia_vgpu_metadata_list
16+
Checks compatibility between a pGPU (on a host) and a list of
17+
vGPUs (assigned to a VM). Note: A VM may use several vGPUs. The
18+
use case is VM.suspend/VM.resume: before VM.resume
19+
[nvidia_vgpu_metadata] of the suspended VM is checked against the
20+
[nvidia_pgpu_metadata] on the host where the VM is resumed.
21+
22+
get_pgpu_vm_compatibility [OPTION]… debug_info pgpu_address domid
23+
nvidia_pgpu_metadata
24+
Checks compatibility between a VM's vGPU(s) and another pGPU.
25+
26+
get_vgpu_metadata [OPTION]… debug_info domid pgpu_address vgpu_uuid
27+
Obtains metadata for all vGPUs running in a domain.
28+
29+
nvml_attach [OPTION]… debug_info
30+
Attach nVidia cards to Gpumon for metrics and compatibility
31+
checking.
32+
33+
nvml_detach [OPTION]… debug_info
34+
Detach nVidia cards from Gpumon
35+
36+
nvml_is_attached [OPTION]… debug_info
37+
Return true if nVidia cards are currently attached.
38+
39+
COMMON OPTIONS
40+
--help[=FMT] (default=auto)
41+
Show this help in format FMT. The value FMT must be one of auto,
42+
pager, groff or plain. With auto, the format is pager or plain
43+
whenever the TERM env var is dumb or undefined.
44+
45+
--version
46+
Show version information.
47+
48+
EXIT STATUS
49+
gpumon_cli exits with:
50+
51+
0 on success.
52+
53+
123 on indiscriminate errors reported on standard error.
54+
55+
124 on command line parsing errors.
56+
57+
125 on unexpected internal errors (bugs).
58+

ocaml/xapi-idl/gpumon/dune

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
xapi-idl
2828
xapi-idl.gpumon))
2929

30-
(rule
31-
(alias runtest)
32-
(deps (:x gpumon_cli.exe))
30+
(cram
3331
(package xapi-idl)
34-
(action (run %{x} --help=plain)))
32+
(deps gpumon_cli.exe))
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$ ./xapiguard_cli.exe --help=plain
2+
./cluster_cli.exe: No such file or directory
3+
[127]

ocaml/xapi-idl/guard/privileged/dune

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
(package varstored-guard)
1919
(libraries
2020
cmdliner
21-
21+
2222
rpclib.cmdliner
2323
rpclib.core
2424
rpclib.markdown
2525
xapi-idl
2626
xapi-idl.guard.privileged
2727
))
2828

29-
(rule
30-
(alias runtest)
31-
(deps xapiguard_cli.exe)
29+
(cram
3230
(package varstored-guard)
33-
(action (run %{deps} --help=plain)))
31+
(deps xapiguard_cli.exe))
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
$ ./varstored_cli.exe --help=plain
2+
NAME
3+
varstored_cli - debug CLI
4+
5+
SYNOPSIS
6+
varstored_cli [COMMAND] …
7+
8+
COMMANDS
9+
VM.get_NVRAM [--socket=SOCKET] [OPTION]… string string
10+
Get the current VM's NVRAM contents
11+
12+
VM.get_by_uuid [--socket=SOCKET] [OPTION]… string string
13+
Dummy, for wire compatibility with XAPI
14+
15+
VM.set_NVRAM_EFI_variables [--socket=SOCKET] [OPTION]… string string
16+
string
17+
Set the current VM's NVRAM contents
18+
19+
message.create [--socket=SOCKET] [OPTION]… string string int64
20+
string string string
21+
Send an alert when booting a UEFI guest fails
22+
23+
session.login_with_password [--socket=SOCKET] [OPTION]… string
24+
string string string
25+
Dummy, for wire compatibility with XAPI
26+
27+
session.logout [--socket=SOCKET] [OPTION]… string
28+
Dummy, for wire compatibility with XAPI
29+
30+
COMMON OPTIONS
31+
--help[=FMT] (default=auto)
32+
Show this help in format FMT. The value FMT must be one of auto,
33+
pager, groff or plain. With auto, the format is pager or plain
34+
whenever the TERM env var is dumb or undefined.
35+
36+
--version
37+
Show version information.
38+
39+
EXIT STATUS
40+
varstored_cli exits with:
41+
42+
0 on success.
43+
44+
123 on indiscriminate errors reported on standard error.
45+
46+
124 on command line parsing errors.
47+
48+
125 on unexpected internal errors (bugs).
49+

ocaml/xapi-idl/guard/varstored/dune

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717
(modules varstored_cli)
1818
(libraries
1919
cmdliner
20-
20+
2121
rpclib.cmdliner
2222
rpclib.core
2323
rpclib.markdown
2424
xapi-idl
2525
xapi-idl.guard.varstored
2626
))
2727

28-
(rule
29-
(alias runtest)
30-
(deps varstored_cli.exe)
28+
(cram
3129
(package xapi-idl)
32-
(action (run %{deps} --help=plain)))
30+
(deps varstored_cli.exe))

0 commit comments

Comments
 (0)