@@ -709,6 +709,7 @@ type subscriptionQuery struct {
709
709
Query []string
710
710
SubMode pb.SubscriptionMode
711
711
SampleInterval uint64
712
+ HeartbeatInterval uint64
712
713
}
713
714
714
715
func pathToString (q client.Path ) string {
@@ -745,6 +746,7 @@ func createQuery(subListMode pb.SubscriptionList_Mode, target string, queries []
745
746
Path : pp ,
746
747
Mode : qq .SubMode ,
747
748
SampleInterval : qq .SampleInterval ,
749
+ HeartbeatInterval : qq .HeartbeatInterval ,
748
750
})
749
751
}
750
752
@@ -792,14 +794,15 @@ func createStateDbQueryOnChangeMode(t *testing.T, paths ...string) client.Query
792
794
}
793
795
794
796
// createCountersDbQueryOnChangeMode creates a query with ON_CHANGE mode.
795
- func createCountersDbQueryOnChangeMode (t * testing.T , paths ... string ) client.Query {
797
+ func createCountersDbQueryOnChangeMode (t * testing.T , interval time. Duration , paths ... string ) client.Query {
796
798
return createQueryOrFail (t ,
797
799
pb .SubscriptionList_STREAM ,
798
800
"COUNTERS_DB" ,
799
801
[]subscriptionQuery {
800
802
{
801
803
Query : paths ,
802
804
SubMode : pb .SubscriptionMode_ON_CHANGE ,
805
+ HeartbeatInterval : uint64 (interval .Nanoseconds ()),
803
806
},
804
807
},
805
808
false )
@@ -1800,9 +1803,35 @@ func runTestSubscribe(t *testing.T, namespace string) {
1800
1803
generateIntervals bool
1801
1804
}
1802
1805
tests := []TestExec {
1806
+ {
1807
+ desc : "Testing invalid heartbeat interval" ,
1808
+ q : createCountersDbQueryOnChangeMode (t , 10 * time .Second , "COUNTERS_PORT_NAME_MAP" ),
1809
+ wantSubErr : fmt .Errorf ("rpc error: code = InvalidArgument desc = invalid heartbeat interval: 10s. It cannot be less than %v" , sdc .MinHeartbeatInterval ),
1810
+ wantNoti : []client.Notification {},
1811
+ },
1812
+ {
1813
+ desc : "stream query with Heartbeat interval for table key Ethernet68 with new test_field field" ,
1814
+ q : createCountersDbQueryOnChangeMode (t , 30 * time .second , "COUNTERS" , "Ethernet68" ),
1815
+ updates : []tablePathValue {
1816
+ {
1817
+ dbName : "COUNTERS_DB" ,
1818
+ tableName : "COUNTERS" ,
1819
+ tableKey : "oid:0x1000000000039" , // "Ethernet68": "oid:0x1000000000039",
1820
+ delimitor : ":" ,
1821
+ field : "test_field" ,
1822
+ value : "test_value" ,
1823
+ },
1824
+ },
1825
+ wantNoti : []client.Notification {
1826
+ client.Connected {},
1827
+ client.Update {Path : []string {"COUNTERS" , "Ethernet68" }, TS : time .Unix (0 , 200 ), Val : countersEthernet68Json },
1828
+ client.Sync {},
1829
+ client.Update {Path : []string {"COUNTERS" , "Ethernet68" }, TS : time .Unix (0 , 200 ), Val : countersEthernet68Json },
1830
+ },
1831
+ },
1803
1832
{
1804
1833
desc : "stream query for table COUNTERS_PORT_NAME_MAP with new test_field field" ,
1805
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS_PORT_NAME_MAP" ),
1834
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS_PORT_NAME_MAP" ),
1806
1835
updates : []tablePathValue {{
1807
1836
dbName : "COUNTERS_DB" ,
1808
1837
tableName : "COUNTERS_PORT_NAME_MAP" ,
@@ -1818,7 +1847,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
1818
1847
},
1819
1848
{
1820
1849
desc : "stream query for table key Ethernet68 with new test_field field" ,
1821
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet68" ),
1850
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet68" ),
1822
1851
updates : []tablePathValue {
1823
1852
{
1824
1853
dbName : "COUNTERS_DB" ,
@@ -1846,7 +1875,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
1846
1875
},
1847
1876
{
1848
1877
desc : "(use vendor alias) stream query for table key Ethernet68/1 with new test_field field" ,
1849
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet68/1" ),
1878
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet68/1" ),
1850
1879
updates : []tablePathValue {
1851
1880
{
1852
1881
dbName : "COUNTERS_DB" ,
@@ -1874,7 +1903,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
1874
1903
},
1875
1904
{
1876
1905
desc : "stream query for COUNTERS/Ethernet68/SAI_PORT_STAT_PFC_7_RX_PKTS with update of field value" ,
1877
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet68" , "SAI_PORT_STAT_PFC_7_RX_PKTS" ),
1906
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet68" , "SAI_PORT_STAT_PFC_7_RX_PKTS" ),
1878
1907
updates : []tablePathValue {
1879
1908
{
1880
1909
dbName : "COUNTERS_DB" ,
@@ -1902,7 +1931,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
1902
1931
},
1903
1932
{
1904
1933
desc : "(use vendor alias) stream query for COUNTERS/[Ethernet68/1]/SAI_PORT_STAT_PFC_7_RX_PKTS with update of field value" ,
1905
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet68/1" , "SAI_PORT_STAT_PFC_7_RX_PKTS" ),
1934
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet68/1" , "SAI_PORT_STAT_PFC_7_RX_PKTS" ),
1906
1935
updates : []tablePathValue {
1907
1936
{
1908
1937
dbName : "COUNTERS_DB" ,
@@ -1930,7 +1959,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
1930
1959
},
1931
1960
{
1932
1961
desc : "stream query for COUNTERS/Ethernet68/Pfcwd with update of field value" ,
1933
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet68" , "Pfcwd" ),
1962
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet68" , "Pfcwd" ),
1934
1963
updates : []tablePathValue {
1935
1964
{
1936
1965
dbName : "COUNTERS_DB" ,
@@ -1958,7 +1987,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
1958
1987
},
1959
1988
{
1960
1989
desc : "(use vendor alias) stream query for COUNTERS/[Ethernet68/1]/Pfcwd with update of field value" ,
1961
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet68/1" , "Pfcwd" ),
1990
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet68/1" , "Pfcwd" ),
1962
1991
updates : []tablePathValue {
1963
1992
{
1964
1993
dbName : "COUNTERS_DB" ,
@@ -1986,7 +2015,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
1986
2015
},
1987
2016
{
1988
2017
desc : "stream query for table key Ethernet* with new test_field field on Ethernet68" ,
1989
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet*" ),
2018
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet*" ),
1990
2019
updates : []tablePathValue {
1991
2020
{
1992
2021
dbName : "COUNTERS_DB" ,
@@ -2014,7 +2043,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
2014
2043
},
2015
2044
{
2016
2045
desc : "stream query for table key Ethernet*/SAI_PORT_STAT_PFC_7_RX_PKTS with field value update" ,
2017
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet*" , "SAI_PORT_STAT_PFC_7_RX_PKTS" ),
2046
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet*" , "SAI_PORT_STAT_PFC_7_RX_PKTS" ),
2018
2047
updates : []tablePathValue {
2019
2048
{
2020
2049
dbName : "COUNTERS_DB" ,
@@ -2034,7 +2063,7 @@ func runTestSubscribe(t *testing.T, namespace string) {
2034
2063
},
2035
2064
{
2036
2065
desc : "stream query for table key Ethernet*/Pfcwd with field value update" ,
2037
- q : createCountersDbQueryOnChangeMode (t , "COUNTERS" , "Ethernet*" , "Pfcwd" ),
2066
+ q : createCountersDbQueryOnChangeMode (t , 0 , "COUNTERS" , "Ethernet*" , "Pfcwd" ),
2038
2067
updates : []tablePathValue {
2039
2068
{
2040
2069
dbName : "COUNTERS_DB" ,
0 commit comments