fakelinstor

package
v0.65.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package fakelinstor provides an in-memory HTTP test double for the LINSTOR REST API. It implements a subset of the API against which a client.Client can be pointed, so applications can exercise their LINSTOR interactions in tests without a running LINSTOR controller.

All state is kept in memory. The following client calls are supported:

  • Controller: GetVersion (reports a static fake version)
  • Nodes: Create, GetAll, Get, Delete, Evacuate, Restore, Lost
  • Node storage pools: GetStoragePools, GetStoragePool, CreateStoragePool, ModifyStoragePool, DeleteStoragePool
  • Node physical storage: CreateDevicePool
  • ResourceGroups: Create, GetAll
  • ResourceDefinitions: Create, GetAll (optionally with volume definitions), Delete, Truncate, CreateVolumeDefinition, GetVolumeDefinitions, ModifyVolumeDefinition
  • Resources: Create, Get, GetAll, GetResourceView

Any endpoint not listed above responds with 501 Not Implemented rather than 404, so an unimplemented call is not mistaken for a genuine github.com/LINBIT/golinstor/client.NotFoundError.

FakeLinstor additionally exposes the test-only helpers StoragePools and DevicePoolCreations for assertions, and SetConnectionStatus to simulate node connectivity changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeLinstor

type FakeLinstor struct {
	Server *httptest.Server
	// contains filtered or unexported fields
}

func New

func New() *FakeLinstor

func (*FakeLinstor) DevicePoolCreations

func (f *FakeLinstor) DevicePoolCreations() int

DevicePoolCreations returns how many times CreateDevicePool was called, for assertions in tests.

func (*FakeLinstor) SetConnectionStatus

func (f *FakeLinstor) SetConnectionStatus(name string, status string)

func (*FakeLinstor) StoragePools

func (f *FakeLinstor) StoragePools() []lapi.StoragePool

StoragePools returns a copy of the registered storage pools, for assertions in tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL