testing

package
v0.6.28 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

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 MetadataCreateRequest = `
{
"test1": "test1", 
"test2": "test2"
}
`
View Source
const MetadataListResponse = `` /* 215-byte string literal not displayed */
View Source
const MetadataResponse = `
{
  "key": "cost-center",
  "value": "Atlanta",
  "read_only": false
}
`
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