testutil

package
v0.0.0-...-53c686c Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

Ciao Testutil

A given ciao component will have unit tests which cover its internals in a component specific way. But this is limited in scope and cannot cover all of the component's functionality, because that functionality is ultimately about creating and servicing SSNTP command/event/error/status flows.

To enable testing of those SSNTP flows, the testutil package provides a set of common test tools for ciao. Included are:

  • shared payload constants
  • shared test certificates
  • test agent implementation for ssntp.AGENT and ssntp.NETAGENT roles
  • test controller implementation for ssntp.Controller role
  • test server implementation for ssntp.SERVER role
  • example client-server test spanning the above SSNTP actors
  • channels for tracking command/event/error/status flows across the SSNTP test actors

This allows a ciao component to be tested more meaninfully, but in partial isolation. The ciao component under test would be a real implementation, but its SSNTP peers are the shared synthetic implementations from the testutil package.

For an example of how to enable basic SSNTP test flows and track the results through the channel helpers review the internals of the example client-server test.

Additional test options

Virtual

The next level of test breadth comes from actually running a test cluster with real implementations of each ciao component. This is provided in a controlled fashion via the singlevm CI script, which has detailed documentation on the wiki at Single VM Development Environment.

Physical

Testing is of course also possible on a real hardware cluster which has been set up according to the cluster setup guide. A minimal Build Acceptance Test (BAT) framework outputting TAP (Test Anything Protocol) results is published in our release tools. The python script drives ciao-cli to query and manipulate the state of a cluster.

Documentation

Index

Constants

View Source
const AgentIP = "10.2.3.4"

AgentIP is a test agent IP address

View Source
const AgentUUID = "4cb19522-1e18-439a-883a-f9b2a3a95f5e"

AgentUUID is a node UUID for coordinated stop/restart/delete tests

View Source
const AssignIPYaml = `assign_public_ip:
  concentrator_uuid: ` + CNCIUUID + `
  tenant_uuid: ` + TenantUUID + `
  instance_uuid: ` + InstanceUUID + `
  public_ip: ` + InstancePublicIP + `
  private_ip: ` + InstancePrivateIP + `
  vnic_mac: ` + VNICMAC + `
`

AssignIPYaml is a sample AssignPublicIP ssntp.Command payload for test cases

View Source
const AssignedIPYaml = `public_ip_assigned:
  concentrator_uuid: ` + CNCIUUID + `
  instance_uuid: ` + InstanceUUID + `
  public_ip: ` + InstancePublicIP + `
  private_ip: ` + InstancePrivateIP + `
`

AssignedIPYaml is a sample PublicIPAssigned ssntp.Event payload for test cases

View Source
const AttachVolumeFailureYaml = `instance_uuid: ` + InstanceUUID + `
volume_uuid: ` + VolumeUUID + `
reason: attach_failure
`

AttachVolumeFailureYaml is a sample AttachVolumeFailure ssntp.Error payload for test cases

View Source
const AttachVolumeYaml = `attach_volume:
  instance_uuid: ` + InstanceUUID + `
  volume_uuid: ` + VolumeUUID + `
  workload_agent_uuid: ` + AgentUUID + `
`

AttachVolumeYaml is a sample yaml payload for the ssntp Attach Volume command.

View Source
const BadAttachVolumeYaml = `attach_volume:
  volume_uuid: ` + VolumeUUID + `
`

BadAttachVolumeYaml is a corrupt yaml payload for the ssntp Attach Volume command.

View Source
const BadDetachVolumeYaml = `detach_volume:
  instance_uuid: ` + InstanceUUID + `
`

BadDetachVolumeYaml is a corrupt yaml payload for the ssntp Detach Volume command.

View Source
const CNCIAddedYaml = `concentrator_instance_added:
  instance_uuid: ` + CNCIUUID + `
  tenant_uuid: ` + TenantUUID + `
  concentrator_ip: ` + CNCIIP + `
  concentrator_mac: ` + CNCIMAC + `
`

CNCIAddedYaml is a sample ConcentratorInstanceAdded ssntp.Event payload for test cases

View Source
const CNCIIP = "10.1.2.3"

CNCIIP is a test CNCI instance IP address

View Source
const CNCIInstanceData = `scheduler_addr: 192.168.42.5
`

CNCIInstanceData is a sample CNCIInstanceConfig payload for test cases

View Source
const CNCIInstanceUUID = "c6beb8b5-0bfc-43fd-9638-7dd788179fd8"

CNCIInstanceUUID is a CNCI instance UUID for use in start/stop/restart/delete tests

View Source
const CNCIMAC = "CA:FE:C0:00:01:02"

CNCIMAC is a test CNCI instance MAC address

View Source
const CNCIStartYaml = `start:
  instance_uuid: ` + CNCIInstanceUUID + `
  image_uuid: ` + ImageUUID + `
  fw_type: efi
  persistence: host
  vm_type: qemu
  requested_resources:
    - type: vcpus
      value: 4
      mandatory: true
    - type: mem_mb
      value: 4096
      mandatory: true
    - type: network_node
      value: 1
      mandatory: true
  networking:
    vnic_mac: ` + VNICMAC + `
    vnic_uuid: ` + VNICUUID + `
    concentrator_uuid: ` + CNCIUUID + `
    concentrator_ip: ` + CNCIIP + `
    subnet: ` + TenantSubnet + `
    subnet_key: ` + SubnetKey + `
    subnet_uuid: ""
    private_ip: ""
    public_ip: false
`

CNCIStartYaml is a sample CNCI workload START ssntp.Command payload for test cases

View Source
const CNCIUUID = "7e84c2d6-5a84-4f9b-98e3-38980f722d1b"

CNCIUUID is a test CNCI instance UUID

View Source
const ComputeAPIPort = "8774"

ComputeAPIPort is the compute service port the testutil identity service will use by default

View Source
const ComputeNet = "192.168.1.110"

ComputeNet is a test compute network

View Source
const ComputePort = "443"

ComputePort is a test port for the compute service

View Source
const ConfigureYaml = `configure:
  scheduler:
    storage_uri: ` + StorageURI + `
  storage:
    secret_path: ` + KeyPath + `
    ceph_id: ` + ManagementID + `
  controller:
    compute_port: ` + ComputePort + `
    compute_ca: ` + HTTPSCACert + `
    compute_cert: ` + HTTPSKey + `
    identity_user: ` + IdentityUser + `
    identity_password: ` + IdentityPassword + `
  launcher:
    compute_net:
    - ` + ComputeNet + `
    mgmt_net:
    - ` + MgmtNet + `
    disk_limit: false
    mem_limit: false
  image_service:
    type: glance
    url: ` + GlanceURL + `
  identity_service:
    type: keystone
    url: ` + KeystoneURL + `
`

ConfigureYaml is a sample CONFIGURE ssntp.Command payload for test cases

View Source
const DeleteFailureYaml = `instance_uuid: ` + InstanceUUID + `
reason: no_instance
`

DeleteFailureYaml is a sample workload DeleteFailure ssntp.Error payload for test cases

View Source
const DeleteYaml = `delete:
  instance_uuid: ` + InstanceUUID + `
  workload_agent_uuid: ` + AgentUUID + `
`

DeleteYaml is a sample workload DELETE ssntp.Command payload for test cases

View Source
const DetachVolumeFailureYaml = `instance_uuid: ` + InstanceUUID + `
volume_uuid: ` + VolumeUUID + `
reason: detach_failure
`

DetachVolumeFailureYaml is a sample DetachVolumeFailure ssntp.Error payload for test cases

View Source
const DetachVolumeYaml = `detach_volume:
  instance_uuid: ` + InstanceUUID + `
  volume_uuid: ` + VolumeUUID + `
  workload_agent_uuid: ` + AgentUUID + `
`

DetachVolumeYaml is a sample yaml payload for the ssntp Detach Volume command.

View Source
const DockerImage = "docker/latest"

DockerImage is a docker image name for use in start/restart tests

View Source
const EvacuateYaml = `evacuate:
  workload_agent_uuid: ` + AgentUUID + `
`

EvacuateYaml is a sample node EVACUATE ssntp.Command payload for test cases

View Source
const GlanceURL = "http://glance.example.com"

GlanceURL is a test Glance image server url

View Source
const HTTPSCACert = "/etc/pki/ciao/compute_ca.pem"

HTTPSCACert is a path to the CA cert used to sign the HTTPSKey

View Source
const HTTPSKey = "/etc/pki/ciao/compute_key.pem"

HTTPSKey is a path to a key for the compute service

View Source
const IdentityPassword = "ciao"

IdentityPassword is a test password for the test identity server

View Source
const IdentityUser = "controller"

IdentityUser is a test user for the test identity server

View Source
const ImageUUID = "59460b8a-5f53-4e3e-b5ce-b71fed8c7e64"

ImageUUID is a disk image UUID for use in start/restart tests

View Source
const InsDelYaml = `instance_deleted:
  instance_uuid: ` + InstanceUUID + `
`

InsDelYaml is a sample workload InstanceDeleted ssntp.Event payload for test cases

View Source
const InstancePrivateIP = "192.168.1.2"

InstancePrivateIP is a test instance private IP

View Source
const InstancePublicIP = "10.1.2.3"

InstancePublicIP is a test instance public IP

View Source
const InstanceUUID = "3390740c-dce9-48d6-b83a-a717417072ce"

InstanceUUID is an instance UUID for use in start/stop/restart/delete tests

View Source
const KeyPath = "/etc/ceph/ceph.client.ciao.keyring"

KeyPath is a test path to a keyring

View Source
const KeystoneURL = "http://keystone.example.com"

KeystoneURL is a test Keystone identity server url

View Source
const ManagementID = "ciao"

ManagementID is a test identifier for a Ceph ID

View Source
const MgmtNet = "192.168.1.111"

MgmtNet is a test management network

View Source
const NetAgentUUID = "6be56328-92e2-4ecd-b426-8fe529c04e0c"

NetAgentUUID is a network node UUID for coordinated tests

View Source
const NodeConnectedYaml = `node_connected:
  node_uuid: ` + AgentUUID + `
  node_type: ` + payloads.NetworkNode + `
`

NodeConnectedYaml is a sample node NodeConnected ssntp.Event payload for test cases

View Source
const NodeOnlyStatsYaml = `node_uuid: ` + AgentUUID + `
mem_total_mb: 3896
mem_available_mb: 3896
disk_total_mb: 500000
disk_available_mb: 256000
load: 0
cpus_online: 4
hostname: test
networks:
- ip: 192.168.1.1
  mac: 02:00:15:03:6f:49
`

NodeOnlyStatsYaml is a sample minimal node STATS ssntp.Command payload for test cases with no per-instance statistics

View Source
const PartialReadyYaml = `node_uuid: ` + AgentUUID + `
load: 1
`

PartialReadyYaml is a sample minimal node READY ssntp.Status payload for test cases

View Source
const PartialRestartYaml = `restart:
  instance_uuid: ` + InstanceUUID + `
  workload_agent_uuid: ` + AgentUUID + `
  fw_type: efi
  persistence: host
  requested_resources:
    - type: vcpus
      value: 2
      mandatory: true
`

PartialRestartYaml is a sample minimal workload RESTART ssntp.Command payload for test cases

View Source
const PartialStartYaml = `start:
  instance_uuid: ` + InstanceUUID + `
  image_uuid: ` + ImageUUID + `
  docker_image: ` + DockerImage + `
  fw_type: efi
  persistence: host
  vm_type: qemu
  requested_resources:
    - type: vcpus
      value: 2
      mandatory: true
`

PartialStartYaml is a sample minimal workload START ssntp.Command payload for test cases

View Source
const PartialStatsYaml = `node_uuid: ` + AgentUUID + `
load: 1
`

PartialStatsYaml is a sample minimal node STATS ssntp.Command payload for test cases with limited node statistics and no per-instance statistics

View Source
const ReadyYaml = `node_uuid: ` + AgentUUID + `
mem_total_mb: 3896
mem_available_mb: 3896
disk_total_mb: 500000
disk_available_mb: 256000
load: 0
cpus_online: 4
`

ReadyYaml is a sample node READY ssntp.Status payload for test cases

View Source
const ReleaseIPYaml = `release_public_ip:
  concentrator_uuid: ` + CNCIUUID + `
  tenant_uuid: ` + TenantUUID + `
  instance_uuid: ` + InstanceUUID + `
  public_ip: ` + InstancePublicIP + `
  private_ip: ` + InstancePrivateIP + `
  vnic_mac: ` + VNICMAC + `
`

ReleaseIPYaml is a sample ReleasePublicIP ssntp.Command payload for test cases

View Source
const RestartFailureYaml = `instance_uuid: ` + InstanceUUID + `
reason: already_running
`

RestartFailureYaml is a sample workload RestartFailure ssntp.Error payload for test cases

View Source
const RestartYaml = `restart:
  tenant_uuid: ` + TenantUUID + `
  instance_uuid: ` + InstanceUUID + `
  image_uuid: ` + ImageUUID + `
  workload_agent_uuid: ` + AgentUUID + `
  fw_type: efi
  persistence: host
  requested_resources:
  - type: vcpus
    value: 2
    mandatory: true
  - type: mem_mb
    value: 4096
    mandatory: true
  - type: disk_mb
    value: 10000
    mandatory: true
  estimated_resources:
  - type: vcpus
    value: 1
  - type: mem_mb
    value: 128
  - type: disk_mb
    value: 4096
  networking:
    vnic_mac: ""
    vnic_uuid: ""
    concentrator_uuid: ""
    concentrator_ip: ""
    subnet: ""
    subnet_key: ""
    subnet_uuid: ""
    private_ip: ""
    public_ip: false
`

RestartYaml is a sample workload RESTART ssntp.Command payload for test cases

View Source
const SchedulerAddr = "192.168.42.5"

SchedulerAddr is a test scheduler address

View Source
const StartFailureYaml = `instance_uuid: ` + InstanceUUID + `
reason: full_cloud
`

StartFailureYaml is a sample workload StartFailure ssntp.Error payload for test cases

View Source
const StartYaml = `start:
  tenant_uuid: ` + TenantUUID + `
  instance_uuid: ` + InstanceUUID + `
  image_uuid: ` + ImageUUID + `
  docker_image: ` + DockerImage + `
  fw_type: efi
  persistence: host
  vm_type: qemu
  requested_resources:
  - type: vcpus
    value: 2
    mandatory: true
  - type: mem_mb
    value: 4096
    mandatory: true
  - type: disk_mb
    value: 10000
    mandatory: true
  estimated_resources:
  - type: vcpus
    value: 1
  - type: mem_mb
    value: 128
  - type: disk_mb
    value: 4096
  networking:
    vnic_mac: ""
    vnic_uuid: ""
    concentrator_uuid: ""
    concentrator_ip: ""
    subnet: ""
    subnet_key: ""
    subnet_uuid: ""
    private_ip: ""
    public_ip: false
`

StartYaml is a sample workload START ssntp.Command payload for test usage

View Source
const StatsYaml = `node_uuid: ` + AgentUUID + `
status: READY
mem_total_mb: 3896
mem_available_mb: 3896
disk_total_mb: 500000
disk_available_mb: 256000
load: 0
cpus_online: 4
hostname: test
networks:
- ip: 192.168.1.1
  mac: 02:00:15:03:6f:49
- ip: 10.168.1.1
  mac: 02:00:8c:ba:f9:45
instances:
- instance_uuid: fe2970fa-7b36-460b-8b79-9eb4745e62f2
  state: active
  ssh_ip: ""
  ssh_port: 0
  memory_usage_mb: 40
  disk_usage_mb: 2
  cpu_usage: 90
  volumes: []
- instance_uuid: cbda5bd8-33bd-4d39-9f52-ace8c9f0b99c
  state: active
  ssh_ip: 172.168.2.2
  ssh_port: 8768
  memory_usage_mb: 50
  disk_usage_mb: 10
  cpu_usage: 0
  volumes: []
- instance_uuid: 1f5b2fe6-4493-4561-904a-8f4e956218d9
  state: exited
  ssh_ip: ""
  ssh_port: 0
  memory_usage_mb: -1
  disk_usage_mb: 2
  cpu_usage: -1
  volumes:
  - 67d86208-b46c-4465-9018-e14187d4010
`

StatsYaml is a sample node STATS ssntp.Command payload for test cases

View Source
const StopFailureYaml = `instance_uuid: ` + InstanceUUID + `
reason: already_stopped
`

StopFailureYaml is a sample workload StopFailure ssntp.Error payload for test cases

View Source
const StopYaml = `stop:
  instance_uuid: ` + InstanceUUID + `
  workload_agent_uuid: ` + AgentUUID + `
`

StopYaml is a sample workload STOP ssntp.Command payload for test cases

View Source
const StorageURI = "/etc/ciao/ciao.json"

StorageURI is a test storage URI

View Source
const SubnetKey = "8"

SubnetKey is a test tenant subnet key

View Source
const TenantAddedYaml = `tenant_added:
  agent_uuid: ` + AgentUUID + `
  agent_ip: ` + AgentIP + `
  tenant_uuid: ` + TenantUUID + `
  tenant_subnet: ` + TenantSubnet + `
  concentrator_uuid: ` + CNCIUUID + `
  concentrator_ip: ` + CNCIIP + `
  subnet_key: ` + SubnetKey + `
`

TenantAddedYaml is a sample TenantAdded ssntp.Event payload for test cases

View Source
const TenantRemovedYaml = `tenant_removed:
  agent_uuid: ` + AgentUUID + `
  agent_ip: ` + AgentIP + `
  tenant_uuid: ` + TenantUUID + `
  tenant_subnet: ` + TenantSubnet + `
  concentrator_uuid: ` + CNCIUUID + `
  concentrator_ip: ` + CNCIIP + `
  subnet_key: ` + SubnetKey + `
`

TenantRemovedYaml is a sample TenantRemove ssntp.Event payload for test cases

View Source
const TenantSubnet = "10.2.0.0/16"

TenantSubnet is a test tenant subnet

View Source
const TenantUUID = "2491851d-dce9-48d6-b83a-a717417072ce"

TenantUUID is a test tenant UUID

View Source
const TestCACert = `` /* 1131-byte string literal not displayed */

TestCACert is a snake oil Certificate Authority for test automation.

View Source
const TestCACertSchedulerMultiHomed = `` /* 1164-byte string literal not displayed */

TestCACertSchedulerMultiHomed is a snake oil SSNTP multihomed scheduler role Certificate Authority for test automation.

View Source
const TestCertAgent = `` /* 2802-byte string literal not displayed */

TestCertAgent is a snake oil SSNTP Agent role certificate for test automation.

View Source
const TestCertAgentNetAgent = `` /* 2818-byte string literal not displayed */

TestCertAgentNetAgent is a snake oil SSNTP AGENT|NETAGENT role certificate for test automation.

View Source
const TestCertCNCIAgent = `` /* 2806-byte string literal not displayed */

TestCertCNCIAgent is a snake oil SSNTP CNCIAgent role certificate for test automation.

View Source
const TestCertController = `` /* 2806-byte string literal not displayed */

TestCertController is a snake oil SSNTP Controller role certificate for test automation.

View Source
const TestCertNetAgent = `` /* 2806-byte string literal not displayed */

TestCertNetAgent is a snake oil SSNTP NetAgent role certificate for test automation.

View Source
const TestCertScheduler = `` /* 2810-byte string literal not displayed */

TestCertScheduler is a snake oil SSNTP Scheduler role certificate for test automation.

View Source
const TestCertServer = `` /* 2802-byte string literal not displayed */

TestCertServer is a snake oil SSNTP Server role certificate for test automation.

View Source
const TestCertUnknown = `` /* 2790-byte string literal not displayed */

TestCertUnknown is a snake oil SSNTP Unknown role certificate for test automation.

View Source
const VNICMAC = "aa:bb:cc:01:02:03"

VNICMAC is a test instance VNIC MAC address

View Source
const VNICUUID = "7f49d00d-1995-4156-8c79-5f5ab24ce138"

VNICUUID is a test instance VNIC UUID

View Source
const VolumeUUID = "67d86208-b46c-4465-9018-e14187d4010"

VolumeUUID is a node UUID for storage tests

Variables

View Source
var ComputeURL = "https://localhost:" + ComputeAPIPort

ComputeURL is the compute service URL the testutil identity service will use by default

View Source
var ComputeUser = "f452bbc7-5076-44d5-922c-3b9d2ce1503f"

ComputeUser is the test user/tenant name the testutil identity service will use by default

View Source
var IdentityURL string

IdentityURL is the URL for the testutil identity service

View Source
var InstanceStat001 = payloads.InstanceStat{
	InstanceUUID:  "fe2970fa-7b36-460b-8b79-9eb4745e62f2",
	State:         payloads.Running,
	MemoryUsageMB: 40,
	DiskUsageMB:   2,
	CPUUsage:      90,
	SSHIP:         "",
	SSHPort:       0,
}

InstanceStat001 is a sample payloads.InstanceStat

View Source
var InstanceStat002 = payloads.InstanceStat{
	InstanceUUID:  "cbda5bd8-33bd-4d39-9f52-ace8c9f0b99c",
	State:         payloads.Running,
	MemoryUsageMB: 50,
	DiskUsageMB:   10,
	CPUUsage:      0,
	SSHIP:         "172.168.2.2",
	SSHPort:       8768,
}

InstanceStat002 is a sample payloads.InstanceStat

View Source
var InstanceStat003 = payloads.InstanceStat{
	InstanceUUID:  "1f5b2fe6-4493-4561-904a-8f4e956218d9",
	State:         payloads.Exited,
	MemoryUsageMB: -1,
	DiskUsageMB:   2,
	CPUUsage:      -1,
	Volumes:       []string{VolumeUUID},
}

InstanceStat003 is a sample payloads.InstanceStat

View Source
var NetworkStat001 = payloads.NetworkStat{
	NodeIP:  "192.168.1.1",
	NodeMAC: "02:00:15:03:6f:49",
}

NetworkStat001 is a sample payloads.NetworkStat

View Source
var NetworkStat002 = payloads.NetworkStat{
	NodeIP:  "10.168.1.1",
	NodeMAC: "02:00:8c:ba:f9:45",
}

NetworkStat002 is a sample payloads.NetworkStat

Functions

func IdentityHandlers

func IdentityHandlers() *mux.Router

IdentityHandlers creates a mux.Router for identity POST and GET handlers

func ReadyPayload

func ReadyPayload(uuid string, memTotal int, memAvail int) payloads.Ready

ReadyPayload is a helper to craft a mostly fixed ssntp.READY status payload, with parameters to specify the source node uuid and memory metrics

func RoleToTestCert

func RoleToTestCert(role ssntp.Role) string

RoleToTestCert returns a string containing the testutil certificate matching the specified ssntp.Role

func StartIdentityServer

func StartIdentityServer(config IdentityConfig) *httptest.Server

StartIdentityServer starts a fake keystone service for unit testing ciao. Caller must call Close() on the returned *httptest.Server.

func StatsPayload

func StatsPayload(uuid string, name string, instances []payloads.InstanceStat, networks []payloads.NetworkStat) payloads.Stat

StatsPayload is a factory function for a node STATS ssntp.Command payload for test cases The StatsPayload() factory function returns a payloads.Stat object. If passed uuid==AgentUUID, instances==[InstanceStat001,InstanceStat002,InstanceStat003] and networks==[NetworkStat001,NetworkStat002], then StatsPayload() will return a payloads.Stat matching the StatsYaml string.

Types

type IdentityConfig

type IdentityConfig struct {
	ComputeURL string
	ProjectID  string
}

IdentityConfig contains the URL of the ciao compute service, and the TenantID of the tenant you want tokens to be sent for. The test Identity service only supports authentication of a single tenant, and gives the token an admin role.

type Result

type Result struct {
	InstanceUUID string
	Err          error
	NodeUUID     string
	TenantUUID   string
	CNCI         bool
	VolumeUUID   string
}

Result is a common result structure for tests spanning between controller client, scheduler server, and the various (eg: Agent, NetAgent, CNCIAgent) agent roles.

type SsntpTestClient

type SsntpTestClient struct {
	Ssntp ssntp.Client
	Name  string

	UUID                   string
	Role                   ssntp.Role
	StartFail              bool
	StartFailReason        payloads.StartFailureReason
	StopFail               bool
	StopFailReason         payloads.StopFailureReason
	RestartFail            bool
	RestartFailReason      payloads.RestartFailureReason
	DeleteFail             bool
	DeleteFailReason       payloads.DeleteFailureReason
	AttachFail             bool
	AttachVolumeFailReason payloads.AttachVolumeFailureReason
	DetachFail             bool
	DetachVolumeFailReason payloads.DetachVolumeFailureReason

	CmdChans        map[ssntp.Command]chan Result
	CmdChansLock    *sync.Mutex
	EventChans      map[ssntp.Event]chan Result
	EventChansLock  *sync.Mutex
	ErrorChans      map[ssntp.Error]chan Result
	ErrorChansLock  *sync.Mutex
	StatusChans     map[ssntp.Status]chan Result
	StatusChansLock *sync.Mutex
	// contains filtered or unexported fields
}

SsntpTestClient is global state for the testutil SSNTP client worker

func NewSsntpTestClientConnection

func NewSsntpTestClientConnection(name string, role ssntp.Role, uuid string) (*SsntpTestClient, error)

NewSsntpTestClientConnection creates an SsntpTestClient and dials the server. Calling with a unique name parameter string for inclusion in the SsntpTestClient.Name field aides in debugging. The role parameter is mandatory. The uuid string parameter allows tests to specify a known uuid for simpler tests.

func (*SsntpTestClient) AddCmdChan

func (client *SsntpTestClient) AddCmdChan(cmd ssntp.Command) *chan Result

AddCmdChan adds an ssntp.Command to the SsntpTestClient command channel

func (*SsntpTestClient) AddErrorChan

func (client *SsntpTestClient) AddErrorChan(error ssntp.Error) *chan Result

AddErrorChan adds a ssntp.Error to the SsntpTestClient error channel

func (*SsntpTestClient) AddEventChan

func (client *SsntpTestClient) AddEventChan(evt ssntp.Event) *chan Result

AddEventChan adds a ssntp.Event to the SsntpTestClient event channel

func (*SsntpTestClient) AddStatusChan

func (client *SsntpTestClient) AddStatusChan(status ssntp.Status) *chan Result

AddStatusChan adds an ssntp.Status to the SsntpTestClient status channel

func (*SsntpTestClient) CommandNotify

func (client *SsntpTestClient) CommandNotify(command ssntp.Command, frame *ssntp.Frame)

CommandNotify implements the SSNTP client CommandNotify callback for SsntpTestClient

func (*SsntpTestClient) ConnectNotify

func (client *SsntpTestClient) ConnectNotify()

ConnectNotify implements the SSNTP client ConnectNotify callback for SsntpTestClient

func (*SsntpTestClient) DisconnectNotify

func (client *SsntpTestClient) DisconnectNotify()

DisconnectNotify implements the SSNTP client ConnectNotify callback for SsntpTestClient

func (*SsntpTestClient) ErrorNotify

func (client *SsntpTestClient) ErrorNotify(error ssntp.Error, frame *ssntp.Frame)

ErrorNotify is an SSNTP callback stub for SsntpTestClient

func (*SsntpTestClient) EventNotify

func (client *SsntpTestClient) EventNotify(event ssntp.Event, frame *ssntp.Frame)

EventNotify is an SSNTP callback stub for SsntpTestClient

func (*SsntpTestClient) GetCmdChanResult

func (client *SsntpTestClient) GetCmdChanResult(c *chan Result, cmd ssntp.Command) (result Result, err error)

GetCmdChanResult gets a Result from the SsntpTestClient command channel

func (*SsntpTestClient) GetErrorChanResult

func (client *SsntpTestClient) GetErrorChanResult(c *chan Result, error ssntp.Error) (result Result, err error)

GetErrorChanResult gets a Result from the SsntpTestClient error channel

func (*SsntpTestClient) GetEventChanResult

func (client *SsntpTestClient) GetEventChanResult(c *chan Result, evt ssntp.Event) (result Result, err error)

GetEventChanResult gets a Result from the SsntpTestClient event channel

func (*SsntpTestClient) GetStatusChanResult

func (client *SsntpTestClient) GetStatusChanResult(c *chan Result, status ssntp.Status) (result Result, err error)

GetStatusChanResult gets a Result from the SsntpTestClient status channel

func (*SsntpTestClient) SendConcentratorAddedEvent

func (client *SsntpTestClient) SendConcentratorAddedEvent(instanceUUID string, tenantUUID string, ip string, vnicMAC string)

SendConcentratorAddedEvent allows an SsntpTestClient to push an ssntp.ConcentratorInstanceAdded event frame

func (*SsntpTestClient) SendDeleteEvent

func (client *SsntpTestClient) SendDeleteEvent(uuid string)

SendDeleteEvent allows an SsntpTestClient to push an ssntp.InstanceDeleted event frame

func (*SsntpTestClient) SendPublicIPAssignedEvent

func (client *SsntpTestClient) SendPublicIPAssignedEvent()

SendPublicIPAssignedEvent allows an SsntpTestClient to push an ssntp.PublicIPAssigned event frame

func (*SsntpTestClient) SendResultAndDelCmdChan

func (client *SsntpTestClient) SendResultAndDelCmdChan(cmd ssntp.Command, result Result)

SendResultAndDelCmdChan deletes an ssntp.Command from the SsntpTestClient command channel

func (*SsntpTestClient) SendResultAndDelErrorChan

func (client *SsntpTestClient) SendResultAndDelErrorChan(error ssntp.Error, result Result)

SendResultAndDelErrorChan deletes an ssntp.Error from the SsntpTestClient error channel

func (*SsntpTestClient) SendResultAndDelEventChan

func (client *SsntpTestClient) SendResultAndDelEventChan(evt ssntp.Event, result Result)

SendResultAndDelEventChan deletes an ssntp.Event from the SsntpTestClient event channel

func (*SsntpTestClient) SendResultAndDelStatusChan

func (client *SsntpTestClient) SendResultAndDelStatusChan(status ssntp.Status, result Result)

SendResultAndDelStatusChan deletes an ssntp.Status from the SsntpTestClient status channel

func (*SsntpTestClient) SendStatsCmd

func (client *SsntpTestClient) SendStatsCmd()

SendStatsCmd pushes an ssntp.STATS command frame from the SsntpTestClient

func (*SsntpTestClient) SendStatus

func (client *SsntpTestClient) SendStatus(memTotal int, memAvail int)

SendStatus pushes an ssntp status frame from the SsntpTestClient with the indicated total and available memory statistics

func (*SsntpTestClient) SendTenantAddedEvent

func (client *SsntpTestClient) SendTenantAddedEvent()

SendTenantAddedEvent allows an SsntpTestClient to push an ssntp.TenantAdded event frame

func (*SsntpTestClient) SendTenantRemovedEvent

func (client *SsntpTestClient) SendTenantRemovedEvent()

SendTenantRemovedEvent allows an SsntpTestClient to push an ssntp.TenantRemoved event frame

func (*SsntpTestClient) SendTrace

func (client *SsntpTestClient) SendTrace()

SendTrace allows an SsntpTestClient to push an ssntp.TraceReport event frame

func (*SsntpTestClient) Shutdown

func (client *SsntpTestClient) Shutdown()

Shutdown shuts down the testutil.SsntpTestClient and cleans up state

func (*SsntpTestClient) StatusNotify

func (client *SsntpTestClient) StatusNotify(status ssntp.Status, frame *ssntp.Frame)

StatusNotify implements the SSNTP client StatusNotify callback for SsntpTestClient

type SsntpTestController

type SsntpTestController struct {
	Ssntp          ssntp.Client
	Name           string
	UUID           string
	CmdChans       map[ssntp.Command]chan Result
	CmdChansLock   *sync.Mutex
	EventChans     map[ssntp.Event]chan Result
	EventChansLock *sync.Mutex
	ErrorChans     map[ssntp.Error]chan Result
	ErrorChansLock *sync.Mutex
}

SsntpTestController is global state for the testutil SSNTP controller

func NewSsntpTestControllerConnection

func NewSsntpTestControllerConnection(name string, uuid string) (*SsntpTestController, error)

NewSsntpTestControllerConnection creates an SsntpTestController and dials the server. Calling with a unique name parameter string for inclusion in the SsntpTestClient.Name field aides in debugging. The uuid string parameter allows tests to specify a known uuid for simpler tests.

func (*SsntpTestController) AddCmdChan

func (ctl *SsntpTestController) AddCmdChan(cmd ssntp.Command) *chan Result

AddCmdChan adds an ssntp.Command to the SsntpTestController command channel

func (*SsntpTestController) AddErrorChan

func (ctl *SsntpTestController) AddErrorChan(error ssntp.Error) *chan Result

AddErrorChan adds an ssntp.Error to the SsntpTestController error channel

func (*SsntpTestController) AddEventChan

func (ctl *SsntpTestController) AddEventChan(evt ssntp.Event) *chan Result

AddEventChan adds an ssntp.Event to the SsntpTestController event channel

func (*SsntpTestController) CommandNotify

func (ctl *SsntpTestController) CommandNotify(command ssntp.Command, frame *ssntp.Frame)

CommandNotify implements the SSNTP client CommandNotify callback for SsntpTestController

func (*SsntpTestController) ConnectNotify

func (ctl *SsntpTestController) ConnectNotify()

ConnectNotify implements the SSNTP client ConnectNotify callback for SsntpTestController

func (*SsntpTestController) DisconnectNotify

func (ctl *SsntpTestController) DisconnectNotify()

DisconnectNotify implements the SSNTP client DisconnectNotify callback for SsntpTestController

func (*SsntpTestController) ErrorNotify

func (ctl *SsntpTestController) ErrorNotify(error ssntp.Error, frame *ssntp.Frame)

ErrorNotify implements the SSNTP client ErrorNotify callback for SsntpTestController

func (*SsntpTestController) EventNotify

func (ctl *SsntpTestController) EventNotify(event ssntp.Event, frame *ssntp.Frame)

EventNotify implements the SSNTP client EventNotify callback for SsntpTestController

func (*SsntpTestController) GetCmdChanResult

func (ctl *SsntpTestController) GetCmdChanResult(c *chan Result, cmd ssntp.Command) (result Result, err error)

GetCmdChanResult gets a Result from the SsntpTestController command channel

func (*SsntpTestController) GetErrorChanResult

func (ctl *SsntpTestController) GetErrorChanResult(c *chan Result, error ssntp.Error) (result Result, err error)

GetErrorChanResult gets a Result from the SsntpTestController error channel

func (*SsntpTestController) GetEventChanResult

func (ctl *SsntpTestController) GetEventChanResult(c *chan Result, evt ssntp.Event) (result Result, err error)

GetEventChanResult gets a Result from the SsntpTestController event channel

func (*SsntpTestController) SendResultAndDelCmdChan

func (ctl *SsntpTestController) SendResultAndDelCmdChan(cmd ssntp.Command, result Result)

SendResultAndDelCmdChan deletes an ssntp.Command from the SsntpTestController command channel

func (*SsntpTestController) SendResultAndDelErrorChan

func (ctl *SsntpTestController) SendResultAndDelErrorChan(error ssntp.Error, result Result)

SendResultAndDelErrorChan deletes an ssntp.Error from the SsntpTestController error channel

func (*SsntpTestController) SendResultAndDelEventChan

func (ctl *SsntpTestController) SendResultAndDelEventChan(evt ssntp.Event, result Result)

SendResultAndDelEventChan deletes an ssntpEvent from the SsntpTestController event channel

func (*SsntpTestController) Shutdown

func (ctl *SsntpTestController) Shutdown()

Shutdown shuts down the testutil.SsntpTestClient and cleans up state

func (*SsntpTestController) StatusNotify

func (ctl *SsntpTestController) StatusNotify(status ssntp.Status, frame *ssntp.Frame)

StatusNotify implements the SSNTP client StatusNotify callback for SsntpTestController

type SsntpTestServer

type SsntpTestServer struct {
	Ssntp ssntp.Server

	CmdChans        map[ssntp.Command]chan Result
	CmdChansLock    *sync.Mutex
	EventChans      map[ssntp.Event]chan Result
	EventChansLock  *sync.Mutex
	ErrorChans      map[ssntp.Error]chan Result
	ErrorChansLock  *sync.Mutex
	StatusChans     map[ssntp.Status]chan Result
	StatusChansLock *sync.Mutex
	// contains filtered or unexported fields
}

SsntpTestServer is global state for the testutil SSNTP server

func StartTestServer

func StartTestServer() *SsntpTestServer

StartTestServer starts a go routine for based on a testutil.SsntpTestServer configuration with standard ssntp.FrameRorwardRules

func (*SsntpTestServer) AddCmdChan

func (server *SsntpTestServer) AddCmdChan(cmd ssntp.Command) *chan Result

AddCmdChan adds an ssntp.Command to the SsntpTestServer command channel

func (*SsntpTestServer) AddErrorChan

func (server *SsntpTestServer) AddErrorChan(error ssntp.Error) *chan Result

AddErrorChan adds an ssntp.Error to the SsntpTestServer error channel

func (*SsntpTestServer) AddEventChan

func (server *SsntpTestServer) AddEventChan(evt ssntp.Event) *chan Result

AddEventChan adds an ssntp.Event to the SsntpTestServer event channel

func (*SsntpTestServer) AddStatusChan

func (server *SsntpTestServer) AddStatusChan(status ssntp.Status) *chan Result

AddStatusChan adds an ssntp.Status to the SsntpTestServer status channel

func (*SsntpTestServer) CommandForward

func (server *SsntpTestServer) CommandForward(uuid string, command ssntp.Command, frame *ssntp.Frame) (dest ssntp.ForwardDestination)

CommandForward implements an SSNTP CommandForward callback for SsntpTestServer

func (*SsntpTestServer) CommandNotify

func (server *SsntpTestServer) CommandNotify(uuid string, command ssntp.Command, frame *ssntp.Frame)

CommandNotify implements an SSNTP CommandNotify callback for SsntpTestServer

func (*SsntpTestServer) ConnectNotify

func (server *SsntpTestServer) ConnectNotify(uuid string, role ssntp.Role)

ConnectNotify implements an SSNTP ConnectNotify callback for SsntpTestServer

func (*SsntpTestServer) DisconnectNotify

func (server *SsntpTestServer) DisconnectNotify(uuid string, role ssntp.Role)

DisconnectNotify implements an SSNTP DisconnectNotify callback for SsntpTestServer

func (*SsntpTestServer) ErrorNotify

func (server *SsntpTestServer) ErrorNotify(uuid string, error ssntp.Error, frame *ssntp.Frame)

ErrorNotify is an SSNTP callback stub for SsntpTestServer

func (*SsntpTestServer) EventForward

func (server *SsntpTestServer) EventForward(uuid string, event ssntp.Event, frame *ssntp.Frame) ssntp.ForwardDestination

EventForward implements and SSNTP EventForward callback for SsntpTestServer

func (*SsntpTestServer) EventNotify

func (server *SsntpTestServer) EventNotify(uuid string, event ssntp.Event, frame *ssntp.Frame)

EventNotify implements an SSNTP EventNotify callback for SsntpTestServer

func (*SsntpTestServer) GetCmdChanResult

func (server *SsntpTestServer) GetCmdChanResult(c *chan Result, cmd ssntp.Command) (result Result, err error)

GetCmdChanResult gets a Result from the SsntpTestServer command channel

func (*SsntpTestServer) GetErrorChanResult

func (server *SsntpTestServer) GetErrorChanResult(c *chan Result, error ssntp.Error) (result Result, err error)

GetErrorChanResult gets a CmdResult from the SsntpTestServer error channel

func (*SsntpTestServer) GetEventChanResult

func (server *SsntpTestServer) GetEventChanResult(c *chan Result, evt ssntp.Event) (result Result, err error)

GetEventChanResult gets a Result from the SsntpTestServer event channel

func (*SsntpTestServer) GetStatusChanResult

func (server *SsntpTestServer) GetStatusChanResult(c *chan Result, status ssntp.Status) (result Result, err error)

GetStatusChanResult gets a Result from the SsntpTestServer status channel

func (*SsntpTestServer) SendResultAndDelCmdChan

func (server *SsntpTestServer) SendResultAndDelCmdChan(cmd ssntp.Command, result Result)

SendResultAndDelCmdChan deletes an ssntp.Command from the SsntpTestServer command channel

func (*SsntpTestServer) SendResultAndDelErrorChan

func (server *SsntpTestServer) SendResultAndDelErrorChan(error ssntp.Error, result Result)

SendResultAndDelErrorChan deletes an ssntp.Error from the SsntpTestServer error channel

func (*SsntpTestServer) SendResultAndDelEventChan

func (server *SsntpTestServer) SendResultAndDelEventChan(evt ssntp.Event, result Result)

SendResultAndDelEventChan deletes an ssntp.Event from the SsntpTestServer event channel

func (*SsntpTestServer) SendResultAndDelStatusChan

func (server *SsntpTestServer) SendResultAndDelStatusChan(error ssntp.Status, result Result)

SendResultAndDelStatusChan deletes an ssntp.Status from the SsntpTestServer status channel

func (*SsntpTestServer) Shutdown

func (server *SsntpTestServer) Shutdown()

Shutdown shuts down the testutil.SsntpTestServer and cleans up state

func (*SsntpTestServer) StatusNotify

func (server *SsntpTestServer) StatusNotify(uuid string, status ssntp.Status, frame *ssntp.Frame)

StatusNotify is an SSNTP callback stub for SsntpTestServer

Jump to

Keyboard shortcuts

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