diff --git a/e2e/cluster_test.go b/e2e/cluster_test.go new file mode 100644 index 000000000..523fe868a --- /dev/null +++ b/e2e/cluster_test.go @@ -0,0 +1,48 @@ +package e2e + +import ( + "testing" + + "github.com/gluster/glusterd2/pkg/api" + + "github.com/stretchr/testify/require" +) + +func testGetClusterOptions(t *testing.T) { + r := require.New(t) + clusterOps, err := client.GetClusterOption() + r.Nil(err) + r.NotNil(clusterOps) +} + +func ClusterOptionsSet(t *testing.T) { + r := require.New(t) + optReq := api.ClusterOptionReq{ + Options: map[string]string{"cluster.brick-multiplex": "on"}, + } + err := client.ClusterOptionSet(optReq) + r.Nil(err) + clusterOps, err := client.GetClusterOption() + for _, ops := range clusterOps { + if ops.Key == "cluster.brick-multiplex" { + r.Equal(ops.Value, "on") + } + } +} + +// TestClusterOption creates a cluster +func TestClusterOption(t *testing.T) { + var err error + + r := require.New(t) + + tc, err := setupCluster(t, "./config/1.toml", "./config/2.toml", "./config/3.toml") + r.Nil(err) + defer teardownCluster(tc) + + client, err = initRestclient(tc.gds[0]) + r.Nil(err) + r.NotNil(client) + + t.Run("Get Cluster Options", testGetClusterOptions) +} diff --git a/e2e/smartvol_ops_test.go b/e2e/smartvol_ops_test.go index a5d099576..602078a9b 100644 --- a/e2e/smartvol_ops_test.go +++ b/e2e/smartvol_ops_test.go @@ -181,6 +181,15 @@ func testSmartVolumeDistribute(t *testing.T) { r.NotNil(err) r.Nil(client.VolumeDelete(smartvolname)) + + createReq = api.VolCreateReq{ + Name: "volume", + Size: 60 * gutils.MiB, + DistributeCount: 3, + } + volinfo, err = client.VolumeCreate(createReq) + r.NotNil(err) + checkZeroLvs(r) } diff --git a/glustercli/cmd/cluster-options.go b/glustercli/cmd/cluster-options.go new file mode 100644 index 000000000..f87c2f10e --- /dev/null +++ b/glustercli/cmd/cluster-options.go @@ -0,0 +1,96 @@ +package cmd + +import ( + "errors" + "fmt" + "os" + + "github.com/gluster/glusterd2/pkg/api" + + "github.com/olekukonko/tablewriter" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +const ( + helpClusterOptionCmd = "Gluster Cluster Option Management" + helpClusterOptionSetCmd = "Set Cluster Option" + helpClusterOptionGetCmd = "Get Cluster Option" +) + +func init() { + clusterCmd.AddCommand(clusterOptionGetCmd) + clusterCmd.AddCommand(clusterOptionSetCmd) +} + +var clusterCmd = &cobra.Command{ + Use: "cluster", + Short: helpClusterOptionCmd, +} + +var clusterOptionSetCmd = &cobra.Command{ + Use: "set