Skip to content

Commit

Permalink
osdconfig struct update
Browse files Browse the repository at this point in the history
Signed-off-by: Saurabh Deoras <[email protected]>
  • Loading branch information
sdeoras committed Mar 12, 2018
1 parent 0b940a8 commit 8f50798
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 149 deletions.
68 changes: 27 additions & 41 deletions api/server/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"testing"
"time"

"github.com/libopenstorage/openstorage/osdconfig"

"github.com/golang/mock/gomock"
types "github.com/libopenstorage/gossip/types"
"github.com/libopenstorage/openstorage/api"
clusterclient "github.com/libopenstorage/openstorage/api/client/cluster"
"github.com/libopenstorage/openstorage/cluster"
"github.com/libopenstorage/openstorage/osdconfig"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -514,29 +513,24 @@ func TestGetClusterConfSuccess(t *testing.T) {
ClusterSecretKey: "cluster-secret-key",
SecretType: "vault",
Vault: &osdconfig.VaultConfig{
VaultAddr: "/vault/addr",
VaultBasePath: "1.1.1.1",
VaultCacert: "vault-ca-cert",
VaultClientCert: "vault-client-cert",
VaultToken: "vault--dummy-token",
Address: "/vault/addr",
BasePath: "1.1.1.1",
CACert: "vault-ca-cert",
ClientCert: "vault-client-cert",
Token: "vault--dummy-token",
},
}

clusterConfig := &osdconfig.ClusterConfig{
NodeId: []string{"node-id-1", "node-id-2", "node-id-3"},
Nolh: true,
ClusterId: "dummy-cluster-id",
Created: time.Now().String(),
Callhome: true,
AlertingUrl: "http://dummy.alerting.url",
DebugLevel: "level-0",
Multicontainer: true,
Secrets: secretsConfig,
Version: "x.y.z",
NodeId: []string{"node-id-1", "node-id-2", "node-id-3"},
ClusterId: "dummy-cluster-id",
Created: time.Now(),
Secrets: secretsConfig,
Version: "x.y.z",
Kvdb: &osdconfig.KvdbConfig{
KvdbAddr: []string{"2.2.2.2"},
Password: "kvdb-pass",
Username: "kvdb",
Discovery: []string{"2.2.2.2"},
Password: "kvdb-pass",
Username: "kvdb",
},
}
// mock the cluster response
Expand All @@ -558,7 +552,6 @@ func TestGetClusterConfSuccess(t *testing.T) {
assert.Equal(t, resp.Version, clusterConfig.Version)
assert.Equal(t, resp.Kvdb.Password, clusterConfig.Kvdb.Password)
assert.Equal(t, len(resp.NodeId), 3)
assert.Equal(t, resp.AlertingUrl, clusterConfig.AlertingUrl)
}

func TestSetClusterConfSuccess(t *testing.T) {
Expand All @@ -572,29 +565,24 @@ func TestSetClusterConfSuccess(t *testing.T) {
ClusterSecretKey: "cluster-secret-key",
SecretType: "vault",
Vault: &osdconfig.VaultConfig{
VaultAddr: "/vault/addr",
VaultBasePath: "1.1.1.1",
VaultCacert: "vault-ca-cert",
VaultClientCert: "vault-client-cert",
VaultToken: "vault--dummy-token",
Address: "/vault/addr",
BasePath: "1.1.1.1",
CACert: "vault-ca-cert",
ClientCert: "vault-client-cert",
Token: "vault--dummy-token",
},
}

clusterConfig := &osdconfig.ClusterConfig{
NodeId: []string{"node-id-1,node-id-2,node-id-3"},
Nolh: true,
ClusterId: "dummy-cluster-id",
Created: time.Now().String(),
Callhome: true,
AlertingUrl: "http://dummy.alerting.url",
DebugLevel: "level-0",
Multicontainer: true,
Secrets: secretsConfig,
Version: "x.y.z",
NodeId: []string{"node-id-1,node-id-2,node-id-3"},
ClusterId: "dummy-cluster-id",
Created: time.Now(),
Secrets: secretsConfig,
Version: "x.y.z",
Kvdb: &osdconfig.KvdbConfig{
KvdbAddr: []string{"2.2.2.2"},
Password: "kvdb-pass",
Username: "kvdb",
Discovery: []string{"2.2.2.2"},
Password: "kvdb-pass",
Username: "kvdb",
},
}

Expand Down Expand Up @@ -625,7 +613,6 @@ func TestGetNodeConfSuccess(t *testing.T) {
nodeConfig := &osdconfig.NodeConfig{
NodeId: nodeID,
Storage: &osdconfig.StorageConfig{
AsyncIo: true,
Devices: []string{"/dev/sdb", "/dev/sdc"},
MaxDriveSetCount: 5,
MaxCount: 5,
Expand Down Expand Up @@ -693,7 +680,6 @@ func TestSetNodeConfSuccess(t *testing.T) {
nodeConfig := &osdconfig.NodeConfig{
NodeId: nodeID,
Storage: &osdconfig.StorageConfig{
AsyncIo: true,
Devices: []string{"/dev/sdb", "/dev/sdc"},
MaxDriveSetCount: 5,
MaxCount: 5,
Expand Down
60 changes: 0 additions & 60 deletions cluster/mock/cluster.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions osdconfig/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestSetGetCluster(t *testing.T) {
// prepare expected cluster config
expectedConf := new(ClusterConfig)
expectedConf.ClusterId = "myClusterID"
expectedConf.Driver = "myDriver"
expectedConf.Description = "myDescription"

// set the expected cluster config value
if err := manager.SetClusterConf(expectedConf); err != nil {
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestCallback(t *testing.T) {
err = fmt.Errorf("data not as expected")

}
if config.Driver != "myDriver" {
if config.Description != "myDescription" {
err = fmt.Errorf("data not as expected")
}
ch <- err
Expand Down Expand Up @@ -150,7 +150,7 @@ func setSomeClusterValues(ch chan error, manager ConfigManager) error {
// prepare expected cluster config
conf := new(ClusterConfig)
conf.ClusterId = "myClusterID"
conf.Driver = "myDriver"
conf.Description = "myDescription"

if err := manager.SetClusterConf(conf); err != nil {
return err
Expand Down
Loading

0 comments on commit 8f50798

Please sign in to comment.