summaryrefslogtreecommitdiff
path: root/docs/reference/node-startup-controller/test-legacy-app-handling.xml
blob: 4f1191feece4c902dc1fef23eb0382c1b686b758 (plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                          "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
]>

<refentry id="test-legacy-app-handling">
  <refmeta>
    <refentrytitle>Tests for legacy application handling</refentrytitle>
  </refmeta>

  <refnamediv>
    <refname>Tests for legacy application handling</refname>
    <refpurpose>
      How to verify that the legacy app handler correctly registers the units as shutdown
      consumers, and that it correctly shuts them down when the Node State manager dummy
      tells it to.
    </refpurpose>
  </refnamediv>

  <refsect1>
    <title>Test environment and setup</title>
    <refsect2>
      <title>Services units</title>
      <para>
        This test uses the "cups.service" and the "avahi-daemon.service" as units which
        are going to be registered as shutdown consumers. These units may or may not
        exist in the system, but this does not affect to the result of the tests.
      </para>
    </refsect2>

    <refsect2>
      <title>Starting the necessary services</title>
      <para>
        The NSM dummy and the Node Startup Controller services need to be started
        prior to running any of the tests described here. This is done using the
        following commands:
      </para>
      <programlisting>systemctl start nsm-dummy.service
systemctl start node-startup-controller.service</programlisting>
    </refsect2>

    <refsect2>
      <title>Restarting the Node Startup Controller</title>
      <para>
        Between each test, the Node Startup Controller should be restarted to ensure that
        it is available, and that no legacy apps are lingering from the last test. It can
        be restarted with the following command:
      </para>
      <programlisting>systemctl restart node-startup-controller.service</programlisting>
    </refsect2>
  </refsect1>

  <refsect1>
    <title>Test Cases</title>
    <para>
      The following test cases for LUC management are described in this document:
      <itemizedlist>
        <listitem><para><xref linkend="test-lah-nsc-self-registers" endterm="test-lah-nsc-self-registers-title" /></para></listitem>
        <listitem><para><xref linkend="test-lah-register-fast-normal-consumers" endterm="test-lah-register-fast-normal-consumers-title" /></para></listitem>
        <listitem><para><xref linkend="test-lah-register-two-normal-consumers" endterm="test-lah-register-two-normal-consumers-title" /></para></listitem>
        <listitem><para><xref linkend="test-lah-reregister" endterm="test-lah-reregister-title" /></para></listitem>
        <listitem><para><xref linkend="test-lah-register-invalid-arguments" endterm="test-lah-register-invalid-arguments-title" /></para></listitem>
      </itemizedlist>
    </para>
  </refsect1>

  <refsect1 id="test-lah-nsc-self-registers">
    <title id="test-lah-nsc-self-registers-title">1. Node Startup Controller registers itself on startup</title>
    <refsect2>
      <title>Description</title>
      <para>
        Every GENIVI application that is managed by the Node State Manager must register
        itself with the NSM as a shutdown client, and this includes the Node Startup
        Controller. This test verifies that the Node Startup Controller registers itself
        with the Node State Manager when it is started.
      </para>
    </refsect2>
    <refsect2>
      <title>Test commands</title>
      <programlisting>kill -s HUP $(pidof nsm-dummy)</programlisting>
    </refsect2>
    <refsect2>
      <title>Desired behaviour and output</title>
      <para>
        The DLT log should now contain the following log messages:
      </para>
      <informaltable><tgroup cols="3">
        <thead>
          <row><entry>APID</entry> <entry>CTID</entry> <entry>Payload</entry></row>
        </thead>
        <tbody>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/0 shutdown mode 1 timeout 1000]</entry></row>
          <row><entry>NSC-</entry> <entry>CTRL</entry> <entry>[Successfully registered the node startup controller as a shutdown consumer]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutdown client unregistered: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController1/ShutdownConsumer/0]</entry></row>
          <row><entry>NSC-</entry> <entry>CTRL</entry> <entry>[Successfully unregistered the node startup controller as a shutdown consumer]</entry></row>
        </tbody>
      </tgroup></informaltable>
    </refsect2>
  </refsect1>

  <refsect1 id="test-lah-register-fast-normal-consumers">
    <title id="test-lah-register-fast-normal-consumers-title">2. Registration of a fast and a normal shutdown consumer</title>
    <refsect2>
      <title>Description</title>
      <para>
        Shutdown Consumers can be registered with two modes - fast and normal. Fast is
        meant for vital applications which must be shut down gracefully, and normal
        applies to everything else that requires a graceful shutdown. This test registers
        shutdown consumers with either mode, and verifies that they are shut down by the
        NSM dummy. The NSM dummy will shut down the fast consumers first, then the normal
        consumers.
      </para>
    </refsect2>
    <refsect2>
      <title>Test commands</title>
      <programlisting>
      /lib/node-startup-controller-1/legacy-app-handler --unit "cups.service" -m 1
      /lib/node-startup-controller-1/legacy-app-handler --unit "avahi-daemon.service" -m 2
      kill -s HUP $(pidof nsm-dummy)
      </programlisting>
    </refsect2>
    <refsect2>
      <title>Desired behaviour and output</title>
      <para>
        The DLT log should now contain the following log messages:
      </para>
      <informaltable><tgroup cols="3">
        <thead>
          <row><entry>APID</entry> <entry>CTID</entry> <entry>Payload</entry></row>
        </thead>
        <tbody>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/1 shutdown mode 1 timeout 1000]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/2 shutdown mode 2 timeout 1000]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/2 shutdown mode 2 timeout 1000 request id XXXXXXX]</entry></row>
          <row><entry>NSC-</entry> <entry>LAH-</entry> <entry>[Completing a lifecycle request: request id XXXXXXX]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/1 shutdown mode 1 timeout 1000 request id YYYYYYY]</entry></row>
          <row><entry>NSC-</entry> <entry>LAH-</entry> <entry>[Completing a lifecycle request: request id YYYYYYY]</entry></row>
        </tbody>
      </tgroup></informaltable>
    </refsect2>
  </refsect1>

    <refsect1 id="test-lah-register-two-normal-consumers">
    <title id="test-lah-register-two-normal-consumers-title">3. Registration of two normal shutdown consumers</title>
    <refsect2>
      <title>Description</title>
      <para>
        The Node State Manager shuts down consumers in reverse order of their registration.
        This test verifies this by registering the consumers with the same mode.
      </para>
    </refsect2>
    <refsect2>
      <title>Test commands</title>
      <programlisting>
      /lib/node-startup-controller-1/legacy-app-handler --unit "cups.service" -m 1
      /lib/node-startup-controller-1/legacy-app-handler --unit "avahi-daemon.service" -m 1
      kill -s HUP $(pidof nsm-dummy)
      </programlisting>
    </refsect2>
     <refsect2>
      <title>Desired behaviour and output</title>
      <para>
        The DLT log should now contain the following log messages:
      </para>
      <informaltable><tgroup cols="3">
        <thead>
          <row><entry>APID</entry> <entry>CTID</entry> <entry>Payload</entry></row>
        </thead>
        <tbody>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/1 shutdown mode 1 timeout 1000]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/2 shutdown mode 1 timeout 1000]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/2 shutdown mode 1 timeout 1000 request id XXXXXXX]</entry></row>
          <row><entry>NSC-</entry> <entry>LAH-</entry> <entry>[Completing a lifecycle request: request id XXXXXXX]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/1 shutdown mode 1 timeout 1000 request id YYYYYYY]</entry></row>
          <row><entry>NSC-</entry> <entry>LAH-</entry> <entry>[Completing a lifecycle request: request id YYYYYYY]</entry></row>
        </tbody>
      </tgroup></informaltable>
    </refsect2>
  </refsect1>

  <refsect1 id="test-lah-reregister">
    <title id="test-lah-reregister-title">4. Registration of the same unit twice with different modes and timeouts</title>
    <refsect2>
      <title>Description</title>
      <para>
        The Legacy App Handler handles repeated registration (i.e. with different modes)
        by registering the old shutdown consumer with the Node State Manager again. The
        Node State Manager will register any new modes with itself, and use the new
        timeout. This test verifies that registering with separate modes will shut the app
        down in both modes with the new timeout.
      </para>
    </refsect2>
    <refsect2>
      <title>Test commands</title>
      <programlisting>
      /lib/node-startup-controller-1/legacy-app-handler --unit "cups.service" -m 1 -t 1500
      /lib/node-startup-controller-1/legacy-app-handler --unit "cups.service" -m 2 -t 500
      kill -s HUP $(pidof nsm-dummy)
      </programlisting>
    </refsect2>
     <refsect2>
      <title>Desired behaviour and output</title>
      <para>
        The DLT log should now contain the following log messages:
      </para>
      <informaltable><tgroup cols="3">
        <thead>
          <row><entry>APID</entry> <entry>CTID</entry> <entry>Payload</entry></row>
        </thead>
        <tbody>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutdown client registered: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/1 shutdown mode 1 timeout 1500]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Re-registered shutdown client: bus name org.genivi.NodeStartupController1 object path /org/genivi/nodeStartupController1/ShutdownConsumer/1 new shutdown mode 3 new timeout 500]</entry></row>

          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/1 shutdown mode 3 timeout 500 request id XXXXXXX]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Waiting for client to shut down: request id XXXXXXX bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController1/ShutdownConsumer/1 shutdown mode 2]</entry></row>
          <row><entry>NSC-</entry> <entry>LAH-</entry> <entry>[Completing a lifecycle request: request id XXXXXXX]</entry></row>

          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Shutting down a client: bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController/ShutdownConsumer/1 shutdown mode 3 timeout 500 request id XXXXXXX]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Waiting for client to shut down: request id XXXXXXX bus name org.genivi.NodeStartupController1 object path /org/genivi/NodeStartupController1/ShutdownConsumer/1 shutdown mode 1]</entry></row>
          <row><entry>NSC-</entry> <entry>LAH-</entry> <entry>[Completing a lifecycle request: request id XXXXXXX]</entry></row>
        </tbody>
      </tgroup></informaltable>
    </refsect2>
  </refsect1>

  <refsect1 id="test-lah-register-invalid-arguments">
    <title id="test-lah-register-invalid-arguments-title">5. Registration with invalid parameters</title>
    <refsect2>
      <title>Description</title>
      <para>
        The Legacy App Handler validates against the following rules:
        <itemizedlist>
          <listitem>There must be a unit name</listitem>
          <listitem>The mode must be a combination of normal and fast, only (i.e. 1, 2 or 3)</listitem>
          <listitem>The timeout must be non-negative</listitem>
        </itemizedlist>
        This test verifies that invalid input causes an error.
      </para>
    </refsect2>
    <refsect2>
      <title>Test commands</title>
      <programlisting>
      /lib/node-startup-controller-1/legacy-app-handler --unit
      /lib/node-startup-controller-1/legacy-app-handler --unit cups.service -m 0
      /lib/node-startup-controller-1/legacy-app-handler --unit cups.service -m 1 -t -2000
      </programlisting>
    </refsect2>
     <refsect2>
      <title>Desired behaviour and output</title>
      <para>
        The DLT log should now contain the following log messages:
      </para>
      <informaltable><tgroup cols="3">
        <thead>
          <row><entry>APID</entry> <entry>CTID</entry> <entry>Payload</entry></row>
        </thead>
        <tbody>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Failed to parse command line options: Missing argument for --unit]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Failed to register legacy application: invalid shutdown mode 0]</entry></row>
          <row><entry>NSMD</entry> <entry>NSMC</entry> <entry>[Failed to register legacy application: shutdown timeout must be non-negative]</entry></row>
        </tbody>
      </tgroup></informaltable>
    </refsect2>
  </refsect1>

</refentry>