@@ -21,6 +21,7 @@ import (
21
21
"testing"
22
22
"time"
23
23
24
+ "github.com/anishathalye/porcupine"
24
25
"github.com/stretchr/testify/require"
25
26
"go.uber.org/zap/zaptest"
26
27
@@ -1835,6 +1836,155 @@ func TestValidateWatch(t *testing.T) {
1835
1836
},
1836
1837
expectError : errBrokeFilter .Error (),
1837
1838
},
1839
+ {
1840
+ name : "Linearizable - ordered events match linearization - pass" ,
1841
+ reports : []report.ClientReport {
1842
+ {
1843
+ Watch : []model.WatchOperation {
1844
+ {
1845
+ Request : model.WatchRequest {
1846
+ WithPrefix : true ,
1847
+ },
1848
+ Responses : []model.WatchResponse {
1849
+ {
1850
+ Events : []model.WatchEvent {
1851
+ putWatchEvent ("a" , "1" , 2 , true ),
1852
+ putWatchEvent ("b" , "2" , 3 , true ),
1853
+ },
1854
+ },
1855
+ },
1856
+ },
1857
+ },
1858
+ KeyValue : []porcupine.Operation {
1859
+ {
1860
+ Input : putRequest ("a" , "1" ),
1861
+ Call : 1 ,
1862
+ Return : 2 ,
1863
+ },
1864
+ {
1865
+ Input : putRequest ("b" , "2" ),
1866
+ Call : 3 ,
1867
+ Return : 4 ,
1868
+ },
1869
+ },
1870
+ },
1871
+ },
1872
+ persistedRequests : []model.EtcdRequest {
1873
+ putRequest ("a" , "1" ),
1874
+ putRequest ("b" , "2" ),
1875
+ },
1876
+ },
1877
+ {
1878
+ name : "Linearizable - concurrent atomic txn - pass" ,
1879
+ reports : []report.ClientReport {
1880
+ {
1881
+ Watch : []model.WatchOperation {
1882
+ {
1883
+ Request : model.WatchRequest {
1884
+ WithPrefix : true ,
1885
+ },
1886
+ Responses : []model.WatchResponse {
1887
+ {
1888
+ Events : []model.WatchEvent {
1889
+ putWatchEvent ("a" , "1" , 2 , true ),
1890
+ putWatchEvent ("b" , "2" , 2 , true ),
1891
+ },
1892
+ },
1893
+ },
1894
+ },
1895
+ },
1896
+ KeyValue : []porcupine.Operation {
1897
+ {
1898
+ Input : model.EtcdRequest {
1899
+ Type : model .Txn ,
1900
+ Txn : & model.TxnRequest {
1901
+ OperationsOnSuccess : []model.EtcdOperation {
1902
+ {
1903
+ Type : model .PutOperation ,
1904
+ Put : model.PutOptions {
1905
+ Key : "a" ,
1906
+ Value : model .ToValueOrHash ("1" ),
1907
+ },
1908
+ },
1909
+ {
1910
+ Type : model .PutOperation ,
1911
+ Put : model.PutOptions {
1912
+ Key : "b" ,
1913
+ Value : model .ToValueOrHash ("2" ),
1914
+ },
1915
+ },
1916
+ },
1917
+ },
1918
+ },
1919
+ Call : 1 ,
1920
+ Return : 2 ,
1921
+ },
1922
+ },
1923
+ },
1924
+ },
1925
+ persistedRequests : []model.EtcdRequest {
1926
+ {
1927
+ Type : model .Txn ,
1928
+ Txn : & model.TxnRequest {
1929
+ OperationsOnSuccess : []model.EtcdOperation {
1930
+ {
1931
+ Type : model .PutOperation ,
1932
+ Put : model.PutOptions {
1933
+ Key : "a" ,
1934
+ Value : model .ToValueOrHash ("1" ),
1935
+ },
1936
+ },
1937
+ {
1938
+ Type : model .PutOperation ,
1939
+ Put : model.PutOptions {
1940
+ Key : "b" ,
1941
+ Value : model .ToValueOrHash ("2" ),
1942
+ },
1943
+ },
1944
+ },
1945
+ },
1946
+ },
1947
+ },
1948
+ },
1949
+ {
1950
+ name : "Linearizable - non-atomic unordered events - fail" ,
1951
+ reports : []report.ClientReport {
1952
+ {
1953
+ Watch : []model.WatchOperation {
1954
+ {
1955
+ Request : model.WatchRequest {
1956
+ WithPrefix : true ,
1957
+ },
1958
+ Responses : []model.WatchResponse {
1959
+ {
1960
+ Events : []model.WatchEvent {
1961
+ putWatchEvent ("b" , "2" , 3 , true ),
1962
+ putWatchEvent ("a" , "1" , 2 , true ),
1963
+ },
1964
+ },
1965
+ },
1966
+ },
1967
+ },
1968
+ KeyValue : []porcupine.Operation {
1969
+ {
1970
+ Input : putRequest ("a" , "1" ),
1971
+ Call : 1 ,
1972
+ Return : 2 ,
1973
+ },
1974
+ {
1975
+ Input : putRequest ("b" , "2" ),
1976
+ Call : 3 ,
1977
+ Return : 4 ,
1978
+ },
1979
+ },
1980
+ },
1981
+ },
1982
+ persistedRequests : []model.EtcdRequest {
1983
+ putRequest ("a" , "1" ),
1984
+ putRequest ("b" , "2" ),
1985
+ },
1986
+ expectError : errBrokeOrdered .Error (),
1987
+ },
1838
1988
}
1839
1989
for _ , tc := range tcs {
1840
1990
t .Run (tc .name , func (t * testing.T ) {
0 commit comments