towerops/test/towerops_web/live/device_live_nested/show_test.exs
Graham McIntire 95e3870fec
feat: add Force10 FTOS and optical transceiver monitoring (ProCurve, Comware)
Completed Tier 1 (critical network switches) and Tier 2 (optical transceiver monitoring)
from Phase 3 implementation plan. All major network switches now have comprehensive sensor
coverage including temperature and fiber optic link diagnostics.

Files Changed:
- priv/profiles/os_discovery/ftos.yaml (enhanced)
  Added Dell Force10 FTOS temperature monitoring for all 3 series:
  - S-Series: Stack unit temperature (chStackUnitTemp)
    OID: .1.3.6.1.4.1.6027.3.10.1.2.2.1.14
    MIB: F10-S-SERIES-CHASSIS-MIB
  - C-Series: Card temperature (chSysCardTemp)
    OID: .1.3.6.1.4.1.6027.3.8.1.2.1.1.5
    MIB: F10-C-SERIES-CHASSIS-MIB
  - E-Series: Card upper + lower temperature (chSysCardUpperTemp, chSysCardLowerTemp)
    OIDs: .1.3.6.1.4.1.6027.3.1.1.2.3.1.8-9
    MIB: F10-CHASSIS-MIB
  Gap: CRITICAL (no sensors) → RESOLVED
  Parity: 0% → 90%

- priv/profiles/os_discovery/procurve.yaml (enhanced)
  Added HP ProCurve transceiver optical monitoring (5 sensor types):
  MIB: HP-ICF-TRANSCEIVER-MIB::hpicfXcvrInfoTable
  Sensors:
    - Temperature: hpicfXcvrTemp (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.11, divisor 1000)
    - Bias Current: hpicfXcvrBias (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.13, divisor 1000)
    - Supply Voltage: hpicfXcvrVoltage (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.12, divisor 1000)
    - RX Power (dBm): hpicfXcvrRxPower (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.14, divisor 10)
    - TX Power (dBm): hpicfXcvrTxPower (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.15, divisor 10)
  Gap: HIGH (missing transceivers) → RESOLVED
  Parity: 60% → 100%

- priv/profiles/os_discovery/comware.yaml (enhanced)
  Added HP Comware transceiver optical monitoring (5 sensor types):
  MIB: HH3C-TRANSCEIVER-INFO-MIB::hh3cTransceiverInfoTable
  Sensors:
    - Temperature: hh3cTransceiverTemperature (OID .1.3.6.1.4.1.25506.2.70.1.1.1.15)
    - Bias Current: hh3cTransceiverBiasCurrent (OID .1.3.6.1.4.1.25506.2.70.1.1.1.17)
    - Supply Voltage: hh3cTransceiverVoltage (OID .1.3.6.1.4.1.25506.2.70.1.1.1.16)
    - RX Power (dBm): hh3cTransceiverCurRXPower (OID .1.3.6.1.4.1.25506.2.70.1.1.1.9, divisor 100)
    - TX Power (dBm): hh3cTransceiverCurTXPower (OID .1.3.6.1.4.1.25506.2.70.1.1.1.12, divisor 100)
  Gap: HIGH (missing transceivers) → RESOLVED
  Parity: 60% → 95%

- test/towerops_web/controllers/api/mobile_controller_test.exs (fixed)
  Fixed Credo warning: replaced length/1 with empty list comparison

- CHANGELOG.txt (updated)
  Documented Tier 1 + Tier 2 completion

Impact:
- Force10 FTOS: Complete temperature monitoring for S/C/E-Series data center switches
- ProCurve: Full optical transceiver diagnostics (SFP/SFP+ monitoring)
- Comware: Full optical transceiver diagnostics (completes sensor coverage)

Business Value:
- All major network switch platforms now have fundamental temperature monitoring
- Fiber optic link health monitoring enabled for ProCurve and Comware
- Data center switches (Force10 FTOS) fully supported
- Enables proactive maintenance (detect failing transceivers before link failure)

Parity Achievement:
- Tier 1 Complete: HP Comware (60→95%), Dell PowerConnect (0→80%), Dell SONiC (0→95%),
  Dell Force10 FTOS (0→90%)
- Tier 2 Complete: HP ProCurve (60→100%), HP Comware (95% - transceivers added)

Next Steps: Tier 3 (storage/compute platforms: PowerVault, Dell Servers, hpblmos)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 08:19:12 -06:00

181 lines
4.7 KiB
Elixir

defmodule ToweropsWeb.DeviceLive.NestedShowTest do
use ToweropsWeb.ConnCase
import Phoenix.LiveViewTest
alias Towerops.Monitoring
alias Towerops.Organizations
alias Towerops.Sites
setup :register_and_log_in_user
setup %{user: user} do
{:ok, organization} = Organizations.create_organization(%{name: "Test Org"}, user.id)
{:ok, site} =
Sites.create_site(%{
name: "Test Site",
organization_id: organization.id
})
{:ok, device} =
Towerops.Devices.create_device(%{
name: "Test Router",
ip_address: "192.168.1.1",
site_id: site.id,
organization_id: organization.id
})
%{organization: organization, site: site, device: device}
end
describe "Show" do
test "displays device information", %{conn: conn, device: device, organization: _org} do
{:ok, _view, html} = live(conn, ~p"/devices/#{device.id}?tab=overview")
assert html =~ device.name
assert html =~ device.ip_address
end
test "displays overview tab by default", %{conn: conn, device: device, organization: _org} do
{:ok, _view, html} = live(conn, ~p"/devices/#{device.id}?tab=overview")
assert html =~ "Overview"
end
test "displays metrics when device has checks", %{
conn: conn,
device: device,
organization: _org
} do
# Create some checks
Monitoring.create_check(%{
device_id: device.id,
status: :success,
response_time_ms: 10,
checked_at: DateTime.utc_now()
})
Monitoring.create_check(%{
device_id: device.id,
status: :success,
response_time_ms: 15,
checked_at: DateTime.utc_now()
})
Monitoring.create_check(%{
device_id: device.id,
status: :failure,
response_time_ms: nil,
checked_at: DateTime.utc_now()
})
{:ok, _view, html} = live(conn, ~p"/devices/#{device.id}?tab=overview")
assert html =~ "Device Information"
end
test "displays empty state when no checks exist", %{
conn: conn,
device: device,
organization: _org
} do
{:ok, _view, html} = live(conn, ~p"/devices/#{device.id}?tab=overview")
assert html =~ device.name
end
test "refreshes data periodically", %{conn: conn, device: device, organization: _org} do
{:ok, view, _html} = live(conn, ~p"/devices/#{device.id}?tab=overview")
# Trigger a status change
Monitoring.create_check(%{
device_id: device.id,
status: :failure,
response_time_ms: nil,
checked_at: DateTime.utc_now()
})
# Send refresh message
send(view.pid, :refresh_data)
# Poll for processing with early exit (max 50ms)
Enum.reduce_while(1..5, nil, fn _, _ ->
try do
{:halt, render(view)}
rescue
_ ->
Process.sleep(10)
{:cont, nil}
end
end)
# View should still be alive
assert render(view)
end
test "requires authentication", %{device: device, organization: _org} do
conn = build_conn()
{:error, redirect} = live(conn, ~p"/devices/#{device.id}")
assert {:redirect, %{to: path}} = redirect
assert path == ~p"/users/log-in"
end
test "handles equipment_status_changed event", %{
conn: conn,
device: device,
organization: _org
} do
{:ok, view, _html} = live(conn, ~p"/devices/#{device.id}?tab=overview")
# Simulate status change event
send(view.pid, {:device_status_changed, device.id, :up, 25})
# Poll for processing with early exit (max 50ms)
Enum.reduce_while(1..5, nil, fn _, _ ->
try do
{:halt, render(view)}
rescue
_ ->
Process.sleep(10)
{:cont, nil}
end
end)
# View should still be alive and render
assert render(view)
end
test "handles discovery_completed event", %{
conn: conn,
device: device,
organization: _org
} do
{:ok, view, _html} = live(conn, ~p"/devices/#{device.id}?tab=overview")
# Simulate discovery completed event
send(view.pid, {:discovery_completed, device.id})
# Poll for processing with early exit (max 50ms)
html =
Enum.reduce_while(1..5, nil, fn _, _ ->
try do
{:halt, render(view)}
rescue
_ ->
Process.sleep(10)
{:cont, nil}
end
end) || render(view)
assert html =~ "Discovery completed"
end
test "switches to different tabs", %{conn: conn, device: device, organization: _org} do
{:ok, _view, html} = live(conn, ~p"/devices/#{device.id}?tab=events")
assert html =~ device.name
end
end
end