Device And Log Tests
OpenFrame Documentation
Get the most out of OpenFrame · Book 30 minutes with Conrad, 25 years in IT. He'll show you what Mingo and Fae can take off your list.
OpenFrame Documentation
Device And Log Tests is the end-to-end coverage slice for device inventory, device-scoped agent logs, tenant event logs, and duplicate-enrolment cleanup. Its four JUnit 5 classes are supplied by the com.openframe.oss:openframe-test-service-core library and executed by this repository's OpenFrame test service. The tests exercise the platform through test API facades rather than accessing storage directly, so they validate the observable device and logging contracts.
The implementation is maintained in OpenFrame OSS Library at the pinned library revision used by this repository.
| Test class | Primary contract | Test characteristics |
|---|---|---|
DevicesTest |
Device discovery, detail, tool connections, Fleet and MeshCentral facts, filtering, nickname updates, and dashboard-driven deletion | Mostly read-only SaaS feature tests, plus explicitly tagged destructive deletion coverage |
DeviceLogsTest |
Device Logs query defaults, filters, validation, cursor paging, and single-device scoping | Ordered SaaS tests under device-logs; the device-specific case additionally needs an enrolled Windows device |
LogsTest |
Tenant event-log filters, list/detail consistency, search, severity filtering, ordering, and inclusive time ranges | Read-only SaaS feature tests |
StaleDeviceCleanupTest |
Retirement of non-online duplicate enrolments for the machine configured for the current run | OSS cleanup test, intentionally narrow and state-changing |
The module is an acceptance-level boundary: test classes invoke DeviceApi, DeviceLogApi, and LogsApi; those facades issue platform requests and deserialize responses into test DTOs. Assertions then verify filtering, projection, lifecycle, and error semantics visible to a consumer.
flowchart LR
TestRunner["JUnit test runner"] --> DeviceTests["DevicesTest"]
TestRunner --> DeviceLogTests["DeviceLogsTest"]
TestRunner --> LogTests["LogsTest"]
TestRunner --> CleanupTest["StaleDeviceCleanupTest"]
DeviceTests --> DeviceApi["DeviceApi"]
DeviceLogTests --> DeviceLogApi["DeviceLogApi"]
LogTests --> LogsApi["LogsApi"]
CleanupTest --> DeviceApi
DeviceApi --> Platform["OpenFrame platform APIs"]
DeviceLogApi --> Platform
LogsApi --> Platform
Platform --> DeviceData["Device inventory and integrations"]
Platform --> LogData["Device and event log data"]
DevicesTest establishes the baseline device-management contract.
purpose:auto_test tag. The tag test validates the tag on every returned device, not merely that an expected hostname is included.finally block.The dashboard deletion case deliberately uses an enrolled device selected from the pipeline's organization when that context is available. It forces client uninstall, accepts the immediate transitional PENDING_DELETION or terminal DELETED state, polls until deletion completes, then confirms the machine ID is absent from normal listed-device results.
sequenceDiagram
participant Test as "DevicesTest"
participant API as "DeviceApi"
participant Client as "Enrolled client"
participant Platform as "Platform"
Test->>API: Select pipeline-scoped online or offline device
API->>Platform: Read device
Test->>API: Force client uninstall
API->>Platform: Request uninstall
Platform->>Client: Deliver uninstall request
Client->>Platform: Uninstall and deregister
Test->>API: Poll device state
API->>Platform: Read device
Platform->>API: DELETED or absent
Test->>API: Verify device is not listed
This case is tagged archive rather than read; it must run only where its pipeline-scoped fixture and side effects are intended.
DeviceLogsTest uses ordered cases because the first case pins a nonempty tenant time window and subsequent cases reuse it. It checks a dedicated device-log query, distinct from the general event-log query tested by LogsTest.
DEBUG, INFO, WARN, or ERROR), non-null messages, and nonblank edge cursors. Page start and end cursors must match the first and last edge.contains and excludes are case-insensitive and literal: the test specifically proves that .* is not evaluated as a regular expression.The module treats invalid input as an observable API contract. It expects a VALIDATION_ERROR for a range longer than 30 days, inverted time bounds, an empty device list, more than 50 device IDs, too many search terms, an oversized exclusion term, and an invalid cursor. An unknown device must instead produce DEVICE_NOT_FOUND.
The single-device case finds a named enrolled Windows fixture, verifies device-only results and hostname attribution, expands to an explicit 30-day window, and confirms compatibility of the deprecated single-machine argument.
flowchart TD
Request["Device log query"] --> Scope{"Machine IDs supplied?"}
Scope -->|"No"| TenantWindow["Default 24-hour tenant window"]
Scope -->|"Yes"| DeviceWindow["Default 7-day device window"]
TenantWindow --> Validate["Validate range filters and cursor"]
DeviceWindow --> Validate
Validate --> Valid{"Arguments valid?"}
Valid -->|"No"| Error["Validation or device-not-found error"]
Valid -->|"Yes"| Query["Query logs newest first"]
Query --> Page["Return nodes, edges, and page info"]
LogsTest validates the tenant-wide event-log surface through LogsApi.
StaleDeviceCleanupTest removes ambiguity caused when repeated pipeline enrolments create multiple device rows with the same hostname. It is intentionally conservative:
ONLINE; every live enrolment remains untouched.flowchart TD
Start["Read configured target hostname"] --> HostConfigured{"Hostname configured?"}
HostConfigured -->|"No"| Skip["Skip cleanup"]
HostConfigured -->|"Yes"| List["List devices in visible states"]
List --> Match["Keep rows with matching hostname"]
Match --> Stale["Select non-online rows"]
Stale --> Retire["Set each stale row to DELETED"]
Retire --> Reload["Reload matching rows"]
Reload --> Assert["Assert every remaining row is ONLINE"]
The tests run against the tenant deployment rather than mocking the services that own device and log behavior. Device interactions traverse the client-facing API surface and depend on enrolled client data, including Fleet MDM and MeshCentral integrations. Log interactions validate the API-visible records produced by device logging and platform event ingestion.
In this repository, the relevant deployment exposes OpenFrame API traffic through the gateway's /api/** route. The library source above supplies the test implementation; this repository packages and operates the service environment in which it executes.
DeviceLogsTest; later cases are intentionally conditional on data found by the first case.