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

mock-insights: various changes/improvements #72

Merged
merged 3 commits into from
Aug 5, 2024

Conversation

ptoscano
Copy link
Collaborator

@ptoscano ptoscano commented Aug 5, 2024

Improve a bit the mock-insights fake service to improve certain bits, and implement new APIs. In particular:

  • fix the handling of the helper systems dictionary to index by the own Inventory ID (i.e. the current hardcoded one)
  • implement more endpoints needed to support the non-legacy-upload mode of insights-client

See the messages of each commit for longer explanations.

Tweak their implementations a bit to prepare them for more substantial
changes; in particular:
- properly name the ID we get: the "insights_id" query parameter as
  such, and the UUID as Inventory ID
- use an helper variable to which add/set all the bits to the replies,
  dumping them as JSON only in one place

This is only a refactor with no behaviour change.
Currently, the fake systems (or better, only one) is kept in the helper
"systems" dictionary by the machine ID; while this seems to work fine,
in practice it will not work for upcoming changes, and it does not match
what Inventory actually does.

Change the ID handling to represent better what Inventory does:
- assign "id" as Inventory ID for each newly registered system; in
  practice we have only one, and keep hardcoding "123-nice-id" for now
  (the "testInsights" test checks for it)
- use the "id" as key in the "systems" dictionary, rather than the
  "machine_id"
- when registering a new system, copy "machine_id" as "insights_id";
  this will help later on when implementing the non-legacy API endpoints
- adapt endpoints to search for the ID they need

Even with all the changes, there should be no behaviour changes.
Implement a couple of missing platform endpoints needed to make
insights-client work in non-legacy-upload mode:
- the upload endpoint, which needs to get the system metadata from the
  MIME data sent with POST: because of this, the implementation needs a
  bit more work; because of testing reasons, the Inventory ID is still
  hardcoded as "123-nice-id"
- the delete endpoint, needed to unregister a system
Copy link
Contributor

@jirihnidek jirihnidek left a comment

Choose a reason for hiding this comment

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

LGTM

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