github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/mrs/v2/clusters/testing/fixtures.go (about)

     1  package testing
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"testing"
     7  
     8  	"github.com/huaweicloud/golangsdk"
     9  	"github.com/huaweicloud/golangsdk/openstack/mrs/v2/clusters"
    10  	th "github.com/huaweicloud/golangsdk/testhelper"
    11  	"github.com/huaweicloud/golangsdk/testhelper/client"
    12  )
    13  
    14  const (
    15  	expectedCreateResponse = `
    16  {
    17  	"cluster_id": "4cb9f483-4464-4b04-b664-b79bf904f441"
    18  }`
    19  )
    20  
    21  var (
    22  	createOpts = &clusters.CreateOpts{
    23  		ClusterName:          "terraform_test",
    24  		AvailabilityZone:     "cn-north-4a",
    25  		ClusterType:          "ANALYSIS",
    26  		ClusterVersion:       "MRS 1.9.2",
    27  		Components:           "Tez,Hive,Hadoop",
    28  		EnterpriseProjectId:  "e9ee3f48-f097-406a-aa74-cfece0af3e31",
    29  		LogCollection:        golangsdk.IntToPointer(1),
    30  		LoginMode:            "PASSWORD",
    31  		ManagerAdminPassword: "Terraform!123",
    32  		NodeRootPassword:     "Terraform!123",
    33  		Region:               "cn-north-4",
    34  		SafeMode:             "KERBEROS",
    35  		SubnetId:             "ea6a5175-2ff1-4f72-b5b5-1fe82cea8c19",
    36  		VpcName:              "terraform_test",
    37  		NodeGroups: []clusters.NodeGroupOpts{
    38  			{
    39  				GroupName:       "master_node_default_group",
    40  				NodeSize:        "c6.2xlarge.4.linux.bigdata",
    41  				NodeNum:         2,
    42  				DataVolumeCount: golangsdk.IntToPointer(1),
    43  				RootVolume: &clusters.Volume{
    44  					Size: 600,
    45  					Type: "SAS",
    46  				},
    47  				DataVolume: &clusters.Volume{
    48  					Size: 600,
    49  					Type: "SAS",
    50  				},
    51  			},
    52  			{
    53  				GroupName:       "core_node_analysis_group",
    54  				NodeSize:        "c6.2xlarge.4.linux.bigdata",
    55  				NodeNum:         2,
    56  				DataVolumeCount: golangsdk.IntToPointer(1),
    57  				RootVolume: &clusters.Volume{
    58  					Size: 600,
    59  					Type: "SAS",
    60  				},
    61  				DataVolume: &clusters.Volume{
    62  					Size: 600,
    63  					Type: "SAS",
    64  				},
    65  			},
    66  			{
    67  				GroupName:       "task_node_analysis_group",
    68  				NodeSize:        "c6.2xlarge.4.linux.bigdata",
    69  				NodeNum:         1,
    70  				DataVolumeCount: golangsdk.IntToPointer(1),
    71  				RootVolume: &clusters.Volume{
    72  					Size: 600,
    73  					Type: "SAS",
    74  				},
    75  				DataVolume: &clusters.Volume{
    76  					Size: 600,
    77  					Type: "SAS",
    78  				},
    79  			},
    80  		},
    81  	}
    82  
    83  	expectedCreateResponseData = &clusters.Cluster{
    84  		ID: "4cb9f483-4464-4b04-b664-b79bf904f441",
    85  	}
    86  )
    87  
    88  func handleV2ClusterCreate(t *testing.T) {
    89  	th.Mux.HandleFunc("/clusters", func(w http.ResponseWriter, r *http.Request) {
    90  		th.TestMethod(t, r, "POST")
    91  		th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
    92  		w.Header().Add("Content-Type", "application/json")
    93  		w.WriteHeader(http.StatusOK)
    94  		_, _ = fmt.Fprint(w, expectedCreateResponse)
    95  	})
    96  }