Tests for self service vpp apps & weird installed vpp app edge case#28372
Tests for self service vpp apps & weird installed vpp app edge case#28372
Conversation
When a vpp app is marked as self service, it should be returned and the data about it should be hydrated. When writing tests for this, another bug was found around vpp apps that were installed and present in host software. These apps need to be retrieved and the data about them needs to be merged onto the host `hostInstalledSoftware` record.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #28372 +/- ##
==========================================
+ Coverage 63.98% 63.99% +0.01%
==========================================
Files 1785 1785
Lines 171339 171546 +207
Branches 4945 4945
==========================================
+ Hits 109629 109788 +159
- Misses 53061 53099 +38
- Partials 8649 8659 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| func hostInstalledVpps(ds *Datastore, ctx context.Context, hostID uint) ([]*hostSoftware, error) { | ||
| vppInstalledStmt := ` |
There was a problem hiding this comment.
We're mising label scoping here :(
If the VPP app got installed and later got dropped out of label scope, it should show up as in inventory and neither as installed nor as available for install.
This will continue being an issue when we revise host install scoping, though at that point self-service will be filtered by labels rather than overall availability for install.
There was a problem hiding this comment.
Should I cover the scoping as part of #28328 in a new PR?
Or would you prefer if I do it in this PR for vpp installs and then cover the rest of the cases missed in the new PR?
There was a problem hiding this comment.
Can handle scoping in a new PR. I'll give this one a thumbs-up momentarily for merge with the knowledge that we have a separate bug tracked for that work.
| INSERT INTO software (name, version, source, bundle_identifier, title_id, checksum) | ||
| VALUES (?, ?, ?, ?, ?, ?) | ||
| `, | ||
| vPPApp2.Name, vPPApp2.LatestVersion, "apps", vPPApp2.BundleIdentifier, vPPApp2.TitleID, hex.EncodeToString([]byte("vpp2")), |
There was a problem hiding this comment.
Should pick a different value than latestVersion here for version, as we want to make sure in assertions that inventory shows the inventoried version rather than the VPP app latest version.
| if softwareTitleRecord.SoftwareIDList == nil { | ||
| softwareTitleRecord.SoftwareIDList = ptr.String("") | ||
| softwareTitleRecord.SoftwareSourceList = ptr.String("") | ||
| softwareTitleRecord.VersionList = ptr.String("") | ||
| softwareTitleRecord.BundleIdentifierList = ptr.String("") | ||
| seperator = "" | ||
| } | ||
|
|
||
| if !strings.Contains(*softwareTitleRecord.SoftwareIDList, softwareIDStr) { | ||
| *softwareTitleRecord.SoftwareIDList += seperator + softwareIDStr | ||
| *softwareTitleRecord.SoftwareSourceList += seperator + s.Source | ||
| *softwareTitleRecord.VersionList += seperator + *s.Version | ||
| *softwareTitleRecord.BundleIdentifierList += seperator + *s.BundleIdentifier | ||
| } |
There was a problem hiding this comment.
This makes me a bit nervous that we're intentionally passing around concatenated lists of strings rather than a proper slice structure, but guessing this was the least diruptive way to add the lists we need, and the lists added above are used not only in L3746-3749 but appended to/defined elsewhere, so we have to stick with this format to avoid a bigger refactor?
There was a problem hiding this comment.
Fixed this! Great callout. Thank you.
iansltx
left a comment
There was a problem hiding this comment.
Approving with the assumption that the code I commented on is as good as we can get for now., and given that labels work is coming in its own PR. Will re-review if anything changes here on either of those, but expecting this'll get merged instead.
iansltx
left a comment
There was a problem hiding this comment.
Thanks for fixing the contains issue.
…28372) #28345 When a vpp app is marked as self service, it should be returned and the data about it should be hydrated. When writing tests for this, another bug was found around vpp apps that were installed and present in host software. These apps need to be retrieved and the data about them needs to be merged onto the host `hostInstalledSoftware` record. - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated automated tests - [x] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it) - [x] Manual QA for all new/changed functionality - [x] For unreleased bug fixes in a release candidate, confirmed that the fix is not expected to adversely impact load test results or alerted the release DRI if additional load testing is needed.
#28328 Also related to #28372 - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated automated tests - [x] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it) - [x] Manual QA for all new/changed functionality - [x] For unreleased bug fixes in a release candidate, confirmed that the fix is not expected to adversely impact load test results or alerted the release DRI if additional load testing is needed.
#28328 Also related to #28372 - [x] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) - [x] Added/updated automated tests - [x] A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it) - [x] Manual QA for all new/changed functionality - [x] For unreleased bug fixes in a release candidate, confirmed that the fix is not expected to adversely impact load test results or alerted the release DRI if additional load testing is needed.
#28345
When a vpp app is marked as self service, it should be returned and the data about it should be hydrated.
When writing tests for this, another bug was found around vpp apps that were installed and present in host software. These apps need to be retrieved and the data about them needs to be merged onto the host
hostInstalledSoftwarerecord.SELECT *is avoided, SQL injection is prevented (using placeholders for values in statements)