github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/compute/v2/hypervisors/testing/fixtures_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"testing"
     7  
     8  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/compute/v2/hypervisors"
     9  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
    10  	"github.com/vnpaycloud-console/gophercloud/v2/testhelper/client"
    11  )
    12  
    13  // HypervisorListBodyPre253 represents a raw hypervisor list from the Compute
    14  // API with microversion older than 2.53.
    15  // The first hypervisor represents what the specification says (~Newton)
    16  // The second is exactly the same, but what you can get off a real system (~Kilo)
    17  const HypervisorListBodyPre253 = `
    18  {
    19      "hypervisors": [
    20          {
    21              "cpu_info": {
    22                  "arch": "x86_64",
    23                  "model": "Nehalem",
    24                  "vendor": "Intel",
    25                  "features": [
    26                      "pge",
    27                      "clflush"
    28                  ],
    29                  "topology": {
    30                      "cores": 1,
    31                      "threads": 1,
    32                      "sockets": 4
    33                  }
    34              },
    35              "current_workload": 0,
    36              "status": "enabled",
    37              "state": "up",
    38              "disk_available_least": 0,
    39              "host_ip": "1.1.1.1",
    40              "free_disk_gb": 1028,
    41              "free_ram_mb": 7680,
    42              "hypervisor_hostname": "fake-mini",
    43              "hypervisor_type": "fake",
    44              "hypervisor_version": 2002000,
    45              "id": 1,
    46              "local_gb": 1028,
    47              "local_gb_used": 0,
    48              "memory_mb": 8192,
    49              "memory_mb_used": 512,
    50              "running_vms": 0,
    51              "service": {
    52                  "host": "e6a37ee802d74863ab8b91ade8f12a67",
    53                  "id": 2,
    54                  "disabled_reason": null
    55              },
    56              "vcpus": 1,
    57              "vcpus_used": 0
    58          },
    59          {
    60              "cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
    61              "current_workload": 0,
    62              "status": "enabled",
    63              "state": "up",
    64              "disk_available_least": 0,
    65              "host_ip": "1.1.1.1",
    66              "free_disk_gb": 1028,
    67              "free_ram_mb": 7680,
    68              "hypervisor_hostname": "fake-mini",
    69              "hypervisor_type": "fake",
    70              "hypervisor_version": 2.002e+06,
    71              "id": 1,
    72              "local_gb": 1028,
    73              "local_gb_used": 0,
    74              "memory_mb": 8192,
    75              "memory_mb_used": 512,
    76              "running_vms": 0,
    77              "service": {
    78                  "host": "e6a37ee802d74863ab8b91ade8f12a67",
    79                  "id": 2,
    80                  "disabled_reason": null
    81              },
    82              "vcpus": 1,
    83              "vcpus_used": 0
    84          }
    85      ]
    86  }`
    87  
    88  // HypervisorListBody represents a raw hypervisor list result with Pike+ release.
    89  const HypervisorListBody = `
    90  {
    91      "hypervisors": [
    92          {
    93              "cpu_info": {
    94                  "arch": "x86_64",
    95                  "model": "Nehalem",
    96                  "vendor": "Intel",
    97                  "features": [
    98                      "pge",
    99                      "clflush"
   100                  ],
   101                  "topology": {
   102                      "cores": 1,
   103                      "threads": 1,
   104                      "sockets": 4
   105                  }
   106              },
   107              "current_workload": 0,
   108              "status": "enabled",
   109              "state": "up",
   110              "disk_available_least": 0,
   111              "host_ip": "1.1.1.1",
   112              "free_disk_gb": 1028,
   113              "free_ram_mb": 7680,
   114              "hypervisor_hostname": "fake-mini",
   115              "hypervisor_type": "fake",
   116              "hypervisor_version": 2002000,
   117              "id": "c48f6247-abe4-4a24-824e-ea39e108874f",
   118              "local_gb": 1028,
   119              "local_gb_used": 0,
   120              "memory_mb": 8192,
   121              "memory_mb_used": 512,
   122              "running_vms": 0,
   123              "service": {
   124                  "host": "e6a37ee802d74863ab8b91ade8f12a67",
   125                  "id": "9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   126                  "disabled_reason": null
   127              },
   128              "vcpus": 1,
   129              "vcpus_used": 0
   130          },
   131          {
   132              "cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
   133              "current_workload": 0,
   134              "status": "enabled",
   135              "state": "up",
   136              "disk_available_least": 0,
   137              "host_ip": "1.1.1.1",
   138              "free_disk_gb": 1028,
   139              "free_ram_mb": 7680,
   140              "hypervisor_hostname": "fake-mini",
   141              "hypervisor_type": "fake",
   142              "hypervisor_version": 2.002e+06,
   143              "id": "c48f6247-abe4-4a24-824e-ea39e108874f",
   144              "local_gb": 1028,
   145              "local_gb_used": 0,
   146              "memory_mb": 8192,
   147              "memory_mb_used": 512,
   148              "running_vms": 0,
   149              "service": {
   150                  "host": "e6a37ee802d74863ab8b91ade8f12a67",
   151                  "id": "9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   152                  "disabled_reason": null
   153              },
   154              "vcpus": 1,
   155              "vcpus_used": 0
   156          }
   157      ]
   158  }`
   159  
   160  // HypervisorListWithParametersBody represents a raw hypervisor list result with Pike+ release.
   161  const HypervisorListWithParametersBody = `
   162  {
   163      "hypervisors": [
   164          {
   165              "cpu_info": {
   166                  "arch": "x86_64",
   167                  "model": "Nehalem",
   168                  "vendor": "Intel",
   169                  "features": [
   170                      "pge",
   171                      "clflush"
   172                  ],
   173                  "topology": {
   174                      "cores": 1,
   175                      "threads": 1,
   176                      "sockets": 4
   177                  }
   178              },
   179              "current_workload": 0,
   180              "status": "enabled",
   181              "state": "up",
   182              "disk_available_least": 0,
   183              "host_ip": "1.1.1.1",
   184              "free_disk_gb": 1028,
   185              "free_ram_mb": 7680,
   186              "hypervisor_hostname": "fake-mini",
   187              "hypervisor_type": "fake",
   188              "hypervisor_version": 2002000,
   189              "id": "c48f6247-abe4-4a24-824e-ea39e108874f",
   190              "local_gb": 1028,
   191              "local_gb_used": 0,
   192              "memory_mb": 8192,
   193              "memory_mb_used": 512,
   194              "running_vms": 0,
   195              "service": {
   196                  "host": "e6a37ee802d74863ab8b91ade8f12a67",
   197                  "id": "9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   198                  "disabled_reason": null
   199              },
   200              "servers": [
   201                  {
   202                      "name": "instance-00000001",
   203                      "uuid": "c42acc8d-eab3-4e4d-9d90-01b0791328f4"
   204                  },
   205                  {
   206                      "name": "instance-00000002",
   207                      "uuid": "8aaf2941-b774-41fc-921b-20c4757cc359"
   208                  }
   209              ],
   210              "vcpus": 1,
   211              "vcpus_used": 0
   212          },
   213          {
   214              "cpu_info": "{\"arch\": \"x86_64\", \"model\": \"Nehalem\", \"vendor\": \"Intel\", \"features\": [\"pge\", \"clflush\"], \"topology\": {\"cores\": 1, \"threads\": 1, \"sockets\": 4}}",
   215              "current_workload": 0,
   216              "status": "enabled",
   217              "state": "up",
   218              "disk_available_least": 0,
   219              "host_ip": "1.1.1.1",
   220              "free_disk_gb": 1028,
   221              "free_ram_mb": 7680,
   222              "hypervisor_hostname": "fake-mini",
   223              "hypervisor_type": "fake",
   224              "hypervisor_version": 2.002e+06,
   225              "id": "c48f6247-abe4-4a24-824e-ea39e108874f",
   226              "local_gb": 1028,
   227              "local_gb_used": 0,
   228              "memory_mb": 8192,
   229              "memory_mb_used": 512,
   230              "running_vms": 0,
   231              "servers": [
   232                  {
   233                      "name": "instance-00000001",
   234                      "uuid": "c42acc8d-eab3-4e4d-9d90-01b0791328f4"
   235                  },
   236                  {
   237                      "name": "instance-00000002",
   238                      "uuid": "8aaf2941-b774-41fc-921b-20c4757cc359"
   239                  }
   240              ],
   241              "service": {
   242                  "host": "e6a37ee802d74863ab8b91ade8f12a67",
   243                  "id": "9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   244                  "disabled_reason": null
   245              },
   246              "vcpus": 1,
   247              "vcpus_used": 0
   248          }
   249      ]
   250  }`
   251  
   252  const HypervisorsStatisticsBody = `
   253  {
   254      "hypervisor_statistics": {
   255          "count": 1,
   256          "current_workload": 0,
   257          "disk_available_least": 0,
   258          "free_disk_gb": 1028,
   259          "free_ram_mb": 7680,
   260          "local_gb": 1028,
   261          "local_gb_used": 0,
   262          "memory_mb": 8192,
   263          "memory_mb_used": 512,
   264          "running_vms": 0,
   265          "vcpus": 2,
   266          "vcpus_used": 0
   267      }
   268  }
   269  `
   270  
   271  // HypervisorGetBody represents a raw hypervisor GET result with Pike+ release.
   272  const HypervisorGetBody = `
   273  {
   274      "hypervisor":{
   275          "cpu_info":{
   276              "arch":"x86_64",
   277              "model":"Nehalem",
   278              "vendor":"Intel",
   279              "features":[
   280                  "pge",
   281                  "clflush"
   282              ],
   283              "topology":{
   284                  "cores":1,
   285                  "threads":1,
   286                  "sockets":4
   287              }
   288          },
   289          "current_workload":0,
   290          "status":"enabled",
   291          "state":"up",
   292          "disk_available_least":0,
   293          "host_ip":"1.1.1.1",
   294          "free_disk_gb":1028,
   295          "free_ram_mb":7680,
   296          "hypervisor_hostname":"fake-mini",
   297          "hypervisor_type":"fake",
   298          "hypervisor_version":2002000,
   299          "id":"c48f6247-abe4-4a24-824e-ea39e108874f",
   300          "local_gb":1028,
   301          "local_gb_used":0,
   302          "memory_mb":8192,
   303          "memory_mb_used":512,
   304          "running_vms":0,
   305          "service":{
   306              "host":"e6a37ee802d74863ab8b91ade8f12a67",
   307              "id":"9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   308              "disabled_reason":null
   309          },
   310          "vcpus":1,
   311          "vcpus_used":0
   312      }
   313  }
   314  `
   315  
   316  // HypervisorGetEmptyCPUInfoBody represents a raw hypervisor GET result with
   317  // no cpu_info
   318  const HypervisorGetEmptyCPUInfoBody = `
   319  {
   320      "hypervisor":{
   321          "cpu_info": "",
   322          "current_workload":0,
   323          "status":"enabled",
   324          "state":"up",
   325          "disk_available_least":0,
   326          "host_ip":"1.1.1.1",
   327          "free_disk_gb":1028,
   328          "free_ram_mb":7680,
   329          "hypervisor_hostname":"fake-mini",
   330          "hypervisor_type":"fake",
   331          "hypervisor_version":2002000,
   332          "id":"c48f6247-abe4-4a24-824e-ea39e108874f",
   333          "local_gb":1028,
   334          "local_gb_used":0,
   335          "memory_mb":8192,
   336          "memory_mb_used":512,
   337          "running_vms":0,
   338          "service":{
   339              "host":"e6a37ee802d74863ab8b91ade8f12a67",
   340              "id":"9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   341              "disabled_reason":null
   342          },
   343          "vcpus":1,
   344          "vcpus_used":0
   345      }
   346  }
   347  `
   348  
   349  // HypervisorAfterV287ResponseBody represents a raw hypervisor GET result with
   350  // missing cpu_info, free_disk_gb, local_gb as seen after v2.87
   351  const HypervisorAfterV287ResponseBody = `
   352  {
   353      "hypervisor":{
   354          "current_workload":0,
   355          "status":"enabled",
   356          "state":"up",
   357          "disk_available_least":0,
   358          "host_ip":"1.1.1.1",
   359          "free_ram_mb":7680,
   360          "hypervisor_hostname":"fake-mini",
   361          "hypervisor_type":"fake",
   362          "hypervisor_version":2002000,
   363          "id":"c48f6247-abe4-4a24-824e-ea39e108874f",
   364          "local_gb_used":0,
   365          "memory_mb":8192,
   366          "memory_mb_used":512,
   367          "running_vms":0,
   368          "service":{
   369              "host":"e6a37ee802d74863ab8b91ade8f12a67",
   370              "id":"9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   371              "disabled_reason":null
   372          },
   373          "vcpus":1,
   374          "vcpus_used":0
   375      }
   376  }
   377  `
   378  
   379  // HypervisorUptimeBody represents a raw hypervisor uptime request result with
   380  // Pike+ release.
   381  const HypervisorUptimeBody = `
   382  {
   383      "hypervisor": {
   384          "hypervisor_hostname": "fake-mini",
   385          "id": "c48f6247-abe4-4a24-824e-ea39e108874f",
   386          "state": "up",
   387          "status": "enabled",
   388          "uptime": " 08:32:11 up 93 days, 18:25, 12 users,  load average: 0.20, 0.12, 0.14"
   389      }
   390  }
   391  `
   392  
   393  var (
   394  	HypervisorFakePre253 = hypervisors.Hypervisor{
   395  		CPUInfo: hypervisors.CPUInfo{
   396  			Arch:   "x86_64",
   397  			Model:  "Nehalem",
   398  			Vendor: "Intel",
   399  			Features: []string{
   400  				"pge",
   401  				"clflush",
   402  			},
   403  			Topology: hypervisors.Topology{
   404  				Cores:   1,
   405  				Threads: 1,
   406  				Sockets: 4,
   407  			},
   408  		},
   409  		CurrentWorkload:    0,
   410  		Status:             "enabled",
   411  		State:              "up",
   412  		DiskAvailableLeast: 0,
   413  		HostIP:             "1.1.1.1",
   414  		FreeDiskGB:         1028,
   415  		FreeRamMB:          7680,
   416  		HypervisorHostname: "fake-mini",
   417  		HypervisorType:     "fake",
   418  		HypervisorVersion:  2002000,
   419  		ID:                 "1",
   420  		LocalGB:            1028,
   421  		LocalGBUsed:        0,
   422  		MemoryMB:           8192,
   423  		MemoryMBUsed:       512,
   424  		RunningVMs:         0,
   425  		Service: hypervisors.Service{
   426  			Host:           "e6a37ee802d74863ab8b91ade8f12a67",
   427  			ID:             "2",
   428  			DisabledReason: "",
   429  		},
   430  		VCPUs:     1,
   431  		VCPUsUsed: 0,
   432  	}
   433  
   434  	HypervisorFake = hypervisors.Hypervisor{
   435  		CPUInfo: hypervisors.CPUInfo{
   436  			Arch:   "x86_64",
   437  			Model:  "Nehalem",
   438  			Vendor: "Intel",
   439  			Features: []string{
   440  				"pge",
   441  				"clflush",
   442  			},
   443  			Topology: hypervisors.Topology{
   444  				Cores:   1,
   445  				Threads: 1,
   446  				Sockets: 4,
   447  			},
   448  		},
   449  		CurrentWorkload:    0,
   450  		Status:             "enabled",
   451  		State:              "up",
   452  		DiskAvailableLeast: 0,
   453  		HostIP:             "1.1.1.1",
   454  		FreeDiskGB:         1028,
   455  		FreeRamMB:          7680,
   456  		HypervisorHostname: "fake-mini",
   457  		HypervisorType:     "fake",
   458  		HypervisorVersion:  2002000,
   459  		ID:                 "c48f6247-abe4-4a24-824e-ea39e108874f",
   460  		LocalGB:            1028,
   461  		LocalGBUsed:        0,
   462  		MemoryMB:           8192,
   463  		MemoryMBUsed:       512,
   464  		RunningVMs:         0,
   465  		Service: hypervisors.Service{
   466  			Host:           "e6a37ee802d74863ab8b91ade8f12a67",
   467  			ID:             "9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   468  			DisabledReason: "",
   469  		},
   470  		VCPUs:     1,
   471  		VCPUsUsed: 0,
   472  	}
   473  
   474  	HypervisorFakeWithParameters = hypervisors.Hypervisor{
   475  		CPUInfo: hypervisors.CPUInfo{
   476  			Arch:   "x86_64",
   477  			Model:  "Nehalem",
   478  			Vendor: "Intel",
   479  			Features: []string{
   480  				"pge",
   481  				"clflush",
   482  			},
   483  			Topology: hypervisors.Topology{
   484  				Cores:   1,
   485  				Threads: 1,
   486  				Sockets: 4,
   487  			},
   488  		},
   489  		CurrentWorkload:    0,
   490  		Status:             "enabled",
   491  		State:              "up",
   492  		DiskAvailableLeast: 0,
   493  		HostIP:             "1.1.1.1",
   494  		FreeDiskGB:         1028,
   495  		FreeRamMB:          7680,
   496  		HypervisorHostname: "fake-mini",
   497  		HypervisorType:     "fake",
   498  		HypervisorVersion:  2002000,
   499  		ID:                 "c48f6247-abe4-4a24-824e-ea39e108874f",
   500  		LocalGB:            1028,
   501  		LocalGBUsed:        0,
   502  		MemoryMB:           8192,
   503  		MemoryMBUsed:       512,
   504  		RunningVMs:         0,
   505  		Service: hypervisors.Service{
   506  			Host:           "e6a37ee802d74863ab8b91ade8f12a67",
   507  			ID:             "9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   508  			DisabledReason: "",
   509  		},
   510  		Servers: &[]hypervisors.Server{
   511  			{
   512  				Name: "instance-00000001",
   513  				UUID: "c42acc8d-eab3-4e4d-9d90-01b0791328f4",
   514  			},
   515  			{
   516  				Name: "instance-00000002",
   517  				UUID: "8aaf2941-b774-41fc-921b-20c4757cc359",
   518  			},
   519  		},
   520  		VCPUs:     1,
   521  		VCPUsUsed: 0,
   522  	}
   523  
   524  	HypervisorEmptyCPUInfo = hypervisors.Hypervisor{
   525  		CPUInfo:            hypervisors.CPUInfo{},
   526  		CurrentWorkload:    0,
   527  		Status:             "enabled",
   528  		State:              "up",
   529  		DiskAvailableLeast: 0,
   530  		HostIP:             "1.1.1.1",
   531  		FreeDiskGB:         1028,
   532  		FreeRamMB:          7680,
   533  		HypervisorHostname: "fake-mini",
   534  		HypervisorType:     "fake",
   535  		HypervisorVersion:  2002000,
   536  		ID:                 "c48f6247-abe4-4a24-824e-ea39e108874f",
   537  		LocalGB:            1028,
   538  		LocalGBUsed:        0,
   539  		MemoryMB:           8192,
   540  		MemoryMBUsed:       512,
   541  		RunningVMs:         0,
   542  		Service: hypervisors.Service{
   543  			Host:           "e6a37ee802d74863ab8b91ade8f12a67",
   544  			ID:             "9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   545  			DisabledReason: "",
   546  		},
   547  		VCPUs:     1,
   548  		VCPUsUsed: 0,
   549  	}
   550  
   551  	HypervisorAfterV287Response = hypervisors.Hypervisor{
   552  		CPUInfo:            hypervisors.CPUInfo{},
   553  		CurrentWorkload:    0,
   554  		Status:             "enabled",
   555  		State:              "up",
   556  		DiskAvailableLeast: 0,
   557  		HostIP:             "1.1.1.1",
   558  		FreeDiskGB:         0,
   559  		FreeRamMB:          7680,
   560  		HypervisorHostname: "fake-mini",
   561  		HypervisorType:     "fake",
   562  		HypervisorVersion:  2002000,
   563  		ID:                 "c48f6247-abe4-4a24-824e-ea39e108874f",
   564  		LocalGB:            0,
   565  		LocalGBUsed:        0,
   566  		MemoryMB:           8192,
   567  		MemoryMBUsed:       512,
   568  		RunningVMs:         0,
   569  		Service: hypervisors.Service{
   570  			Host:           "e6a37ee802d74863ab8b91ade8f12a67",
   571  			ID:             "9c2566e7-7a54-4777-a1ae-c2662f0c407c",
   572  			DisabledReason: "",
   573  		},
   574  		VCPUs:     1,
   575  		VCPUsUsed: 0,
   576  	}
   577  
   578  	HypervisorsStatisticsExpected = hypervisors.Statistics{
   579  		Count:              1,
   580  		CurrentWorkload:    0,
   581  		DiskAvailableLeast: 0,
   582  		FreeDiskGB:         1028,
   583  		FreeRamMB:          7680,
   584  		LocalGB:            1028,
   585  		LocalGBUsed:        0,
   586  		MemoryMB:           8192,
   587  		MemoryMBUsed:       512,
   588  		RunningVMs:         0,
   589  		VCPUs:              2,
   590  		VCPUsUsed:          0,
   591  	}
   592  
   593  	HypervisorUptimeExpected = hypervisors.Uptime{
   594  		HypervisorHostname: "fake-mini",
   595  		ID:                 "c48f6247-abe4-4a24-824e-ea39e108874f",
   596  		State:              "up",
   597  		Status:             "enabled",
   598  		Uptime:             " 08:32:11 up 93 days, 18:25, 12 users,  load average: 0.20, 0.12, 0.14",
   599  	}
   600  )
   601  
   602  func HandleHypervisorsStatisticsSuccessfully(t *testing.T) {
   603  	th.Mux.HandleFunc("/os-hypervisors/statistics", func(w http.ResponseWriter, r *http.Request) {
   604  		th.TestMethod(t, r, "GET")
   605  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   606  
   607  		w.Header().Add("Content-Type", "application/json")
   608  		fmt.Fprint(w, HypervisorsStatisticsBody)
   609  	})
   610  }
   611  
   612  func HandleHypervisorListPre253Successfully(t *testing.T) {
   613  	th.Mux.HandleFunc("/os-hypervisors/detail", func(w http.ResponseWriter, r *http.Request) {
   614  		th.TestMethod(t, r, "GET")
   615  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   616  
   617  		w.Header().Add("Content-Type", "application/json")
   618  		fmt.Fprint(w, HypervisorListBodyPre253)
   619  	})
   620  }
   621  
   622  func HandleHypervisorListSuccessfully(t *testing.T) {
   623  	th.Mux.HandleFunc("/os-hypervisors/detail", func(w http.ResponseWriter, r *http.Request) {
   624  		th.TestMethod(t, r, "GET")
   625  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   626  
   627  		w.Header().Add("Content-Type", "application/json")
   628  		fmt.Fprint(w, HypervisorListBody)
   629  	})
   630  }
   631  
   632  func HandleHypervisorListWithParametersSuccessfully(t *testing.T) {
   633  	th.Mux.HandleFunc("/os-hypervisors/detail", func(w http.ResponseWriter, r *http.Request) {
   634  		th.TestMethod(t, r, "GET")
   635  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   636  		th.TestFormValues(t, r, map[string]string{
   637  			"with_servers": "true",
   638  		})
   639  
   640  		w.Header().Add("Content-Type", "application/json")
   641  		fmt.Fprint(w, HypervisorListWithParametersBody)
   642  	})
   643  }
   644  
   645  func HandleHypervisorGetSuccessfully(t *testing.T) {
   646  	th.Mux.HandleFunc("/os-hypervisors/"+HypervisorFake.ID, func(w http.ResponseWriter, r *http.Request) {
   647  		th.TestMethod(t, r, "GET")
   648  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   649  
   650  		w.Header().Add("Content-Type", "application/json")
   651  		fmt.Fprint(w, HypervisorGetBody)
   652  	})
   653  }
   654  
   655  func HandleHypervisorGetEmptyCPUInfoSuccessfully(t *testing.T) {
   656  	th.Mux.HandleFunc("/os-hypervisors/"+HypervisorFake.ID, func(w http.ResponseWriter, r *http.Request) {
   657  		th.TestMethod(t, r, "GET")
   658  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   659  
   660  		w.Header().Add("Content-Type", "application/json")
   661  		fmt.Fprint(w, HypervisorGetEmptyCPUInfoBody)
   662  	})
   663  }
   664  
   665  func HandleHypervisorAfterV287ResponseSuccessfully(t *testing.T) {
   666  	th.Mux.HandleFunc("/os-hypervisors/"+HypervisorFake.ID, func(w http.ResponseWriter, r *http.Request) {
   667  		th.TestMethod(t, r, "GET")
   668  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   669  
   670  		w.Header().Add("Content-Type", "application/json")
   671  		fmt.Fprint(w, HypervisorAfterV287ResponseBody)
   672  	})
   673  }
   674  
   675  func HandleHypervisorUptimeSuccessfully(t *testing.T) {
   676  	th.Mux.HandleFunc("/os-hypervisors/"+HypervisorFake.ID+"/uptime", func(w http.ResponseWriter, r *http.Request) {
   677  		th.TestMethod(t, r, "GET")
   678  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
   679  
   680  		w.Header().Add("Content-Type", "application/json")
   681  		fmt.Fprint(w, HypervisorUptimeBody)
   682  	})
   683  }