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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
//go:build acceptance || containers || capsules
// +build acceptance containers capsules
package v1
import (
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/openstack/container/v1/capsules"
"github.com/gophercloud/gophercloud/pagination"
th "github.com/gophercloud/gophercloud/testhelper"
)
func TestCapsuleBase(t *testing.T) {
t.Skip("Currently failing in OpenLab")
clients.SkipRelease(t, "stable/mitaka")
clients.SkipRelease(t, "stable/newton")
clients.SkipRelease(t, "stable/ocata")
clients.SkipRelease(t, "stable/pike")
clients.SkipRelease(t, "stable/queens")
client, err := clients.NewContainerV1Client()
th.AssertNoErr(t, err)
template := new(capsules.Template)
template.Bin = []byte(capsuleTemplate)
createOpts := capsules.CreateOpts{
TemplateOpts: template,
}
v, err := capsules.Create(client, createOpts).Extract()
th.AssertNoErr(t, err)
capsule := v.(*capsules.Capsule)
err = WaitForCapsuleStatus(client, capsule.UUID, "Running")
th.AssertNoErr(t, err)
pager := capsules.List(client, nil)
err = pager.EachPage(func(page pagination.Page) (bool, error) {
v, err := capsules.ExtractCapsules(page)
th.AssertNoErr(t, err)
allCapsules := v.([]capsules.Capsule)
for _, m := range allCapsules {
capsuleUUID := m.UUID
if capsuleUUID != capsule.UUID {
continue
}
capsule, err := capsules.Get(client, capsuleUUID).ExtractBase()
th.AssertNoErr(t, err)
th.AssertEquals(t, capsule.MetaName, "template")
err = capsules.Delete(client, capsuleUUID).ExtractErr()
th.AssertNoErr(t, err)
}
return true, nil
})
th.AssertNoErr(t, err)
}
func TestCapsuleV132(t *testing.T) {
t.Skip("Currently failing in OpenLab")
clients.SkipRelease(t, "stable/mitaka")
clients.SkipRelease(t, "stable/newton")
clients.SkipRelease(t, "stable/ocata")
clients.SkipRelease(t, "stable/pike")
clients.SkipRelease(t, "stable/queens")
clients.SkipRelease(t, "stable/rocky")
clients.SkipRelease(t, "stable/stein")
client, err := clients.NewContainerV1Client()
th.AssertNoErr(t, err)
client.Microversion = "1.32"
template := new(capsules.Template)
template.Bin = []byte(capsuleTemplate)
createOpts := capsules.CreateOpts{
TemplateOpts: template,
}
capsule, err := capsules.Create(client, createOpts).ExtractV132()
th.AssertNoErr(t, err)
err = WaitForCapsuleStatus(client, capsule.UUID, "Running")
th.AssertNoErr(t, err)
pager := capsules.List(client, nil)
err = pager.EachPage(func(page pagination.Page) (bool, error) {
allCapsules, err := capsules.ExtractCapsulesV132(page)
th.AssertNoErr(t, err)
for _, m := range allCapsules {
capsuleUUID := m.UUID
if capsuleUUID != capsule.UUID {
continue
}
capsule, err := capsules.Get(client, capsuleUUID).ExtractV132()
th.AssertNoErr(t, err)
th.AssertEquals(t, capsule.MetaName, "template")
err = capsules.Delete(client, capsuleUUID).ExtractErr()
th.AssertNoErr(t, err)
}
return true, nil
})
th.AssertNoErr(t, err)
}
|