Skip to content

Commit

Permalink
chore(RHINENG-9787): Add tests for bootc image table
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Johnson authored and johnsonm325 committed May 10, 2024
1 parent 9f73281 commit 97749de
Show file tree
Hide file tree
Showing 7 changed files with 531 additions and 1 deletion.
39 changes: 39 additions & 0 deletions src/__mocks__/mockedBootCImageData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[
{
"image": "India Pale Ale",
"hashCommitCount": 2,
"systemCount": 3,
"hashes": [
{
"image_digest": "Hazy",
"hashSystemCount": 2
},
{
"image_digest": "West Coast",
"hashSystemCount": 1
}
]
},
{
"image": "Belgian",
"hashCommitCount": 1,
"systemCount": 1,
"hashes": [
{
"image_digest": "Dubbel",
"hashSystemCount": 1
}
]
},
{
"image": "Stout",
"hashCommitCount": 1,
"systemCount": 1,
"hashes": [
{
"image_digest": "Bourbon Barrell Aged",
"hashSystemCount": 1
}
]
}
]
288 changes: 288 additions & 0 deletions src/__mocks__/mockedBootCStatusData.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
{
"total": 5,
"count": 5,
"page": 1,
"per_page": 50,
"results": [
{
"id": "6de30d78-f052-41d4-b123-125017443a98",
"system_profile": {
"arch": "x86_64",
"cpu_flags": [ "fpu" ],
"yum_repos": [
{
"name": "Extra Packages for Enterprise Linux 7 - Testing - $basearch",
"enabled": false,
"gpgcheck": true
}
],
"os_release": "7.4",
"bios_vendor": "SeaBIOS",
"bios_version": "1.10.2-2.fc27",
"kernel_modules": [ "veth" ],
"last_boot_time": "2018-03-14T17:06:10",
"number_of_cpus": 1,
"cores_per_socket": 1,
"enabled_services": [ "auditd" ],
"bios_release_date": "04\/01\/2014",
"number_of_sockets": 1,
"os_kernel_version": "3.10.0",
"running_processes": [ "qmgr" ],
"satellite_managed": false,
"installed_packages": [ "0:GeoIP-1.5.0-11.el7" ],
"installed_services": [ "arp-ethers" ],
"network_interfaces": [
{
"mtu": 65536,
"name": "lo",
"type": "loopback",
"state": "UNKNOWN",
"mac_address": "00:00:00:00:00:00",
"ipv4_addresses": [
"127.0.0.1"
],
"ipv6_addresses": [
"::1"
]
}
],
"infrastructure_type": "virtual",
"system_memory_bytes": 512073728,
"infrastructure_vendor": "qemu",
"system_purpose": {
"usage": "Production"
},
"bootc_status": {
"booted": {
"image": "India Pale Ale",
"image_digest": "Hazy"
}
}
}
},
{
"id": "08a06e04-afbb-4e3c-b923-91aa1c17acc1",
"system_profile": {
"arch": "x86_64",
"cpu_flags": [ "fpu" ],
"yum_repos": [
{
"name": "Extra Packages for Enterprise Linux 7 - Testing - $basearch",
"enabled": false,
"gpgcheck": true
}
],
"os_release": "8.4",
"bios_vendor": "SeaBIOS",
"bios_version": "1.10.2-2.fc27",
"kernel_modules": [ "veth" ],
"last_boot_time": "2018-03-14T17:06:10",
"number_of_cpus": 1,
"cores_per_socket": 1,
"enabled_services": [ "auditd" ],
"bios_release_date": "04\/01\/2014",
"number_of_sockets": 1,
"os_kernel_version": "3.10.0",
"running_processes": [ "qmgr" ],
"satellite_managed": false,
"installed_packages": [ "0:GeoIP-1.5.0-11.el7" ],
"installed_services": [ "arp-ethers" ],
"network_interfaces": [
{
"mtu": 65536,
"name": "lo",
"type": "loopback",
"state": "UNKNOWN",
"mac_address": "00:00:00:00:00:00",
"ipv4_addresses": [
"127.0.0.1"
],
"ipv6_addresses": [
"::1"
]
}
],
"infrastructure_type": "virtual",
"system_memory_bytes": 512073728,
"infrastructure_vendor": "qemu",
"system_purpose": {
"usage": "Production"
},
"bootc_status": {
"booted": {
"image": "India Pale Ale",
"image_digest": "Hazy"
}
}
}
},
{
"id": "4ef68d04-79fa-42ea-a0fe-b40ee257ff0e",
"system_profile": {
"arch": "x86_64",
"cpu_flags": [ "fpu" ],
"yum_repos": [
{
"name": "Extra Packages for Enterprise Linux 7 - Testing - $basearch",
"enabled": false,
"gpgcheck": true
}
],
"os_release": "8.5",
"bios_vendor": "SeaBIOS",
"bios_version": "1.10.2-2.fc27",
"kernel_modules": [ "veth" ],
"last_boot_time": "2018-03-14T17:06:10",
"number_of_cpus": 1,
"cores_per_socket": 1,
"enabled_services": [ "auditd" ],
"bios_release_date": "04\/01\/2014",
"number_of_sockets": 1,
"os_kernel_version": "3.10.0",
"running_processes": [ "qmgr" ],
"satellite_managed": false,
"installed_packages": [ "0:GeoIP-1.5.0-11.el7" ],
"installed_services": [ "arp-ethers" ],
"network_interfaces": [
{
"mtu": 65536,
"name": "lo",
"type": "loopback",
"state": "UNKNOWN",
"mac_address": "00:00:00:00:00:00",
"ipv4_addresses": [
"127.0.0.1"
],
"ipv6_addresses": [
"::1"
]
}
],
"infrastructure_type": "virtual",
"system_memory_bytes": 512073728,
"infrastructure_vendor": "qemu",
"system_purpose": {
"usage": "Production"
},
"bootc_status": {
"booted": {
"image": "India Pale Ale",
"image_digest": "West Coast"
}
}
}
},
{
"id": "b6197999-06f8-4301-a936-651832aa8b31",
"system_profile": {
"arch": "x86_64",
"cpu_flags": [ "fpu" ],
"yum_repos": [
{
"name": "Extra Packages for Enterprise Linux 7 - Testing - $basearch",
"enabled": false,
"gpgcheck": true
}
],
"os_release": "8.5",
"bios_vendor": "SeaBIOS",
"bios_version": "1.10.2-2.fc27",
"kernel_modules": [ "veth" ],
"last_boot_time": "2018-03-14T17:06:10",
"number_of_cpus": 1,
"cores_per_socket": 1,
"enabled_services": [ "auditd" ],
"bios_release_date": "04\/01\/2014",
"number_of_sockets": 1,
"os_kernel_version": "3.10.0",
"running_processes": [ "qmgr" ],
"satellite_managed": false,
"installed_packages": [ "0:GeoIP-1.5.0-11.el7" ],
"installed_services": [ "arp-ethers" ],
"network_interfaces": [
{
"mtu": 65536,
"name": "lo",
"type": "loopback",
"state": "UNKNOWN",
"mac_address": "00:00:00:00:00:00",
"ipv4_addresses": [
"127.0.0.1"
],
"ipv6_addresses": [
"::1"
]
}
],
"infrastructure_type": "virtual",
"system_memory_bytes": 512073728,
"infrastructure_vendor": "qemu",
"system_purpose": {
"usage": "Production"
},
"bootc_status": {
"booted": {
"image": "Belgian",
"image_digest": "Dubbel"
}
}
}
},
{
"id": "8499b198-5352-4eda-8650-ca09e002fdc1",
"system_profile": {
"arch": "x86_64",
"cpu_flags": [ "fpu" ],
"yum_repos": [
{
"name": "Extra Packages for Enterprise Linux 7 - Testing - $basearch",
"enabled": false,
"gpgcheck": true
}
],
"os_release": "8.2",
"bios_vendor": "SeaBIOS",
"bios_version": "1.10.2-2.fc27",
"kernel_modules": [ "veth" ],
"last_boot_time": "2018-03-14T17:06:10",
"number_of_cpus": 1,
"cores_per_socket": 1,
"enabled_services": [ "auditd" ],
"bios_release_date": "04\/01\/2014",
"number_of_sockets": 1,
"os_kernel_version": "3.10.0",
"running_processes": [ "qmgr" ],
"satellite_managed": false,
"installed_packages": [ "0:GeoIP-1.5.0-11.el7" ],
"installed_services": [ "arp-ethers" ],
"network_interfaces": [
{
"mtu": 65536,
"name": "lo",
"type": "loopback",
"state": "UNKNOWN",
"mac_address": "00:00:00:00:00:00",
"ipv4_addresses": [
"127.0.0.1"
],
"ipv6_addresses": [
"::1"
]
}
],
"infrastructure_type": "virtual",
"system_memory_bytes": 512073728,
"infrastructure_vendor": "qemu",
"system_purpose": {
"usage": "Production"
},
"bootc_status": {
"booted": {
"image": "Stout",
"image_digest": "Bourbon Barrell Aged"
}
}
}
}
]
}
35 changes: 35 additions & 0 deletions src/routes/InventoryComponents/BifrostPage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { render, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
import axios from 'axios';
import BifrostPage from './BifrostPage';
import mockedBootCStatusData from '../../__mocks__/mockedBootCStatusData.json';
import {
INVENTORY_TOTAL_FETCH_URL_SERVER,
INVENTORY_FETCH_BOOTC,
INVENTORY_FETCH_NON_BOOTC,
INVENTORY_FILTER_NO_HOST_TYPE,
} from '../../Utilities/constants';

jest.mock('axios');

describe('BifrostPage', () => {
beforeEach(() => {
axios.get.mockResolvedValue({
data: mockedBootCStatusData,
});
});

test('should fetch bootc_status', async () => {
render(<BifrostPage />);
await waitFor(() =>
expect(axios.get).toHaveBeenCalledWith(
`${INVENTORY_TOTAL_FETCH_URL_SERVER}${INVENTORY_FETCH_BOOTC}&fields[system_profile]=bootc_status`
)
);

expect(axios.get).toHaveBeenCalledWith(
`${INVENTORY_TOTAL_FETCH_URL_SERVER}${INVENTORY_FETCH_NON_BOOTC}&${INVENTORY_FILTER_NO_HOST_TYPE}&per_page=1`
);
});
});
Loading

0 comments on commit 97749de

Please sign in to comment.