You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
696 lines
25 KiB
696 lines
25 KiB
package test
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/account"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/bservice"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/compute"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/disks"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/extnet"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/flipgroup"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/image"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8ci"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/lb"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/locations"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/rg"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/stack"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/tasks"
|
|
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/vins"
|
|
|
|
account_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/account"
|
|
audit_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/audit"
|
|
compute_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/compute"
|
|
disks_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/disks"
|
|
extnet_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/extnet"
|
|
flipgroup_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/flipgroup"
|
|
grid_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/grid"
|
|
image_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/image"
|
|
k8ci_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8ci"
|
|
k8s_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s"
|
|
lb_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/lb"
|
|
pcidevice_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/pcidevice"
|
|
rg_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/rg"
|
|
sep_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/sep"
|
|
stack_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/stack"
|
|
tasks_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/tasks"
|
|
vins_cb "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/vins"
|
|
)
|
|
|
|
// TestGetListCloudAPI tests platforms responses vs. json tags of golang structures in cloudapi get/list methods
|
|
func TestGetListCloudAPI(t *testing.T) {
|
|
var bytes []byte
|
|
var err error
|
|
client, err := getClient()
|
|
if err != nil {
|
|
t.Fatalf("Cannot get client: %v", err)
|
|
}
|
|
|
|
const logFileName = "test_get_list_cloudAPI.log"
|
|
var testLogs []string
|
|
// Account
|
|
// List
|
|
bytes, err = client.CloudAPI().Account().ListRaw(context.Background(), account.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
testLogs = append(testLogs, getResult("Account list", bytes, account.ListAccounts{}, t))
|
|
// Get
|
|
listAcc, _ := client.CloudAPI().Account().List(context.Background(), account.ListRequest{})
|
|
if len(listAcc.Data) > 0 {
|
|
id := listAcc.Data[0].ID
|
|
bytes, err = client.CloudAPI().Account().GetRaw(context.Background(), account.GetRequest{AccountID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Account get", bytes, account.RecordAccount{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Account get because account list is empty")
|
|
}
|
|
|
|
// Bservice
|
|
// List
|
|
bytes, err = client.CloudAPI().BService().ListRaw(context.Background(), bservice.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Bservice list", bytes, bservice.ListBasicServices{}, t))
|
|
// Get
|
|
listBServ, _ := client.CloudAPI().BService().List(context.Background(), bservice.ListRequest{})
|
|
if len(listBServ.Data) > 0 {
|
|
id := listBServ.Data[0].ID
|
|
bytes, err = client.CloudAPI().BService().GetRaw(context.Background(), bservice.GetRequest{ServiceID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Bservice get", bytes, bservice.RecordBasicService{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Bservice get because bservice list is empty")
|
|
}
|
|
|
|
// Compute
|
|
// List
|
|
bytes, err = client.CloudAPI().Compute().ListRaw(context.Background(), compute.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Compute list", bytes, compute.ListComputes{}, t))
|
|
// Get
|
|
listComp, _ := client.CloudAPI().Compute().List(context.Background(), compute.ListRequest{})
|
|
if len(listComp.Data) > 0 {
|
|
id := listComp.Data[0].ID
|
|
bytes, err = client.CloudAPI().Compute().GetRaw(context.Background(), compute.GetRequest{ComputeID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Compute get", bytes, compute.RecordCompute{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Compute get because compute list is empty")
|
|
}
|
|
|
|
// Disk
|
|
// List
|
|
bytes, err = client.CloudAPI().Disks().ListRaw(context.Background(), disks.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Disk list", bytes, disks.ListDisks{}, t))
|
|
// Get
|
|
listDisk, _ := client.CloudAPI().Disks().List(context.Background(), disks.ListRequest{})
|
|
if len(listDisk.Data) > 0 {
|
|
id := listDisk.Data[0].ID
|
|
bytes, err = client.CloudAPI().Disks().GetRaw(context.Background(), disks.GetRequest{DiskID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Disk get", bytes, disks.RecordDisk{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Disk get because disk list is empty")
|
|
}
|
|
|
|
// ExtNet
|
|
// List
|
|
bytes, err = client.CloudAPI().ExtNet().ListRaw(context.Background(), extnet.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("ExtNet list", bytes, extnet.ListExtNets{}, t))
|
|
// Get
|
|
listExtNet, _ := client.CloudAPI().ExtNet().List(context.Background(), extnet.ListRequest{})
|
|
if len(listExtNet.Data) > 0 {
|
|
id := listExtNet.Data[0].ID
|
|
bytes, err = client.CloudAPI().ExtNet().GetRaw(context.Background(), extnet.GetRequest{NetID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("ExtNet get", bytes, extnet.RecordExtNet{}, t))
|
|
} else {
|
|
t.Errorf("Can not test ExtNet get because listExtNet list is empty")
|
|
}
|
|
|
|
// FLIPGroup
|
|
// List
|
|
bytes, err = client.CloudAPI().FLIPGroup().ListRaw(context.Background(), flipgroup.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("FLIPGroup list", bytes, flipgroup.ListFLIPGroups{}, t))
|
|
// Get
|
|
listFG, _ := client.CloudAPI().FLIPGroup().List(context.Background(), flipgroup.ListRequest{})
|
|
if len(listFG.Data) > 0 {
|
|
id := listFG.Data[0].ID
|
|
bytes, err = client.CloudAPI().FLIPGroup().GetRaw(context.Background(), flipgroup.GetRequest{FLIPGroupID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("FLIPGroup get", bytes, flipgroup.RecordFLIPGroup{}, t))
|
|
} else {
|
|
t.Errorf("Can not test FLIPGroup get because flipgroup list is empty")
|
|
}
|
|
|
|
// Image
|
|
// List
|
|
bytes, err = client.CloudAPI().Image().ListRaw(context.Background(), image.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Image list", bytes, image.ListImages{}, t))
|
|
// Get
|
|
listImg, _ := client.CloudAPI().Image().List(context.Background(), image.ListRequest{})
|
|
if len(listImg.Data) > 0 {
|
|
id := listImg.Data[0].ID
|
|
bytes, err = client.CloudAPI().Image().GetRaw(context.Background(), image.GetRequest{ImageID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Image get", bytes, image.RecordImage{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Image get because Image list is empty")
|
|
}
|
|
|
|
// K8CI
|
|
// List
|
|
bytes, err = client.CloudAPI().K8CI().ListRaw(context.Background(), k8ci.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("K8CI list", bytes, k8ci.ListK8CI{}, t))
|
|
// Get
|
|
listk8ci, _ := client.CloudAPI().K8CI().List(context.Background(), k8ci.ListRequest{})
|
|
if len(listk8ci.Data) > 0 {
|
|
id := listk8ci.Data[0].ID
|
|
bytes, err = client.CloudAPI().K8CI().GetRaw(context.Background(), k8ci.GetRequest{K8CIID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("K8CI get", bytes, k8ci.RecordK8CI{}, t))
|
|
} else {
|
|
t.Errorf("Can not test K8CI get because K8CI list is empty")
|
|
}
|
|
|
|
// K8S
|
|
// List
|
|
bytes, err = client.CloudAPI().K8S().ListRaw(context.Background(), k8s.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("K8S list", bytes, k8s.ListK8SClusters{}, t))
|
|
// Get
|
|
listk8s, _ := client.CloudAPI().K8S().List(context.Background(), k8s.ListRequest{})
|
|
if len(listk8s.Data) > 0 {
|
|
id := listk8s.Data[0].ID
|
|
bytes, err = client.CloudAPI().K8S().GetRaw(context.Background(), k8s.GetRequest{K8SID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("K8S get", bytes, k8s.RecordK8S{}, t))
|
|
} else {
|
|
t.Errorf("Can not test K8S get because K8S list is empty")
|
|
}
|
|
|
|
// LB
|
|
// List
|
|
bytes, err = client.CloudAPI().LB().ListRaw(context.Background(), lb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("LB list", bytes, lb.ListLB{}, t))
|
|
// Get
|
|
listLB, _ := client.CloudAPI().LB().List(context.Background(), lb.ListRequest{})
|
|
if len(listLB.Data) > 0 {
|
|
id := listLB.Data[0].ID
|
|
bytes, err = client.CloudAPI().LB().GetRaw(context.Background(), lb.GetRequest{LBID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("LB get", bytes, lb.RecordLB{}, t))
|
|
} else {
|
|
t.Errorf("Can not test LB get because LB list is empty")
|
|
}
|
|
|
|
// Locations
|
|
// List
|
|
bytes, err = client.CloudAPI().Locations().ListRaw(context.Background(), locations.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Locations list", bytes, locations.ListLocations{}, t))
|
|
|
|
// RG
|
|
// List
|
|
bytes, err = client.CloudAPI().RG().ListRaw(context.Background(), rg.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("RG list", bytes, rg.ListResourceGroups{}, t))
|
|
// Get
|
|
listRG, _ := client.CloudAPI().RG().List(context.Background(), rg.ListRequest{})
|
|
if len(listRG.Data) > 0 {
|
|
id := listRG.Data[0].ID
|
|
bytes, err = client.CloudAPI().RG().GetRaw(context.Background(), rg.GetRequest{RGID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("RG get", bytes, rg.RecordResourceGroup{}, t))
|
|
} else {
|
|
t.Errorf("Can not test RG get because RG list is empty")
|
|
}
|
|
|
|
// Stack
|
|
// List
|
|
bytes, err = client.CloudAPI().Stack().ListRaw(context.Background(), stack.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Stack list", bytes, stack.ListStacks{}, t))
|
|
|
|
// Tasks
|
|
// List
|
|
bytes, err = client.CloudAPI().Tasks().ListRaw(context.Background(), tasks.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Tasks list", bytes, tasks.ListTasks{}, t))
|
|
// Get
|
|
listTasks, _ := client.CloudAPI().Tasks().List(context.Background(), tasks.ListRequest{})
|
|
if len(listTasks.Data) > 0 {
|
|
id := listTasks.Data[0].AuditID
|
|
bytes, err = client.CloudAPI().Tasks().GetRaw(context.Background(), tasks.GetRequest{AuditID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Tasks get", bytes, tasks.RecordAsyncTask{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Tasks get because Tasks list is empty")
|
|
}
|
|
|
|
// VINS
|
|
// List
|
|
bytes, err = client.CloudAPI().VINS().ListRaw(context.Background(), vins.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("VINS list", bytes, vins.ListVINS{}, t))
|
|
// Get
|
|
listVINS, _ := client.CloudAPI().VINS().List(context.Background(), vins.ListRequest{})
|
|
if len(listVINS.Data) > 0 {
|
|
id := listVINS.Data[0].ID
|
|
bytes, err = client.CloudAPI().VINS().GetRaw(context.Background(), vins.GetRequest{VINSID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("VINS get", bytes, vins.RecordVINS{}, t))
|
|
} else {
|
|
t.Errorf("Can not test VINS get because VINS list is empty")
|
|
}
|
|
|
|
compareLogs(logFileName, testLogs, t, "get")
|
|
}
|
|
|
|
// WARNING: not working correctly due to inclusions of tagless structures in cloudbroker
|
|
// TestGetListCloudbroker tests platforms responses vs. json tags of golang structures in cloudbroker get/list methods
|
|
func TestGetListCloudbroker(t *testing.T) {
|
|
var bytes []byte
|
|
var err error
|
|
client, err := getClient()
|
|
if err != nil {
|
|
t.Fatalf("Cannot get client: %v", err)
|
|
}
|
|
|
|
const logFileName = "test_get_list_cloudbroker.log"
|
|
var testLogs = make([]string, 0)
|
|
// Account
|
|
// List
|
|
bytes, err = client.CloudBroker().Account().ListRaw(context.Background(), account_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Account list", bytes, account_cb.ListAccounts{}, t))
|
|
// Get
|
|
listAcc, _ := client.CloudBroker().Account().List(context.Background(), account_cb.ListRequest{})
|
|
if len(listAcc.Data) > 0 {
|
|
id := listAcc.Data[0].ID
|
|
bytes, err = client.CloudBroker().Account().GetRaw(context.Background(), account_cb.GetRequest{AccountID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Account get", bytes, account_cb.RecordAccount{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Account get because account list is empty")
|
|
}
|
|
|
|
// Audit
|
|
// List
|
|
bytes, err = client.CloudBroker().Audit().ListRaw(context.Background(), audit_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Audit list", bytes, audit_cb.ListAudits{}, t))
|
|
// Get
|
|
listAudits, _ := client.CloudBroker().Audit().List(context.Background(), audit_cb.ListRequest{})
|
|
if len(listAudits.Data) > 0 {
|
|
id := listAudits.Data[0].GUID
|
|
bytes, err = client.CloudBroker().Audit().GetRaw(context.Background(), audit_cb.GetRequest{AuditGuid: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Audit get", bytes, audit_cb.RecordAudit{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Audit get because Audit list is empty")
|
|
}
|
|
|
|
// Compute
|
|
// List
|
|
bytes, err = client.CloudBroker().Compute().ListRaw(context.Background(), compute_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Compute list", bytes, compute_cb.ListComputes{}, t))
|
|
// Get
|
|
listComp, _ := client.CloudBroker().Compute().List(context.Background(), compute_cb.ListRequest{})
|
|
if len(listComp.Data) > 0 {
|
|
id := listComp.Data[0].ID
|
|
bytes, err = client.CloudBroker().Compute().GetRaw(context.Background(), compute_cb.GetRequest{ComputeID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Compute get", bytes, compute_cb.RecordCompute{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Compute get because compute list is empty")
|
|
}
|
|
|
|
// Disk
|
|
// List
|
|
bytes, err = client.CloudBroker().Disks().ListRaw(context.Background(), disks_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Disk list", bytes, disks_cb.ListDisks{}, t))
|
|
// Get
|
|
listDisk, _ := client.CloudBroker().Disks().List(context.Background(), disks_cb.ListRequest{})
|
|
if len(listDisk.Data) > 0 {
|
|
id := listDisk.Data[0].ID
|
|
bytes, err = client.CloudBroker().Disks().GetRaw(context.Background(), disks_cb.GetRequest{DiskID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Disk get", bytes, disks_cb.RecordDisk{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Disk get because disk list is empty")
|
|
}
|
|
|
|
// ExtNet
|
|
// List
|
|
bytes, err = client.CloudBroker().ExtNet().ListRaw(context.Background(), extnet_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("ExtNet list", bytes, extnet_cb.ListExtNet{}, t))
|
|
// Get
|
|
listExtNet, _ := client.CloudBroker().ExtNet().List(context.Background(), extnet_cb.ListRequest{})
|
|
if len(listExtNet.Data) > 0 {
|
|
id := listExtNet.Data[0].ID
|
|
bytes, err = client.CloudBroker().ExtNet().GetRaw(context.Background(), extnet_cb.GetRequest{NetID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("ExtNet get", bytes, extnet_cb.RecordExtNet{}, t))
|
|
} else {
|
|
t.Errorf("Can not test ExtNet get because listExtNet list is empty")
|
|
}
|
|
|
|
// FLIPGroup
|
|
// List
|
|
bytes, err = client.CloudBroker().FLIPGroup().ListRaw(context.Background(), flipgroup_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("FLIPGroup list", bytes, flipgroup_cb.ListFLIPGroups{}, t))
|
|
// Get
|
|
listFG, _ := client.CloudBroker().FLIPGroup().List(context.Background(), flipgroup_cb.ListRequest{})
|
|
if len(listFG.Data) > 0 {
|
|
id := listFG.Data[0].ID
|
|
bytes, err = client.CloudBroker().FLIPGroup().GetRaw(context.Background(), flipgroup_cb.GetRequest{FLIPGroupID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("FLIPGroup get", bytes, flipgroup_cb.RecordFLIPGroup{}, t))
|
|
} else {
|
|
t.Errorf("Can not test FLIPGroup get because flipgroup list is empty")
|
|
}
|
|
|
|
// Grid
|
|
// List
|
|
bytes, err = client.CloudBroker().Grid().ListRaw(context.Background(), grid_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Grid list", bytes, grid_cb.ListGrids{}, t))
|
|
// Get
|
|
listGrid, _ := client.CloudBroker().Grid().List(context.Background(), grid_cb.ListRequest{})
|
|
if len(listGrid.Data) > 0 {
|
|
id := listGrid.Data[0].ID
|
|
bytes, err = client.CloudBroker().Grid().GetRaw(context.Background(), grid_cb.GetRequest{GID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Grid get", bytes, grid_cb.RecordGrid{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Grid get because Grid list is empty")
|
|
}
|
|
|
|
// Image
|
|
// List
|
|
bytes, err = client.CloudBroker().Image().ListRaw(context.Background(), image_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Image list", bytes, image_cb.ListImages{}, t))
|
|
// Get
|
|
listImg, _ := client.CloudBroker().Image().List(context.Background(), image_cb.ListRequest{})
|
|
if len(listImg.Data) > 0 {
|
|
id := listImg.Data[0].ID
|
|
bytes, err = client.CloudBroker().Image().GetRaw(context.Background(), image_cb.GetRequest{ImageID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Image get", bytes, image_cb.RecordImage{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Image get because Image list is empty")
|
|
}
|
|
|
|
// K8CI
|
|
// List
|
|
bytes, err = client.CloudBroker().K8CI().ListRaw(context.Background(), k8ci_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("K8CI list", bytes, k8ci_cb.ListK8CI{}, t))
|
|
// Get
|
|
listk8ci, _ := client.CloudBroker().K8CI().List(context.Background(), k8ci_cb.ListRequest{})
|
|
if len(listk8ci.Data) > 0 {
|
|
id := listk8ci.Data[0].ID
|
|
bytes, err = client.CloudBroker().K8CI().GetRaw(context.Background(), k8ci_cb.GetRequest{K8CIID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("K8CI get", bytes, k8ci_cb.RecordK8CI{}, t))
|
|
} else {
|
|
t.Errorf("Can not test K8CI get because K8CI list is empty")
|
|
}
|
|
|
|
// K8S
|
|
// List
|
|
bytes, err = client.CloudBroker().K8S().ListRaw(context.Background(), k8s_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("K8S list", bytes, k8s_cb.ListK8S{}, t))
|
|
// Get
|
|
listk8s, _ := client.CloudBroker().K8S().List(context.Background(), k8s_cb.ListRequest{})
|
|
if len(listk8s.Data) > 0 {
|
|
id := listk8s.Data[0].ID
|
|
bytes, err = client.CloudBroker().K8S().GetRaw(context.Background(), k8s_cb.GetRequest{K8SID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("K8S get", bytes, k8s_cb.RecordK8S{}, t))
|
|
} else {
|
|
t.Errorf("Can not test K8S get because K8S list is empty")
|
|
}
|
|
|
|
// LB
|
|
// List
|
|
bytes, err = client.CloudBroker().LB().ListRaw(context.Background(), lb_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("LB list", bytes, lb_cb.ListLB{}, t))
|
|
// Get
|
|
listLB, _ := client.CloudBroker().LB().List(context.Background(), lb_cb.ListRequest{})
|
|
if len(listLB.Data) > 0 {
|
|
id := listLB.Data[0].ID
|
|
bytes, err = client.CloudBroker().LB().GetRaw(context.Background(), lb_cb.GetRequest{LBID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("LB get", bytes, lb_cb.RecordLB{}, t))
|
|
} else {
|
|
t.Errorf("Can not test LB get because LB list is empty")
|
|
}
|
|
|
|
// Pcidevice
|
|
// List
|
|
bytes, err = client.CloudBroker().PCIDevice().ListRaw(context.Background(), pcidevice_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Pcidevice list", bytes, pcidevice_cb.ListPCIDevices{}, t))
|
|
|
|
// RG
|
|
// List
|
|
bytes, err = client.CloudBroker().RG().ListRaw(context.Background(), rg_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("RG list", bytes, rg_cb.ListRG{}, t))
|
|
// Get
|
|
listRG, _ := client.CloudBroker().RG().List(context.Background(), rg_cb.ListRequest{})
|
|
if len(listRG.Data) > 0 {
|
|
id := listRG.Data[0].ID
|
|
bytes, err = client.CloudBroker().RG().GetRaw(context.Background(), rg_cb.GetRequest{RGID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("RG get", bytes, rg_cb.RecordRG{}, t))
|
|
} else {
|
|
t.Errorf("Can not test RG get because RG list is empty")
|
|
}
|
|
|
|
// SEP
|
|
// List
|
|
bytes, err = client.CloudBroker().SEP().ListRaw(context.Background(), sep_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("SEP list", bytes, sep_cb.ListSEP{}, t))
|
|
// Get
|
|
listSEP, _ := client.CloudBroker().SEP().List(context.Background(), sep_cb.ListRequest{})
|
|
if len(listSEP.Data) > 0 {
|
|
id := listSEP.Data[0].ID
|
|
bytes, err = client.CloudBroker().SEP().GetRaw(context.Background(), sep_cb.GetRequest{SEPID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("SEP get", bytes, sep_cb.RecordSEP{}, t))
|
|
} else {
|
|
t.Errorf("Can not test SEP get because SEP list is empty")
|
|
}
|
|
|
|
// Stack
|
|
// List
|
|
bytes, err = client.CloudBroker().Stack().ListRaw(context.Background(), stack_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Stack list", bytes, stack_cb.ListStacks{}, t))
|
|
// Get
|
|
listStack, _ := client.CloudBroker().Stack().List(context.Background(), stack_cb.ListRequest{})
|
|
if len(listStack.Data) > 0 {
|
|
id := listStack.Data[0].ID
|
|
bytes, err = client.CloudBroker().Stack().GetRaw(context.Background(), stack_cb.GetRequest{StackId: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Stack get", bytes, stack_cb.InfoStack{}, t))
|
|
} else {
|
|
t.Errorf("Can not test Stack get because Stack list is empty")
|
|
}
|
|
|
|
// Tasks
|
|
// List
|
|
bytes, err = client.CloudBroker().Tasks().ListRaw(context.Background(), tasks_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("Tasks list", bytes, tasks_cb.ListTasks{}, t))
|
|
|
|
// VINS
|
|
// List
|
|
bytes, err = client.CloudBroker().VINS().ListRaw(context.Background(), vins_cb.ListRequest{})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("VINS list", bytes, vins_cb.ListVINS{}, t))
|
|
// Get
|
|
listVINS, _ := client.CloudBroker().VINS().List(context.Background(), vins_cb.ListRequest{})
|
|
if len(listVINS.Data) > 0 {
|
|
id := listVINS.Data[0].ID
|
|
bytes, err = client.CloudBroker().VINS().GetRaw(context.Background(), vins_cb.GetRequest{VINSID: id})
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
testLogs = append(testLogs, getResult("VINS get", bytes, vins_cb.RecordVINS{}, t))
|
|
} else {
|
|
t.Errorf("Can not test VINS get because VINS list is empty")
|
|
}
|
|
compareLogs(logFileName, testLogs, t, "get")
|
|
}
|
|
|
|
// TestRequestsCloudAPI tests platform requests vs. golang request structures in sdk for cloudapi requests
|
|
func TestRequestsCloudAPI(t *testing.T) {
|
|
bytes := getBytesFromJSON("input.json", t)
|
|
getErrorsFromJSON(bytes, t, "cloudapi")
|
|
}
|
|
|
|
// TestRequestsCloudbroker tests platform requests vs. golang request structures in sdk for cloudbroker requests
|
|
func TestRequestsCloudbroker(t *testing.T) {
|
|
bytes := getBytesFromJSON("input.json", t)
|
|
getErrorsFromJSON(bytes, t, "cloudbroker")
|
|
}
|
|
|
|
// TestGetAllPaths tests if platform has any handlers that golang sdk doesn't. In this case, list of missing handlers is provided.
|
|
// Note that DEPRECATED_GROUPS stores list of groups that are considered deprecated. You can add additional grops to DEPRECATED_GROUPS if required.
|
|
func TestGetAllPaths(t *testing.T) {
|
|
bytes := getBytesFromJSON("input.json", t)
|
|
jsonUrls, err := getUrlsFromBytes(bytes)
|
|
if err != nil {
|
|
t.Error(err)
|
|
}
|
|
|
|
decortUrls := readUrlFromDir("../../pkg", len(jsonUrls))
|
|
|
|
result := getMissingDecortUrls(jsonUrls, decortUrls)
|
|
if len(result) > 0 {
|
|
errorText := fmt.Sprintf("Below API handlers (%d in total) need to be added to decort-sdk:\n", len(result))
|
|
for _, r := range result {
|
|
errorText += fmt.Sprintln(r)
|
|
}
|
|
t.Errorf(errorText)
|
|
}
|
|
}
|