github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/internal/acceptance/openstack/blockstorage/v2/schedulerstats_test.go (about)

     1  //go:build acceptance || blockstorage || schedulerstats
     2  
     3  package v2
     4  
     5  import (
     6  	"context"
     7  	"testing"
     8  
     9  	"github.com/vnpaycloud-console/gophercloud/v2/internal/acceptance/clients"
    10  	"github.com/vnpaycloud-console/gophercloud/v2/internal/acceptance/tools"
    11  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/blockstorage/v2/schedulerstats"
    12  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
    13  )
    14  
    15  func TestSchedulerStatsList(t *testing.T) {
    16  	clients.SkipReleasesAbove(t, "stable/ocata")
    17  	clients.RequireAdmin(t)
    18  
    19  	blockClient, err := clients.NewBlockStorageV2Client()
    20  	th.AssertNoErr(t, err)
    21  
    22  	listOpts := schedulerstats.ListOpts{
    23  		Detail: true,
    24  	}
    25  
    26  	allPages, err := schedulerstats.List(blockClient, listOpts).AllPages(context.TODO())
    27  	th.AssertNoErr(t, err)
    28  
    29  	allStats, err := schedulerstats.ExtractStoragePools(allPages)
    30  	th.AssertNoErr(t, err)
    31  
    32  	for _, stat := range allStats {
    33  		tools.PrintResource(t, stat)
    34  	}
    35  }