1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
//go:build acceptance || containerinfra
// +build acceptance containerinfra
package v1
import (
"testing"
"time"
"github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/containerinfra/v1/clusters"
th "github.com/gophercloud/gophercloud/testhelper"
)
func TestClustersCRUD(t *testing.T) {
t.Skip("Failure to deploy cluster in CI")
client, err := clients.NewContainerInfraV1Client()
th.AssertNoErr(t, err)
clusterTemplate, err := CreateKubernetesClusterTemplate(t, client)
th.AssertNoErr(t, err)
defer DeleteClusterTemplate(t, client, clusterTemplate.UUID)
clusterID, err := CreateKubernetesCluster(t, client, clusterTemplate.UUID)
th.AssertNoErr(t, err)
tools.PrintResource(t, clusterID)
defer DeleteCluster(t, client, clusterID)
allPages, err := clusters.List(client, nil).AllPages()
th.AssertNoErr(t, err)
allClusters, err := clusters.ExtractClusters(allPages)
th.AssertNoErr(t, err)
var found bool
for _, v := range allClusters {
if v.UUID == clusterID {
found = true
}
}
th.AssertEquals(t, found, true)
updateOpts := []clusters.UpdateOptsBuilder{
clusters.UpdateOpts{
Op: clusters.ReplaceOp,
Path: "/node_count",
Value: 2,
},
}
updateResult := clusters.Update(client, clusterID, updateOpts)
th.AssertNoErr(t, updateResult.Err)
if len(updateResult.Header["X-Openstack-Request-Id"]) > 0 {
t.Logf("Cluster Update Request ID: %s", updateResult.Header["X-Openstack-Request-Id"][0])
}
clusterID, err = updateResult.Extract()
th.AssertNoErr(t, err)
err = WaitForCluster(client, clusterID, "UPDATE_COMPLETE", time.Second*300)
th.AssertNoErr(t, err)
newCluster, err := clusters.Get(client, clusterID).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, newCluster.UUID, clusterID)
allPagesDetail, err := clusters.ListDetail(client, nil).AllPages()
th.AssertNoErr(t, err)
allClustersDetail, err := clusters.ExtractClusters(allPagesDetail)
th.AssertNoErr(t, err)
var foundDetail bool
for _, v := range allClustersDetail {
if v.UUID == clusterID {
foundDetail = true
}
}
th.AssertEquals(t, foundDetail, true)
tools.PrintResource(t, newCluster)
}
|