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

[uss_qualifier] Track external file contents #260

Merged

Conversation

BenjaminPelletier
Copy link
Member

Currently, there are some places in the configuration where paths to files are specified. The behavior of the test depends on the contents of these external files, yet this information is not captured in the test baseline -- that is, if the contents of one of these files changed, the behavior of the test would change but the test baseline identifier would not change. Since we want the test baseline identifier to fully describe how the test behaves, this is undesirable.

This PR adds an ExternalFile object that resources can use in their specifications when they want to use the content of an external file. This object contains a hash of that resource's content. If the hash is specified by the user (test designer), then uss_qualifier will refuse to use file content that doesn't match that hash. If the hash is not specified by the user (test designer), then uss_qualifier will populate the hash, the configuration will be augmented with this information, and the configuration saved with the report will contain this information. Since the test baseline identifier is computed as a function of the configuration (as written to the report, after this PR), these hashes will be covered by the test baseline identifier.

Some additional logging statements are added to reduce amount of time spent performing unannounced tasks (it doesn't take 6 seconds to validate the configuration).

A small bug in sequence view generation discovered during this PR's development is fixed.

@BenjaminPelletier BenjaminPelletier marked this pull request as ready for review October 17, 2023 06:27
Copy link
Contributor

@mickmis mickmis left a comment

Choose a reason for hiding this comment

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

LGTM overall. Just two remarks.

The following configurations have references to files but were not updated. Does this break them?

  • monitoring/uss_qualifier/configurations/dev/faa/uft/uft.yaml
  • monitoring/uss_qualifier/configurations/dev/non_docker/resources.yaml
  • monitoring/uss_qualifier/configurations/dev/faa/uft/local_message_signing.yaml
  • monitoring/uss_qualifier/configurations/dev/geoawareness_cis.yaml (unsure about this one)

Also I see one potential negative side-effect from this change, which is checking out the repo and running tests will generate in the configuration files the hashes, thus modify them. Would it make sense that all files do have their hashes set in the configuration in the repository? And if we are to change them, well we just update the hashes at the same time. (and maybe also that is also checked by make format in order to check this easily before committing in the repo :) )

If not specified, will be populated with the hash of the external file at the time of execution."""


def _verify_or_set_hash(file: ExternalFile, content: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: any reason not to put this as a member of ExternalFile?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope; either would work. I'll make it a method instead.

@BenjaminPelletier
Copy link
Member Author

The following configurations have references to files but were not updated. Does this break them?

  • monitoring/uss_qualifier/configurations/dev/faa/uft/uft.yaml
  • monitoring/uss_qualifier/configurations/dev/non_docker/resources.yaml
  • monitoring/uss_qualifier/configurations/dev/faa/uft/local_message_signing.yaml
  • monitoring/uss_qualifier/configurations/dev/geoawareness_cis.yaml (unsure about this one)

Yes, this PR would currently break any of them with the affected file references. I will fix them before merging, but we should probably think about how to reliably maintain artifacts like this that aren't exercised by CI (or maybe we remove some of those artifacts).

Also I see one potential negative side-effect from this change, which is checking out the repo and running tests will generate in the configuration files the hashes, thus modify them.

While the configuration in memory is mutated by adding hashes at runtime, I don't think the configuration is ever written back to the file(s) from which it was read. So, running tests should produce reports that include configurations with the hashes, but the original configuration files should remain unchanged.

Would it make sense that all files do have their hashes set in the configuration in the repository? And if we are to change them, well we just update the hashes at the same time. (and maybe also that is also checked by make format in order to check this easily before committing in the repo :) )

We could do this, but I was hoping to basically make hash tracking an optional feature -- for users who want to maintain explicit control of when external content changes, they could handle the inconvenience of keeping hashes up to date. But, for users who just want a record of what was actually run, adding the hashes at runtime seems fine. I think our dev configurations are in the latter camp, except it's probably useful to demonstrate that explicit hashes do work, which is why I specified one of the hashes explicitly.

@BenjaminPelletier
Copy link
Member Author

The following configurations have references to files but were not updated. Does this break them?

  • monitoring/uss_qualifier/configurations/dev/faa/uft/uft.yaml
  • monitoring/uss_qualifier/configurations/dev/non_docker/resources.yaml
  • monitoring/uss_qualifier/configurations/dev/faa/uft/local_message_signing.yaml
  • monitoring/uss_qualifier/configurations/dev/geoawareness_cis.yaml (unsure about this one)

Yes, this PR would currently break any of them with the affected file references. I will fix them before merging, but we should probably think about how to reliably maintain artifacts like this that aren't exercised by CI (or maybe we remove some of those artifacts).

These non-CI configurations should now be cleaned up:

uft.yaml -> Deleted; UFT activity is complete so this configuration is no longer worth actively maintaining
non_docker/resources.yaml -> Deleted and replaced with environment.yaml which should be substitutable for library/environment.yaml
local_message_signing.yaml -> Updated and verified to work
geoawareness_cis.yaml -> No changes needed; verified to work

@mickmis
Copy link
Contributor

mickmis commented Oct 18, 2023

but we should probably think about how to reliably maintain artifacts like this that aren't exercised by CI (or maybe we remove some of those artifacts)

Definitely! The ones not covered by the CI were broken pretty often unfortunately.

I don't think the configuration is ever written back to the file(s) from which it was read

Ah - that was not my understanding. OK then I withdraw my remark :)

We could do this, but I was hoping to basically make hash tracking an optional feature -- for users who want to maintain explicit control of when external content changes, they could handle the inconvenience of keeping hashes up to date. But, for users who just want a record of what was actually run, adding the hashes at runtime seems fine. I think our dev configurations are in the latter camp, except it's probably useful to demonstrate that explicit hashes do work, which is why I specified one of the hashes explicitly.

Yeah agreed: since I thought that the hashes would be written back to the config file, it would have made sense to have them all. But then not here.

@BenjaminPelletier BenjaminPelletier merged commit 2110d53 into interuss:main Oct 18, 2023
10 checks passed
@BenjaminPelletier BenjaminPelletier deleted the track-external-file-contents branch October 18, 2023 16:22
github-actions bot added a commit that referenced this pull request Oct 18, 2023
* Track external file contents

* Fix f3548_self_contained

* Convert function to method per comments

* Clean up non-CI configurations

* Update hash for changed file 2110d53
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.

2 participants