Add HostdeviceResource to HostResource in inventory#847
Add HostdeviceResource to HostResource in inventory#847
Conversation
| resources: []*computev1.HostdeviceResource{expHostdevice1, expHostdevice2}, | ||
| valid: true, | ||
| }, | ||
| "FilterDeviceName": { |
There was a problem hiding this comment.
This test case probably fails because the filter find two resources with the same name - createresreq1 and createresreq2 should have different devicename for this test case to pass.
There was a problem hiding this comment.
Updated the device name in the second resource.
| } | ||
| } | ||
|
|
||
| func Test_StrongRelations_On_Delete_HostDevice(t *testing.T) { |
There was a problem hiding this comment.
This test fails most likely, because the helper function CreateHostdevice() in inv_testing has cleanup function registered that makes sure that the resource gets deleted - thus it is already deleted when Host deletion is executed. You should try using this function to create Hostdevice CreateHostdeviceNoCleanup()
There was a problem hiding this comment.
The test needs to use the CreateHostdevice function with the cleanup as it is testing the relation between HostDevice and Host. The cleanup function it runs removes the Host after the test has completed, as per the documentation. So the HostDevice would not be deleted when the Host resource is deleted.
After some additional investigation, I have made a fix to the protobuf API to address this issue.
There was a problem hiding this comment.
@cjnolan was it fixed by changing one-to-one relationship to one-to-many for host-hostdevice?
| host := dao.CreateHost(t, tenantID) | ||
| return tenantID, len( | ||
| []any{ | ||
| dao.CreateHostDeviceNoCleanup(t, tenantID, host), |
There was a problem hiding this comment.
this test case tries to assign three Hostdevices to one host which is not allowed. https://github.com/open-edge-platform/infra-core/blob/host-resource-vpro-support/inventory/internal/ent/schema/hostdevice_resource.go#L20
| "HostNic": { | ||
| resID: hostNic.GetResourceId(), | ||
| }, | ||
| "HostDevice": { |
There was a problem hiding this comment.
This test case is probably failing because this function needs to be updated for eager loading with : WithHostdevice() in https://github.com/open-edge-platform/infra-core/blob/host-resource-vpro-support/inventory/internal/store/host.go#L180
There was a problem hiding this comment.
Yes, that was also needed as was a change to the filterHosts function as well in order to enable the eager loading, fixed.
Description
Adds a new HostdeviceResource to the HostResource object in inventory. This allows details to the current vPRO support status of an edge node to be stored for each host as part of the report from the edge node HW Discovery Agent
Fixes # (issue)
Any Newly Introduced Dependencies
Please describe any newly introduced 3rd party dependencies in this change. List their name, license information and how they are used in the project.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: