Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions config/transformer/models_list
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,31 @@ gnsi-authz.yang
gnsi-pathz.yang
gnsi-certz.yang
gnsi-credentialz.yang
openconfig-optical-amplifier.yang
openconfig-optical-amplifier-annot.yang
openconfig-optical-attenuator.yang
openconfig-optical-attenuator-annot.yang
openconfig-channel-monitor.yang
openconfig-channel-monitor-annot.yang
openconfig-system.yang
openconfig-system-annot.yang
openconfig-platform.yang
openconfig-platform-annot.yang
openconfig-terminal-device.yang
openconfig-terminal-device-annot.yang
openconfig-terminal-device-deviation.yang
openconfig-optical-time-domain-reflectometer.yang
openconfig-optical-time-domain-reflectometer-annot.yang
openconfig-telemetry.yang
openconfig-telemetry-annot.yang
openconfig-transport-line-protection.yang
openconfig-transport-line-protection-annot.yang
openconfig-wavelength-router.yang
openconfig-wavelength-router-annot.yang
openconfig-transport-line-common.yang
openconfig-platform-transceiver.yang
openconfig-wavelength-router-deviation.yang
openconfig-test-xfmr.yang
openconfig-test-xfmr-annot.yang
sonic-test-xfmr-annot.yang

1 change: 1 addition & 0 deletions cvl/common/db_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type DBAccess interface {
Lookup(s Search) JsonResult
// Count entries using a Search criteria. Returns 0 if there are no matches.
Count(s Search) IntResult
GetMDBName() string
}

type IntResult interface {
Expand Down
1 change: 1 addition & 0 deletions cvl/custom_validation/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type CustValidationCtxt struct {
YCur *xmlquery.Node //YANG data tree
SessCache *CustValidationCache //Session cache, can be used for storing data, persistent in session
RClient common.DBAccess //Db access interface
NameSpace string // Namespace is required to open NewDbClient to other dependent DBs like STATE_DB,APPL_DB..
}

// Search criteria for advanced lookup through DBAccess APIs
Expand Down
3 changes: 2 additions & 1 deletion cvl/cvl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,8 @@ func (c *CVL) doCustomValidation(node *xmlquery.Node,
YNodeVal: nodeVal,
YCur: node,
SessCache: &(c.custvCache),
RClient: c.dbAccess}
RClient: c.dbAccess,
NameSpace: c.dbAccess.GetMDBName()}
for _, custFunction := range custFuncs {
CVL_LOG(INFO_TRACE, "Calling custom validation function %s", custFunction)
errObj := custv.InvokeCustomValidation(&custv.CustomValidation{}, custFunction, pCustv)
Expand Down
1 change: 1 addition & 0 deletions cvl/cvl_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ func (c *CVL) ValidateEditConfig(cfgData []cmn.CVLEditConfigData) (cvlErr CVLErr
panic(c.dbAccess)
}

CVL_LOG(INFO_DEBUG, "ValidateEditConfig: Namespace:%s", c.dbAccess.GetMDBName())
ts := time.Now()

defer func() {
Expand Down
3 changes: 2 additions & 1 deletion cvl/cvl_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const (
)

func verifyValidateEditConfig(t *testing.T, data []CVLEditConfigData, exp CVLErrorInfo) {
c := NewTestSession(t)
d := getMDBInstance(hostDBName)
c := NewTestSession(t, d)
res, _ := c.ValidateEditConfig(data)
verifyErr(t, res, exp)
}
Expand Down
31 changes: 17 additions & 14 deletions cvl/cvl_hint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,22 @@ var hKey = "TESTKEY"
var hValue = map[string]string{"a": "1", "b": "2"}

func TestSetHint(t *testing.T) {
cvSess, retCode := NewCvlSession()
if retCode != cvl.CVL_SUCCESS {
t.Fatalf("cvl.ValidationSessOpen() fails e: %v", retCode)
}

t.Cleanup(func() { cvl.ValidationSessClose(cvSess) })

if retCode = cvSess.StoreHint(hKey, hValue); retCode != cvl.CVL_SUCCESS {
t.Fatalf("cvSess.StoreHint() fails e: %v", retCode)
}

value, ok := cvSess.LoadHint(hKey)
if !ok || !reflect.DeepEqual(hValue, value) {
t.Errorf("%v != %v", hValue, value)
for _, dbName := range MdbNames {
d := configDb[dbName]
cvSess, retCode := NewCvlSession(d)
if retCode != cvl.CVL_SUCCESS {
t.Fatalf("cvl.ValidationSessOpen() fails e: %v", retCode)
}

t.Cleanup(func() { cvl.ValidationSessClose(cvSess) })

if retCode = cvSess.StoreHint(hKey, hValue); retCode != cvl.CVL_SUCCESS {
t.Fatalf("cvSess.StoreHint() fails e: %v", retCode)
}

value, ok := cvSess.LoadHint(hKey)
if !ok || !reflect.DeepEqual(hValue, value) {
t.Errorf("%v != %v", hValue, value)
}
}
}
75 changes: 50 additions & 25 deletions cvl/cvl_leaflist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
// Create test cases

t.Run("create_all", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_CREATE,
Expand All @@ -78,7 +79,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("create_without_min0", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_CREATE,
Expand All @@ -91,7 +93,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("create_without_min1", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_CREATE,
Expand All @@ -103,7 +106,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("create_without_min4", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_CREATE,
Expand All @@ -115,7 +119,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("create_more_than_max", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_CREATE,
Expand All @@ -128,7 +133,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("create_less_than_min", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_CREATE,
Expand All @@ -143,7 +149,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
// update cases

t.Run("update_without_minmax", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -155,7 +162,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("update_min0", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -168,7 +176,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("update_to_min1", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -181,7 +190,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("update_to_min4", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -193,7 +203,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("update_to_max", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -206,7 +217,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("update_more_than_max", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -219,7 +231,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("update_less_than_min", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -232,7 +245,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("update_to_empty1", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -245,7 +259,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("update_to_empty4", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_UPDATE,
Expand All @@ -258,7 +273,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
// delete cases

t.Run("delete_without_minmax", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_DELETE,
Expand All @@ -269,7 +285,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("delete_min0", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_DELETE,
Expand All @@ -280,7 +297,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("delete_min1", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_DELETE,
Expand All @@ -291,7 +309,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("delete_min4", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
VType: VALIDATE_ALL,
VOp: OP_DELETE,
Expand All @@ -304,7 +323,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
// replace cases

t.Run("replace_no_constraints2", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
ReplaceOp: true,
VType: VALIDATE_ALL,
Expand All @@ -322,7 +342,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("replace_remove_min0", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
ReplaceOp: true,
VType: VALIDATE_ALL,
Expand All @@ -340,7 +361,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("replace_remove_min1", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
ReplaceOp: true,
VType: VALIDATE_ALL,
Expand All @@ -358,7 +380,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("replace_remove_min4", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
ReplaceOp: true,
VType: VALIDATE_ALL,
Expand All @@ -376,7 +399,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("replace_set_more_than_max", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
ReplaceOp: true,
VType: VALIDATE_ALL,
Expand All @@ -394,7 +418,8 @@ func TestValidateEditConfig_Leaflist_MinMax(t *testing.T) {
})

t.Run("replace_set_less_than_min", func(tt *testing.T) {
c := NewTestSession(tt)
d := getMDBInstance(hostDBName)
c := NewTestSession(tt, d)
res, _ := c.ValidateEditConfig([]CVLEditConfigData{{
ReplaceOp: true,
VType: VALIDATE_ALL,
Expand Down
9 changes: 6 additions & 3 deletions cvl/cvl_leafref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func TestValidateEditConfig_Create_Chained_Leafref_DepData_Positive(t *testing.T
},
})

cvSess, _ := NewCvlSession()
d := getMDBInstance(hostDBName)
cvSess, _ := NewCvlSession(d)

cfgDataVlan := []cmn.CVLEditConfigData{
cmn.CVLEditConfigData{
Expand Down Expand Up @@ -389,15 +390,17 @@ func TestValidateEditConfig_Delete_Leafref(t *testing.T) {

func deletePO(poId int, expSuccess bool) func(*testing.T) {
return func(t *testing.T) {
session, _ := NewCvlSession()
d := getMDBInstance(hostDBName)
session, _ := NewCvlSession(d)
defer cvl.ValidationSessClose(session)
validateDeletePO(t, session, nil, poId, expSuccess)
}
}

func deleteACLAndPO(aclName, ports string, poId int, bulk, expSuccess bool) func(*testing.T) {
return func(t *testing.T) {
session, _ := NewCvlSession()
d := getMDBInstance(hostDBName)
session, _ := NewCvlSession(d)
defer cvl.ValidationSessClose(session)
var cfgData []cmn.CVLEditConfigData

Expand Down
Loading