Skip to content

Commit a266aef

Browse files
Add general guidelines for writing test scripts regarding RFC 2119 Ke… (#154)
* Add general guidelines for writing test scripts regarding RFC 2119 Keywords (standards/issues/#447) --------- Signed-off-by: cah-patrickthiem <[email protected]>
1 parent c467204 commit a266aef

File tree

1 file changed

+173
-0
lines changed

1 file changed

+173
-0
lines changed
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
title: SCS RFC2119 Keyword Test Guide
3+
type:
4+
status: Draft
5+
track: Global
6+
---
7+
8+
## Introduction
9+
10+
The development and validation of tests within the Sovereign Cloud Stack (SCS) is a critical endeavor aimed at ensuring that cloud technologies meet the highest standards of interoperability, security and sovereignty. This process is not only about aligning with the technical specifications and standards set by SCS but also about safeguarding the principles of open-source collaboration and the autonomy of cloud services. By thoroughly crafting tests that adhere to the stringent requirement levels as indicated by [RFC2119 keywords](https://datatracker.ietf.org/doc/html/rfc2119), we ensure that the infrastructure, services and their integrations within the SCS ecosystem are robust, secure and sovereign.
11+
12+
This detailed process is crucial for stakeholders seeking to develop or utilize sovereign cloud services that are reliable, compliant and capable of standing up to the demands of modern cloud computing. It serves as an indispensable guide for developers, operators and policymakers who are involved in the creation, deployment and governance of cloud services within SCS. By understanding and implementing the standards and tests defined by the SCS, professionals can contribute to a cloud infrastructure that is not only technologically advanced but also aligns with the core values of sovereignty and open-source ethics.
13+
14+
Therefore, for individuals tasked with writing tests and defining standards within SCS, this document is particularly important. It serves as a base with guidelines on how to use and understand RFC2119 keywords in the context of SCS. Its insights are crucial for anyone from technical architects to regulatory bodies within the SCS ecosystem, underlining the foundational principles necessary for achieving a sovereign cloud environment.
15+
16+
## 1. Understanding SCS Standards and RFC2119 Keywords
17+
18+
SCS standards use RFC2119 keywords like:
19+
20+
- **MUST** (same as **REQUIRED**, **SHALL**),
21+
- **MUST NOT** (same as **SHALL NOT**),
22+
- **SHOULD** (same as **RECOMMENDED**),
23+
- **SHOULD NOT** (same as **NOT RECOMMENDED**),
24+
- **MAY** (same as **OPTIONAL**)
25+
26+
to define requirements for SCS-compatible IaaS and KaaS resources. These standards & tests are crucial for ensuring interoperability and sovereignty in cloud services, as they are built on open-source components such as Kubernetes and OpenStack.
27+
28+
To ensure readability and comprehensibility, only the main keywords **MUST**, **MUST NOT**, **SHOULD**, **SHOULD NOT** and **MAY** are referred to below.
29+
30+
## 2. Interpreting RFC2119 Keywords in the Context of SCS
31+
32+
- **MUST and MUST NOT**: These are binary and straightforward to test. Compliance or
33+
non-compliance directly affects whether the standard is satisfied. For visualization, fulfilled
34+
requirements could be marked in green, unfulfilled ones in red.
35+
- **SHOULD and SHOULD NOT**: These represent recommendations. While fulfilling these do
36+
not directly affect standard compliance, it is advised for future-proofing against
37+
potential standard evolutions. Non-compliance could be visualized in yellow, possibly
38+
with a valid reason for non-fulfillment.
39+
- **MAY**: This is more flexible and could be used to provide additional
40+
information or best practices. Their impact on compliance is not as direct as **MUST** or
41+
**SHOULD** categories. These can be marked as blue.
42+
43+
## 3. Channels for Output in Test Scripts
44+
45+
In test scripts, different channels are used to convey information of different importance to the user. These channels are based on the ubiquitous and de-facto standard logging levels of common logging libraries in scripting and programming languages, in particular Python: DEBUG, INFO, WARNING, ERROR and CRITICAL.
46+
47+
Alignment of the RFC2119 keywords with specific channels in test scripts:
48+
49+
- **MUST** and **MUST NOT** lead to the ERROR channel for failed tests
50+
- **SHOULD** and **SHOULD NOT** lead to the WARNING channel, the test is still passed
51+
- **MAY** leads to the INFO channel, the test is still passed
52+
53+
However, the CRITICAL level is not directly associated with any of the RFC2119 keywords; it is instead used to signify that a test was unable to complete or was interrupted due to various issues, such as runtime failures.
54+
55+
## 4. Compliance and Test Passing Criteria
56+
57+
A test is considered to pass if and only if it doesn't produce any messages on the
58+
ERROR nor the CRITICAL channel. The presence of warnings or informational items from
59+
**SHOULD** and **MAY** categories do not directly impact the pass/fail status but is
60+
important for overall quality and compatibility with future standards.
61+
62+
That means a test can have one of three results:
63+
64+
- fail: if it has at least one message on ERROR
65+
- DNF (did not finish): if it has no message on ERROR, but at least one on CRITICAL
66+
- pass: otherwise
67+
68+
In addition, a test **MUST** exit with a non-zero exit code (e.g., via `sys.exit(…)`) if there are any ERROR or CRITICAL messages, thus signaling a failure to meet a standard.
69+
70+
In test scripts it is a **MUST** to redirect all channel outputs to standard error (**stderr**), which aligns with Python's default logging behavior. The format which **MUST** be used is **CHANNEL: MESSAGE**, where **CHANNEL** represents the log level (e.g., DEBUG, INFO, WARNING, ERROR, CRITICAL) and **MESSAGE** encapsulates the actual log message.
71+
72+
For instance, when logging an INFO regarding a Kubernetes cluster, the format on the command line should be like this:
73+
74+
```md
75+
INFO: Checking cluster specified by context 'my-cluster' in /path/to/.kube/config.
76+
```
77+
78+
This example adheres to our proposed format by clearly indicating the severity level (INFO) followed by the specific message intended for the user or developer.
79+
80+
## Examples
81+
82+
### 5.1 Example: Standards Document using RFC2119 Keywords
83+
84+
The following example of a fictitious document for a "Web Server Installation Standard"
85+
is intended to illustrate the use of RFC2119 keywords in connection with the creation of
86+
SCS-compliant standard documents.
87+
88+
### Web Server Installation Standard
89+
90+
#### Purpose
91+
92+
This document provides a concise set of requirements for installing a secure web server.
93+
94+
#### Requirements
95+
96+
- Web Server Software: Apache HTTP Server 2.4.x or Nginx 1.18.x **MUST** be installed. No
97+
other web server software versions or types are permitted.
98+
99+
- Operating System: The server **MUST** run on an OS that receives current security updates.
100+
Unsupported versions **MUST NOT** be used.
101+
102+
- TLS Configuration: TLS 1.2 or higher **MUST** be enabled for all connections. SSL and
103+
earlier TLS versions **MUST NOT** be used.
104+
105+
- Security Patches: The web server and OS **MUST** be kept up-to-date with security patches.
106+
Critical patches **SHOULD** be applied within 48 hours of release.
107+
108+
- Firewall Setup: The firewall **SHOULD** be configured to allow only necessary ports,
109+
such as 80 (HTTP) and 443 (HTTPS). All unnecessary ports **SHOULD NOT** be open.
110+
111+
- Backup Plan: Regular backups of the web server data **MAY** be performed, and it is
112+
recommended that backup integrity checks are conducted to ensure recoverability.
113+
114+
#### Compliance
115+
116+
Failure to comply with these requirements results in the web server being
117+
considered non-compliant with the organization's security policies.
118+
119+
### 5.2 Example: Test script using RFC2119 Keywords
120+
121+
The following example of a fictitious code for a test of "process_requirements"
122+
is intended to illustrate the use of RFC2119 keywords in connection with the
123+
creation of SCS-compliant standard tests.
124+
125+
```python
126+
127+
import logging
128+
logging.basicConfig(level=logging.DEBUG)
129+
logger = logging.getLogger(__name__)
130+
131+
def process_requirements(var1, var2):
132+
try:
133+
# debug log for input variables
134+
logger.debug(f"Received input var1: {var1}, var2: {var2}")
135+
136+
# example of an error case (equivalent to MUST and MUST NOT)
137+
if var1 < 0:
138+
logger.error("var1 must be positive")
139+
elif var1 > 100:
140+
logger.error("var1 must not exceed 100")
141+
142+
# add debug log to confirm evaluation of var1
143+
logger.debug(f"var1 evaluated: {var1 > 0 and var1 < 100}")
144+
145+
# example of a warning case (equivalent to SHOULD and SHOULD NOT)
146+
if var2 < 10:
147+
logger.warning("var2 should be at least 10 for optimal performance")
148+
elif var2 > 50:
149+
logger.warning("var2 should not exceed 50 for optimal performance")
150+
151+
# add debug log to confirm evaluation of var2
152+
logger.debug(f"var2 evaluated: {var2 > 10 and var2 < 50}")
153+
154+
# example of an informative case (equivalent to MAY)
155+
if var1 + var2 < 100:
156+
logger.info("Combination is within recommended range")
157+
else:
158+
logger.info("Combination exceeds the recommended range but may still proceed")
159+
160+
# debug log before completing the process
161+
logger.debug(f"Final evaluation before completion: var1 + var2 = {var1 + var2}")
162+
163+
# success log
164+
logger.debug("Process completed successfully")
165+
166+
except ValueError as e:
167+
# debug log before raising a critical error
168+
logger.debug("Encountered a critical error about to log", exc_info=True)
169+
logger.critical(f"Process failed: {e}", exc_info=True)
170+
171+
```
172+
173+
**Note**: The DEBUG channel is used for additional information for developers to better understand a process and does not apply to RFC2119 keywords.

0 commit comments

Comments
 (0)