summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/rb/definition_test.go
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2018-12-10 13:34:16 -0800
committerKiran Kamineni <kiran.k.kamineni@intel.com>2018-12-14 14:26:26 -0800
commitd203ccf9174e450b6f5a6a9aabea95b73c9973ff (patch)
tree702034eafbd28b47f33023607ee213cf92519a99 /src/k8splugin/rb/definition_test.go
parentaa56022e0fba3c358e46e8671d9a0cd36094ebaa (diff)
Migrating from consul to mongodb for backend
Migrating to mongodb from consul. The main reason being the value size limitation of 512kb in consul. See https://jira.onap.org/browse/MULTICLOUD-426 for details. This requires a little bit of hierarchy management and data management. We are no longer converting structs to json encoded strings. The underlying db supports structs without any modifications. Also, since Mongo has the concept of collections, each submodule can use its own collection for storage as needed. Definition uses a collection called rbdef right now. P10: Enabling unit tests for mongo.go. This requires the usage of aliased functions. P11: Expanded unit tests for all functions in mongo.go P12: Refactored parameter validation. Removed TestHealthCheck as we are not mocking any of the db commands right now Checking return value of read with an expected value P13: Adding back consul support. Fixing functional test Full consul implementation check and modifications is being tracked by MULTICLOUD-427 P15: Fix ReadAll unit test and corresponding code ReadAll now returns error when no objects are found Issue-ID: MULTICLOUD-426 Change-Id: I42d239b324025fc4ef4e561790aceeff794001ef Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/rb/definition_test.go')
-rw-r--r--src/k8splugin/rb/definition_test.go47
1 files changed, 17 insertions, 30 deletions
diff --git a/src/k8splugin/rb/definition_test.go b/src/k8splugin/rb/definition_test.go
index 58eb718d..1e488678 100644
--- a/src/k8splugin/rb/definition_test.go
+++ b/src/k8splugin/rb/definition_test.go
@@ -24,7 +24,6 @@ import (
"strings"
"testing"
- "github.com/hashicorp/consul/api"
pkgerrors "github.com/pkg/errors"
)
@@ -110,21 +109,17 @@ func TestList(t *testing.T) {
},
expectedError: "",
mockdb: &db.MockDB{
- Items: api.KVPairs{
- &api.KVPair{
- Key: "rb/def/123e4567-e89b-12d3-a456-426655440000",
- Value: []byte("{\"name\":\"testresourcebundle\"," +
+ Items: map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": []byte(
+ "{\"name\":\"testresourcebundle\"," +
"\"description\":\"testresourcebundle\"," +
"\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
"\"service-type\":\"firewall\"}"),
- },
- &api.KVPair{
- Key: "rb/def/123e4567-e89b-12d3-a456-426655441111",
- Value: []byte("{\"name\":\"testresourcebundle2\"," +
+ "123e4567-e89b-12d3-a456-426655441111": []byte(
+ "{\"name\":\"testresourcebundle2\"," +
"\"description\":\"testresourcebundle2\"," +
"\"uuid\":\"123e4567-e89b-12d3-a456-426655441111\"," +
"\"service-type\":\"dns\"}"),
- },
},
},
},
@@ -179,14 +174,12 @@ func TestGet(t *testing.T) {
},
expectedError: "",
mockdb: &db.MockDB{
- Items: api.KVPairs{
- &api.KVPair{
- Key: "rb/def/123e4567-e89b-12d3-a456-426655440000",
- Value: []byte("{\"name\":\"testresourcebundle\"," +
+ Items: map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": []byte(
+ "{\"name\":\"testresourcebundle\"," +
"\"description\":\"testresourcebundle\"," +
"\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
"\"service-type\":\"firewall\"}"),
- },
},
},
},
@@ -293,14 +286,12 @@ func TestUpload(t *testing.T) {
0x4a, 0xf9, 0x00, 0x28, 0x00, 0x00,
},
mockdb: &db.MockDB{
- Items: api.KVPairs{
- &api.KVPair{
- Key: "rb/def/123e4567-e89b-12d3-a456-426655440000",
- Value: []byte("{\"name\":\"testresourcebundle\"," +
+ Items: map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": []byte(
+ "{\"name\":\"testresourcebundle\"," +
"\"description\":\"testresourcebundle\"," +
"\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
"\"service-type\":\"firewall\"}"),
- },
},
},
},
@@ -330,14 +321,12 @@ func TestUpload(t *testing.T) {
0x4a, 0xf9, 0x00, 0x28, 0x00, 0x00,
},
mockdb: &db.MockDB{
- Items: api.KVPairs{
- &api.KVPair{
- Key: "rb/def/123e4567-e89b-12d3-a456-426655441111",
- Value: []byte("{\"name\":\"testresourcebundle\"," +
+ Items: map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655441111": []byte(
+ "{\"name\":\"testresourcebundle\"," +
"\"description\":\"testresourcebundle\"," +
"\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
"\"service-type\":\"firewall\"}"),
- },
},
},
},
@@ -350,14 +339,12 @@ func TestUpload(t *testing.T) {
0x00, 0xff, 0xf2, 0x48, 0xcd,
},
mockdb: &db.MockDB{
- Items: api.KVPairs{
- &api.KVPair{
- Key: "rb/def/123e4567-e89b-12d3-a456-426655440000",
- Value: []byte("{\"name\":\"testresourcebundle\"," +
+ Items: map[string][]byte{
+ "123e4567-e89b-12d3-a456-426655440000": []byte(
+ "{\"name\":\"testresourcebundle\"," +
"\"description\":\"testresourcebundle\"," +
"\"uuid\":\"123e4567-e89b-12d3-a456-426655440000\"," +
"\"service-type\":\"firewall\"}"),
- },
},
},
},