testing

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MPL-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

instances unit tests

Index

Constants

View Source
const AssignSecurityGroupsRequest = `
{
  "name": "Test"
}
`
View Source
const AttachInterfaceRequest = `
{
  "type": "subnet",
  "subnet_id": "9bc36cf6-407c-4a74-bc83-ce3aa3854c3d"
}
`
View Source
const CreateRequest = `` /* 621-byte string literal not displayed */
View Source
const CreateResponse = `
{
  "tasks": [
    "50f53a35-42ed-40c4-82b2-5a37fb3e00bc"
  ]
}
`
View Source
const DeleteResponse = `
{
  "tasks": [
    "50f53a35-42ed-40c4-82b2-5a37fb3e00bc"
  ]
}
`
View Source
const DetachInterfaceRequest = `
{
  "ip_address": "192.168.0.23",
  "port_id": "9bc36cf6-407c-4a74-bc83-ce3aa3854c3d"
}
`
View Source
const GetResponse = `` /* 1409-byte string literal not displayed */
View Source
const InstanceConsoleResponse = `` /* 204-byte string literal not displayed */
View Source
const InterfacesResponse = `` /* 3142-byte string literal not displayed */
View Source
const ListAvailableFlavorsResponse = `` /* 275-byte string literal not displayed */
View Source
const ListInstanceLocationResponse = `` /* 262-byte string literal not displayed */
View Source
const ListInstanceMetricsRequest = `
{
    "time_interval": 4,
    "time_unit": "day"
}
`
View Source
const ListInstanceMetricsResponse = `` /* 490-byte string literal not displayed */
View Source
const ListResponse = `` /* 1683-byte string literal not displayed */
View Source
const MetadataDetailedResponse = `` /* 298-byte string literal not displayed */

MetadataDetailedResponse is an instance-detail response that carries the metadata_detailed field used by MetadataListAll after migrating off the deprecated v1 /metadata listing endpoint.

View Source
const MetadataListResponse = `` /* 215-byte string literal not displayed */

MetadataListResponse is the paginated body returned by the deprecated v1 /metadata listing endpoint, still served by the legacy MetadataList pager.

View Source
const MetadataReplaceTagsPatchRequest = `
{
  "tags": {
    "old-user-tag": null,
    "test1": "test1",
    "test2": "test2"
  }
}
`

MetadataReplaceTagsPatchRequest is the merge-patch body produced by MetadataUpdate's replace-all behaviour: the existing user tag absent from the new set is nulled, the read-only tag is left untouched, and the new tags are written.

View Source
const MetadataResponse = `
{
  "key": "cost-center",
  "value": "Atlanta",
  "read_only": false
}
`
View Source
const MetadataTagsPatchRequest = `
{
  "tags": {
    "test1": "test1",
    "test2": "test2"
  }
}
`

MetadataTagsPatchRequest is the request body sent to PATCH the instance when adding/updating tags via the modern instance update endpoint.

View Source
const MetadataUpdateDetailResponse = `` /* 336-byte string literal not displayed */

MetadataUpdateDetailResponse is the instance-detail response read by MetadataUpdate before it builds a replace-all merge patch. It carries one user tag (to be removed) and one read-only tag (must be preserved).

View Source
const PortsListResponse = `` /* 260-byte string literal not displayed */
View Source
const RenameInstanceRequest = `
{
	"name": "new-name"
}
`
View Source
const ResizeResponse = `
{
  "tasks": [
    "50f53a35-42ed-40c4-82b2-5a37fb3e00bc"
  ]
}
`
View Source
const SecurityGroupsListResponse = `
{
  "count": 1,
  "results": [
    {
      "name": "Test",
      "id": "2bf3a5d7-9072-40aa-8ac0-a64e39427a2c"
    }
  ]
}
`
View Source
const UnAssignSecurityGroupsRequest = `
{
  "name": "Test"
}
`

Variables

View Source
var (
	Instance1 = instances.Instance{
		ID:               instanceID,
		Name:             instanceName,
		Description:      instanceDescription,
		CreatedAt:        createdTime,
		Status:           "ACTIVE",
		VMState:          "active",
		TaskState:        nil,
		AvailabilityZone: instances.DefaultAvailabilityZone,
		Flavor: flavors.Flavor{
			FlavorID:   "g1s-shared-1-0.5",
			FlavorName: "g1s-shared-1-0.5",
			RAM:        512,
			VCPUS:      1,
		},
		Metadata: map[string]interface{}{
			"os_distro":     "centos",
			"os_version":    "1711-x64",
			"image_name":    "cirros-0.3.5-x86_64-disk",
			"image_id":      "f01fd9a0-9548-48ba-82dc-a8c8b2d6f2f1",
			"snapshot_name": "test_snapshot",
			"snapshot_id":   "c286cd13-fba9-4302-9cdb-4351a05a56ea",
			"task_id":       "d1e1500b-e2be-40aa-9a4b-cc493fa1af30",
		},
		Volumes: []instances.InstanceVolume{{
			ID:                  "28bfe198-a003-4283-8dca-ab5da4a71b62",
			DeleteOnTermination: false,
		}},
		Addresses: map[string][]instances.InstanceAddress{
			"net1": {{
				Type:    types.AddressTypeFixed,
				Address: ip1,
			},
				{
					Type:    types.AddressTypeFloating,
					Address: ip2,
				},
			},
			"net2": {{
				Type:    types.AddressTypeFixed,
				Address: ip3,
			}},
		},
		SecurityGroups: []gcorecloud.ItemName{{
			Name: "default",
		}},
		CreatorTaskID: &creatorTaskID,
		TaskID:        &taskID,
		ProjectID:     1,
		RegionID:      1,
		Region:        "RegionOne",
	}
	PortID                         = "1f0ca628-a73b-42c0-bdac-7b10d023e097"
	PortMac, _                     = gcorecloud.ParseMacString("00:16:3e:f2:87:16")
	PortIP1                        = net.ParseIP("192.168.123.20")
	PortIP2                        = net.ParseIP("192.168.120.16")
	PortNetworkUpdatedAt, _        = time.Parse(gcorecloud.RFC3339Z, "2020-02-26T08:44:44+0000")
	PortNetworkCreatedAt, _        = time.Parse(gcorecloud.RFC3339Z, "2020-02-26T08:44:08+0000")
	PortNetworkSubnet1CreatedAt, _ = time.Parse(gcorecloud.RFC3339Z, "2019-07-18T12:07:00+0000")
	PortNetworkSubnet1UpdatedAt, _ = time.Parse(gcorecloud.RFC3339Z, "2019-07-22T10:55:45+0000")
	PortNetworkSubnet2CreatedAt, _ = time.Parse(gcorecloud.RFC3339Z, "2019-07-22T15:15:05+0000")
	PortNetworkSubnet2UpdatedAt, _ = time.Parse(gcorecloud.RFC3339Z, "2019-07-22T15:15:05+0000")
	MetricsTime, _                 = time.Parse(gcorecloud.RFC3339ZZ, "2020-07-07T12:57:00Z")
	PortNetworkSubnet1Cidr, _      = gcorecloud.ParseCIDRString("192.168.123.0/24")
	PortNetworkSubnet2Cidr, _      = gcorecloud.ParseCIDRString("192.168.120.0/24")
	FloatingIP1                    = net.ParseIP("5.188.135.29")
	FixedIP1                       = net.ParseIP("192.168.123.20")
	FloatingIP2                    = net.ParseIP("5.188.135.30")
	FixedIP2                       = net.ParseIP("192.168.120.16")
	PortFloatingIP1CreatedAt, _    = time.Parse(gcorecloud.RFC3339Z, "2020-02-26T08:47:19+0000")
	PortFloatingIP1UpdatedAt, _    = time.Parse(gcorecloud.RFC3339Z, "2020-02-26T08:47:23+0000")
	PortFloatingIP1CreatorTaskID   = "d1c1fd65-6eef-4e64-96cb-705cbbdbc90b"
	PortFloatingIP2CreatedAt, _    = time.Parse(gcorecloud.RFC3339Z, "2020-02-26T08:47:18+0000")
	PortFloatingIP2UpdatedAt, _    = time.Parse(gcorecloud.RFC3339Z, "2020-02-26T08:47:23+0000")
	PortFloatingIP2CreatorTaskID   = "d1c1fd65-6eef-4e64-96cb-705cbbdbc90b"
	NetworkDetailsCreatorTask      = "a10dd116-07f5-4225-abb7-f42da5cb78fb"
	NetworkDetailsTask             = "a10dd116-07f5-4225-abb7-f42da5cb78fc"
	SecurityGroup1                 = gcorecloud.ItemIDName{
		ID:   "2bf3a5d7-9072-40aa-8ac0-a64e39427a2c",
		Name: "Test",
	}
	InstancePort1 = instances.InstancePorts{
		ID:             "ae74714c-c380-48b4-87f8-758d656cdad6",
		Name:           "name",
		SecurityGroups: ExpectedSecurityGroupsSlice,
	}
	InstanceInterface1 = instances.Interface{
		PortID:              PortID,
		MacAddress:          *PortMac,
		PortSecurityEnabled: true,
		NetworkID:           "bc688791-f1b0-44eb-97d4-07697294b1e1",
		IPAssignments: []instances.PortIP{{
			IPAddress: PortIP1,
			SubnetID:  "351b0dd7-ca09-431c-be53-935db3785067",
		}, {
			IPAddress: PortIP2,
			SubnetID:  "0a641ef8-62dc-4146-91e5-6ab4b464df6d",
		}},
		NetworkDetails: instances.NetworkDetail{
			Mtu:           1450,
			UpdatedAt:     &gcorecloud.JSONRFC3339Z{Time: PortNetworkUpdatedAt},
			CreatedAt:     gcorecloud.JSONRFC3339Z{Time: PortNetworkCreatedAt},
			ID:            "bc688791-f1b0-44eb-97d4-07697294b1e1",
			External:      false,
			Default:       false,
			Shared:        false,
			Name:          "test network",
			TaskID:        &NetworkDetailsTask,
			CreatorTaskID: &NetworkDetailsCreatorTask,
			Subnets: []instances.Subnet{{
				ID:         "351b0dd7-ca09-431c-be53-935db3785067",
				Name:       "test 2",
				IPVersion:  gcorecloud.IPv4,
				EnableDHCP: true,
				Cidr:       *PortNetworkSubnet1Cidr,
				CreatedAt:  gcorecloud.JSONRFC3339Z{Time: PortNetworkSubnet1CreatedAt},
				UpdatedAt:  &gcorecloud.JSONRFC3339Z{Time: PortNetworkSubnet1UpdatedAt},
				NetworkID:  "bc688791-f1b0-44eb-97d4-07697294b1e1",
				ProjectID:  1,
				RegionID:   1,
				Region:     "",
			}, {
				ID:         "0a641ef8-62dc-4146-91e5-6ab4b464df6d",
				Name:       "string",
				IPVersion:  gcorecloud.IPv4,
				EnableDHCP: true,
				Cidr:       *PortNetworkSubnet2Cidr,
				CreatedAt:  gcorecloud.JSONRFC3339Z{Time: PortNetworkSubnet2CreatedAt},
				UpdatedAt:  &gcorecloud.JSONRFC3339Z{Time: PortNetworkSubnet2UpdatedAt},
				NetworkID:  "bc688791-f1b0-44eb-97d4-07697294b1e1",
				ProjectID:  1,
				RegionID:   1,
				Region:     "",
			}},
			ProjectID: 1,
			RegionID:  1,
			Region:    "ED-8",
		},
		FloatingIPDetails: []instances.FloatingIP{{
			FloatingIPAddress: FloatingIP1,
			FixedIPAddress:    FixedIP1,
			Status:            "ACTIVE",
			RouterID:          "bf231ab1-769f-44db-bcb1-7f4199a1cba8",
			ID:                "f32fe70c-f2ce-492e-858a-621bdc234885",
			PortID:            "1f0ca628-a73b-42c0-bdac-7b10d023e097",
			CreatedAt:         gcorecloud.JSONRFC3339Z{Time: PortFloatingIP1CreatedAt},
			UpdatedAt:         &gcorecloud.JSONRFC3339Z{Time: PortFloatingIP1UpdatedAt},
			CreatorTaskID:     &PortFloatingIP1CreatorTaskID,
			ProjectID:         1,
			RegionID:          1,
			Region:            "ED-8",
		}, {
			FloatingIPAddress: FloatingIP2,
			FixedIPAddress:    FixedIP2,
			Status:            "ACTIVE",
			RouterID:          "bf231ab1-769f-44db-bcb1-7f4199a1cba8",
			ID:                "f32fe70c-f2ce-492e-858a-621bdc234441",
			PortID:            "1f0ca628-a73b-42c0-bdac-7b10d023e097",
			CreatedAt:         gcorecloud.JSONRFC3339Z{Time: PortFloatingIP2CreatedAt},
			UpdatedAt:         &gcorecloud.JSONRFC3339Z{Time: PortFloatingIP2UpdatedAt},
			CreatorTaskID:     &PortFloatingIP2CreatorTaskID,
			ProjectID:         1,
			RegionID:          1,
			Region:            "ED-8",
		}},
	}
	ExpectedInstancesSlice          = []instances.Instance{Instance1}
	ExpectedInstanceInterfacesSlice = []instances.Interface{InstanceInterface1}
	ExpectedSecurityGroupsSlice     = []gcorecloud.ItemIDName{SecurityGroup1}
	ExpectedPortsSlice              = []instances.InstancePorts{InstancePort1}
	Tasks1                          = tasks.TaskResults{
		Tasks: []tasks.TaskID{"50f53a35-42ed-40c4-82b2-5a37fb3e00bc"},
	}
	Metadata1 = metadata.Metadata{
		Key:      "cost-center",
		Value:    "Atlanta",
		ReadOnly: false,
	}
	Metadata2 = metadata.Metadata{
		Key:      "data-center",
		Value:    "A",
		ReadOnly: false,
	}
	ExpectedMetadataList = []metadata.Metadata{Metadata1, Metadata2}
	Console              = instances.RemoteConsole{
		URL:      "https://92.38.157.200:6082/spice_auto.html?token=369b3c64-541b-4cd7-bc47-a82cdb98228f",
		Type:     "spice-html5",
		Protocol: "spice",
	}
	Metrics = instances.InstanceMetrics{
		CPUUtil: 8,
		Disks: []instances.DiskMetrics{
			{
				BpsRead:   16384,
				BpsWrite:  86016,
				IOPSRead:  3,
				IOPSWrite: 12,
				Name:      "sda",
			},
		},
		MemoryUtil:        33.28411162695459,
		NetworkBPSEgress:  102,
		NetworkBPSIngress: 102,
		NetworkPPSEgress:  0.7,
		NetworkPPSIngress: 0.7,
		Time:              gcorecloud.JSONRFC3339ZZ{Time: MetricsTime},
	}

	AvailableFlavor = flavors.Flavor{
		FlavorID:      "g1-gpu-1-2-1",
		FlavorName:    "g1-gpu-1-2-1",
		PriceStatus:   &priceStatus,
		CurrencyCode:  currencyCode,
		PricePerHour:  &pricePerHour,
		PricePerMonth: &pricePerMonth,
		RAM:           2048,
		VCPUS:         1,
	}
	InstanceLocation = instances.InstanceLocation{
		ID:          "0fc2bcde-209a-44d7-9506-1e92089b1695",
		ProjectID:   "879",
		ProjectName: "default",
		Name:        "bubuntu",
		RegionID:    "1",
		RegionName:  "ED-10",
		ClientID:    2,
	}
	ExpectedInstancesLocationSlice = []instances.InstanceLocation{InstanceLocation}
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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