Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add general guidelines for writing test scripts regarding RFC 2119 Ke… #154

Merged

Conversation

cah-patrickthiem
Copy link
Contributor

@cah-patrickthiem cah-patrickthiem commented Mar 4, 2024

This PR adds a document for general guidelines in regard of writing test scripts, especially on how to use RFC2119 keywords.

Resolves: SovereignCloudStack/standards#447

…ywords (standards/issues/#447)

Signed-off-by: Patrick Thiem <[email protected]>
@martinmo
Copy link
Member

martinmo commented Mar 7, 2024

@cah-patrickthiem is the text ready for review from your point of view or are you still working on it? If you're finished feel free to request a review from me :-)

I already have a few remarks/suggestions:

  • Your change appears to be very out of sync with the current state in main: contributor-docs/ should be used instead of dev-docs/.
  • Did you discuss adding the numbering scheme to the subfolders? I am asking because this might break existing links.
  • To remain consistent with the other files in this repo, RFC2119-keyword-test-guide.md should be completely lower case (slug format).

Copy link
Contributor

@mbuechse mbuechse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a real review, just a remark and a request: once these guidelines are merged, please add a link to https://github.com/SovereignCloudStack/standards/blob/main/.github/ISSUE_TEMPLATE/stabilize-standard.md?plain=1#L15

@cah-patrickthiem
Copy link
Contributor Author

@cah-patrickthiem is the text ready for review from your point of view or are you still working on it? If you're finished feel free to request a review from me :-)

I already have a few remarks/suggestions:

  • Your change appears to be very out of sync with the current state in main: contributor-docs/ should be used instead of dev-docs/.
  • Did you discuss adding the numbering scheme to the subfolders? I am asking because this might break existing links.
  • To remain consistent with the other files in this repo, RFC2119-keyword-test-guide.md should be completely lower case (slug format).

You are completely right here. The branch is out of sync. Also, the subfolders were just a quick catch of me, I understand that this needs to be discussed, but right now I also think this is not necessary.
I will change and fix the things you suggested since I wanted to tackle this anyway.

…2119 Keywords (standards/issues/#447)

Signed-off-by: cah-patrickthiem <[email protected]>
@cah-patrickthiem
Copy link
Contributor Author

Pushed a !fixup to address several inconsistensies. @martinmo the text itself is ready for review, feel free to check it. Also, if you want to add more content regarding tests, feel free to do so.

@mbuechse
Copy link
Contributor

After the remarks I just made, I have a suspicion that these docs may actually become a standard one day. But it's fine to start out with docs.

…ded examples for RFC2119 keyword use for standard documents and tests.
… and added examples for RFC2119 keyword use for standard documents and tests.

Signed-off-by: cah-patrickthiem <[email protected]>
@cah-patrickthiem cah-patrickthiem marked this pull request as ready for review March 28, 2024 13:15
Copy link
Member

@martinmo martinmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed it and left some suggestions for some minor issues I have found. Overall this looks really promising and we should get this merged soon 👍

@martinmo
Copy link
Member

One more thing, because I just read @mbuechse's comment #154 (comment) again.

We should definitely discuss whether to specify in the document that all channels output should go to stderr (for Python logging, this is the default) and what kind of format we expect (<CHANNEL>: <MESSAGE>).

I'm in favor of putting it into this document.

@cah-patrickthiem
Copy link
Contributor Author

One more thing, because I just read @mbuechse's comment #154 (comment) again.

We should definitely discuss whether to specify in the document that all channels output should go to stderr (for Python logging, this is the default) and what kind of format we expect (<CHANNEL>: <MESSAGE>).

I'm in favor of putting it into this document.

Added this as well.


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.

It is crucial to determine and explicitly state within this document the expected conventions for logging output, specifically regarding the redirection of 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is crucial to determine and explicitly state within this document the expected conventions for logging output

This sounds like a prompt for the reader to determine the conventions and should be shortened to something like "the scripts are expected to ...".

Instead of CHANNEL(MESSAGE) the actual format we use is CHANNEL: MESSAGE. Example:

INFO: Checking cluster specified by context 'my-cluster' in /path/to/.kube/config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@martinmo
Copy link
Member

martinmo commented Apr 5, 2024

With regard to my comment:

We should definitely discuss whether to specify in the document that all channels output should go to stderr

I double checked with the existing scripts in the standards repo. Some scripts explicitly set the logging stream to sys.stdout (example). Also, the "umbrella script" scs-compliance-check.py supports both stdout and stderr.

Maybe we should leave the stderr part out and allow both. Otherwise, we need to adapt the affected scripts to conform to this new guideline :-) @mbuechse do you have a strong opinion here?

@mbuechse
Copy link
Contributor

Maybe we should leave the stderr part out and allow both. Otherwise, we need to adapt the affected scripts to conform to this new guideline :-) @mbuechse do you have a strong opinion here?

I wouldn't say strong, but I think the bit with stdout is a mistake, and stderr should be a recommendation at the very least.

@cah-patrickthiem
Copy link
Contributor Author

Maybe we should leave the stderr part out and allow both. Otherwise, we need to adapt the affected scripts to conform to this new guideline :-) @mbuechse do you have a strong opinion here?

I wouldn't say strong, but I think the bit with stdout is a mistake, and stderr should be a recommendation at the very least.

Fyi I talked to @martinmo and we came to the conclusion to make "stderr" a MUST for test scripts.

Copy link
Member

@martinmo martinmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cah-patrickthiem cah-patrickthiem merged commit a266aef into main Apr 12, 2024
4 checks passed
@cah-patrickthiem cah-patrickthiem deleted the General-guidelines-for-writing-test-scripts/#447 branch April 12, 2024 13:41
JuanPTM pushed a commit to JuanPTM/docs that referenced this pull request Jun 3, 2024
SovereignCloudStack#154)

* Add general guidelines for writing test scripts regarding RFC 2119 Keywords (standards/issues/#447)

---------

Signed-off-by: cah-patrickthiem <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

General guidelines for writing test scripts
3 participants