From 42723e2593926f1cfa144b503bf043a0fe36e657 Mon Sep 17 00:00:00 2001 From: Markku Virtanen Date: Tue, 15 Jun 2021 10:09:23 +0300 Subject: [PATCH] Added duplicate detection changes Change-Id: I85582e38a4bbe6c722a59439da30784f8039de3d Signed-off-by: Markku Virtanen --- go.sum | 68 +++++ pkg/control/control.go | 254 +++++++++++------- pkg/control/duplicate.go | 115 ++++++-- pkg/control/duplicate_test.go | 69 +++-- pkg/control/registry.go | 24 +- pkg/control/sdl_restSubsDb.go | 6 +- pkg/control/sdl_restSubsDb_test.go | 2 +- pkg/control/ut_messaging_test.go | 532 ++++++++++++++++++++++++++++++++++++- pkg/teststube2ap/stubE2.go | 3 +- 9 files changed, 922 insertions(+), 151 deletions(-) diff --git a/go.sum b/go.sum index 44f6a9c..8d66bc0 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= gerrit.o-ran-sc.org/r/com/golog.git v0.0.2 h1:Ix6SgFuzd6yW6Ur6+qDlGhDO65UYs8PiIkeAL1VaQ2o= gerrit.o-ran-sc.org/r/com/golog.git v0.0.2/go.mod h1:A7hUL52YQSO4dFIZNcj76XQ09C9PftAe3LyL7kqBnok= @@ -15,16 +16,22 @@ gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.3 h1:C5nhnmSZLdysSiQ7vMkpNaKro gerrit.o-ran-sc.org/r/ric-plt/xapp-frame.git v0.8.3/go.mod h1:MRTeTBLROgTA2t91SXYjTbRsxoOhMMvvkK/ChLVRZUU= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/agnivade/levenshtein v1.0.1 h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6 h1:G1bPvciwNyF7IUmKXNt9Ak3m6u9DE1rF+RmtIkBpVdA= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= @@ -32,17 +39,26 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:l github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.2.0 h1:3Jm3tLmsgAYcjC+4Up7hJrFBPr+n7rAqYeSw/SZazuY= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954 h1:RMLoZVzv4GliuWafOuPuQDKSm1SJph7uCRnnS61JAn4= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= @@ -51,12 +67,17 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-kit/kit v0.8.0 h1:Wz+5lgoB0kkuqLEc6NVmwRknTKP6dTGbSqvhZtBI/j0= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0 h1:MP4Eh7ZCb31lleYCFuwm0oe4/YGak+5l1vA2NOE80nA= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= @@ -115,9 +136,13 @@ github.com/go-redis/redis v6.15.9+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8w github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef h1:veQD95Isof8w9/WXiA+pa3tz3fJXkt5B7QaRBrM62gk= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -130,6 +155,7 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -142,9 +168,13 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.7.1 h1:Dw4jY2nghMMRsh1ol8dv1axHkDwMQK2DHerMNJsIpJU= github.com/gorilla/mux v1.7.1/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 h1:Iju5GlWwrvL6UBg4zJJt3btmonfrMlCDdsejg4CZE7c= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0 h1:bM6ZAFZmc/wPFaRDi0d5L7hGEZEx/2u+Tmr2evNHDiI= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -152,15 +182,22 @@ github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0 h1:ZqfnKyx9KGpRcW04j5nnPDgRgoXUeLh2YFBeFzphcA0= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.5 h1:hyz3dwM5QLc1Rfoz4FuWJQG5BN7tc6K1MndAUnGpQr4= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -176,9 +213,11 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223 h1:F9x/1yl3T2AeKLr2AMdilSD8+f9bvMnNN8VS5iDtovc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -187,6 +226,7 @@ github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9k github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -207,13 +247,19 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084 h1:sofwID9zm4tzrgykg80hfFph1mryUeLRsUfoocVVmRY= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af h1:gu+uRPtBe88sKxUCEXRoeCvVG90TJmwhiqRpvdhQFng= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/segmentio/ksuid v1.0.3 h1:FoResxvleQwYiPAVKe1tMUlEirodZqlqglIuFsdDntY= github.com/segmentio/ksuid v1.0.3/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= @@ -238,25 +284,36 @@ github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/vektah/gqlparser v1.1.2 h1:ZsyLGn7/7jDNI+y4SEhI4yAxRChlv15pUHMjijT+e68= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77 h1:ESFSdwYZvkeru3RtdrYueztKhOBCSAAzS4Gf+k0tEow= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.2 h1:Z/90sZLPOeCy2PwprqkFa25PdkusRzaj9P8zm/KNyvk= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.2 h1:jxcFYjlkl8xaERsgLo+RNquI0epW6zuy/ZRQs6jnrFA= go.mongodb.org/mongo-driver v1.1.2/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56 h1:ZpKuNIejY8P0ExLOVyKhb0WsgG8UdvHXe6TWjY7eL6k= golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -272,10 +329,12 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -296,6 +355,7 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -303,12 +363,16 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190617190820-da514acc4774 h1:CQVOmarCBFzTx0kbOU0ru54Cvot8SdSrNYjZPhQl+gk= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRSs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -317,12 +381,14 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/resty.v1 v1.12.0 h1:CuXP0Pjfw9rOuY6EP+UvtNvt5DSqHpIxILZKT/quCZI= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -333,7 +399,9 @@ gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099 h1:XJP7lxbSxWLOMNdBE4B/STaqVy6L73o0knwj2vIlxnw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/klog/v2 v2.0.0 h1:Foj74zO6RbjjP4hBEKjnYtjjAhGg4jNynUdYF6fJrok= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/utils v0.0.0-20201110183641-67b214c5f920 h1:CbnUZsM497iRC5QMVkHwyl8s2tB3g7yaSHkYPkpgelw= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= diff --git a/pkg/control/control.go b/pkg/control/control.go index c74b1a5..4df7676 100755 --- a/pkg/control/control.go +++ b/pkg/control/control.go @@ -46,8 +46,12 @@ func idstring(err error, entries ...fmt.Stringer) string { var retval string = "" var filler string = "" for _, entry := range entries { - retval += filler + entry.String() - filler = " " + if entry != nil { + retval += filler + entry.String() + filler = " " + } else { + retval += filler + "(NIL)" + } } if err != nil { retval += filler + "err(" + err.Error() + ")" @@ -237,6 +241,63 @@ func (c *Control) Run() { xapp.Run(c) } +//------------------------------------------------------------------- +// +//------------------------------------------------------------------- +func (c *Control) GetOrCreateRestSubscription(p *models.SubscriptionParams, md5sum string, xAppRmrEndpoint string) (*RESTSubscription, string, error) { + + var restSubId string + var restSubscription *RESTSubscription + var err error + + prevRestSubsId, exists := restDuplicateCtrl.GetLastKnownRestSubsIdBasedOnMd5sum(md5sum) + if p.SubscriptionID == "" { + if exists { + restSubscription, err = c.registry.GetRESTSubscription(prevRestSubsId, false) + if restSubscription != nil { + restSubId = prevRestSubsId + if err == nil { + xapp.Logger.Info("Existing restSubId %s found by MD5sum %s for a request without subscription ID - using previous subscription", prevRestSubsId, md5sum) + } else { + xapp.Logger.Info("Existing restSubId %s found by MD5sum %s for a request without subscription ID - Note: %s", prevRestSubsId, md5sum, err.Error()) + } + } else { + xapp.Logger.Info("None existing restSubId %s referred by MD5sum %s for a request without subscription ID - deleting cached entry", prevRestSubsId, md5sum) + restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum) + } + } + + if restSubscription == nil { + restSubId = ksuid.New().String() + restSubscription, err = c.registry.CreateRESTSubscription(&restSubId, &xAppRmrEndpoint, p.Meid) + if err != nil { + xapp.Logger.Error("%s", err.Error()) + c.UpdateCounter(cRestSubFailToXapp) + return nil, "", err + } + } + } else { + restSubId = p.SubscriptionID + + xapp.Logger.Info("RestSubscription ID %s provided via REST request", restSubId) + + restSubscription, err = c.registry.GetRESTSubscription(restSubId, false) + if err != nil { + xapp.Logger.Error("%s", err.Error()) + c.UpdateCounter(cRestSubFailToXapp) + return nil, "", err + } + + if !exists { + xapp.Logger.Info("Existing restSubscription found for ID %s, new request based on md5sum", restSubId) + } else { + xapp.Logger.Info("Existing restSubscription found for ID %s(%s), re-transmission based on md5sum match with previous request", prevRestSubsId, restSubId) + } + } + + return restSubscription, restSubId, nil +} + //------------------------------------------------------------------- // //------------------------------------------------------------------- @@ -264,25 +325,16 @@ func (c *Control) SubscriptionHandler(params interface{}) (*models.SubscriptionR c.UpdateCounter(cRestSubFailToXapp) return nil, err } - var restSubId string - var restSubscription *RESTSubscription - if p.SubscriptionID == "" { - restSubId = ksuid.New().String() - restSubscription, err = c.registry.CreateRESTSubscription(&restSubId, &xAppRmrEndpoint, p.Meid) - if err != nil { - xapp.Logger.Error("%s", err.Error()) - c.UpdateCounter(cRestSubFailToXapp) - return nil, err - } - } else { - restSubId = p.SubscriptionID - restSubscription, err = c.registry.GetRESTSubscription(restSubId, false) - if err != nil { - xapp.Logger.Error("%s", err.Error()) - c.UpdateCounter(cRestSubFailToXapp) - return nil, err - } + md5sum, err := CalculateRequestMd5sum(params) + if err != nil { + xapp.Logger.Error("Failed to generate md5sum from incoming request - %s", err.Error()) + } + + restSubscription, restSubId, err := c.GetOrCreateRestSubscription(p, md5sum, xAppRmrEndpoint) + if err != nil { + xapp.Logger.Error("Failed to get/allocate REST subscription") + return nil, err } subResp.SubscriptionID = &restSubId @@ -290,103 +342,38 @@ func (c *Control) SubscriptionHandler(params interface{}) (*models.SubscriptionR err = c.e2ap.FillSubscriptionReqMsgs(params, &subReqList, restSubscription) if err != nil { xapp.Logger.Error("%s", err.Error()) + restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum) c.registry.DeleteRESTSubscription(&restSubId) c.UpdateCounter(cRestSubFailToXapp) return nil, err } - err, duplicate, md5sum := restDuplicateCtrl.IsDuplicateToOngoingTransaction(restSubId, params) - - if err != nil { - // We were unable to detect whether this request was duplicate or not, proceed - xapp.Logger.Info("%s - proceeding with the request", err.Error()) - } else { - if duplicate { - if *p.SubscriptionDetails[0].ActionToBeSetupList[0].ActionType == "report" { - xapp.Logger.Info("Retransmission blocker dropped for report typer of request") - c.UpdateCounter(cRestSubRespToXapp) - return &subResp, nil - } - } - restSubscription.Md5sum = md5sum + duplicate := restDuplicateCtrl.IsDuplicateToOngoingTransaction(restSubId, md5sum) + if duplicate { + xapp.Logger.Info("Retransmission blocker direct ACK for request of restSubsId %s restSubId MD5sum %s as retransmission", restSubId, md5sum) + c.UpdateCounter(cRestSubRespToXapp) + return &subResp, nil } - c.WriteRESTSubscriptionToDb(restSubId, restSubscription) - - go c.processSubscriptionRequests(restSubscription, &subReqList, p.ClientEndpoint, p.Meid, &restSubId, xAppRmrEndpoint) + go c.processSubscriptionRequests(restSubscription, &subReqList, p.ClientEndpoint, p.Meid, &restSubId, xAppRmrEndpoint, md5sum) c.UpdateCounter(cRestSubRespToXapp) return &subResp, nil } -func (c *Control) sendUnsuccesfullResponseNotification(restSubId *string, restSubscription *RESTSubscription, xAppEventInstanceID int64, err error, - clientEndpoint *models.SubscriptionParamsClientEndpoint, trans *TransactionXapp) { - - // Send notification to xApp that prosessing of a Subscription Request has failed. - e2EventInstanceID := (int64)(0) - errorCause := err.Error() - resp := &models.SubscriptionResponse{ - SubscriptionID: restSubId, - SubscriptionInstances: []*models.SubscriptionInstance{ - &models.SubscriptionInstance{E2EventInstanceID: &e2EventInstanceID, - ErrorCause: &errorCause, - XappEventInstanceID: &xAppEventInstanceID}, - }, - } - // Mark REST subscription request processed. - restSubscription.SetProcessed() - c.UpdateRESTSubscriptionInDB(*restSubId, restSubscription, false) - if trans != nil { - xapp.Logger.Info("Sending unsuccessful REST notification (cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s", - errorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans)) - } else { - xapp.Logger.Info("Sending unsuccessful REST notification (cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v", - errorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID) - } - - c.UpdateCounter(cRestSubFailNotifToXapp) - xapp.Subscription.Notify(resp, *clientEndpoint) -} - -func (c *Control) sendSuccesfullResponseNotification(restSubId *string, restSubscription *RESTSubscription, xAppEventInstanceID int64, e2EventInstanceID int64, - clientEndpoint *models.SubscriptionParamsClientEndpoint, trans *TransactionXapp) { - - // Store successfully processed InstanceId for deletion - restSubscription.AddE2InstanceId((uint32)(e2EventInstanceID)) - restSubscription.AddXappIdToE2Id(xAppEventInstanceID, e2EventInstanceID) - - // Send notification to xApp that a Subscription Request has been processed. - resp := &models.SubscriptionResponse{ - SubscriptionID: restSubId, - SubscriptionInstances: []*models.SubscriptionInstance{ - &models.SubscriptionInstance{E2EventInstanceID: &e2EventInstanceID, - ErrorCause: nil, - XappEventInstanceID: &xAppEventInstanceID}, - }, - } - // Mark REST subscription request processesd. - restSubscription.SetProcessed() - c.UpdateRESTSubscriptionInDB(*restSubId, restSubscription, false) - xapp.Logger.Info("Sending successful REST notification to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s", - clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans)) - - c.UpdateCounter(cRestSubNotifToXapp) - xapp.Subscription.Notify(resp, *clientEndpoint) -} - //------------------------------------------------------------------- // //------------------------------------------------------------------- func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription, subReqList *e2ap.SubscriptionRequestList, - clientEndpoint *models.SubscriptionParamsClientEndpoint, meid *string, restSubId *string, xAppRmrEndpoint string) { + clientEndpoint *models.SubscriptionParamsClientEndpoint, meid *string, restSubId *string, xAppRmrEndpoint string, md5sum string) { xapp.Logger.Info("Subscription Request count=%v ", len(subReqList.E2APSubscriptionRequests)) var xAppEventInstanceID int64 var e2EventInstanceID int64 - defer restDuplicateCtrl.TransactionComplete(restSubscription.Md5sum) + defer restDuplicateCtrl.SetMd5sumFromLastOkRequest(*restSubId, md5sum) for index := 0; index < len(subReqList.E2APSubscriptionRequests); index++ { subReqMsg := subReqList.E2APSubscriptionRequests[index] @@ -402,13 +389,17 @@ func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription xapp.Logger.Info("Handle SubscriptionRequest index=%v, %s", index, idstring(nil, trans)) - subRespMsg, err := c.handleSubscriptionRequest(trans, &subReqMsg, meid, restSubId) + subRespMsg, err := c.handleSubscriptionRequest(trans, &subReqMsg, meid, *restSubId) + + xapp.Logger.Info("Handled SubscriptionRequest index=%v, %s", index, idstring(nil, trans)) + if err != nil { c.sendUnsuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, err, clientEndpoint, trans) } else { e2EventInstanceID = (int64)(subRespMsg.RequestId.InstanceId) - xapp.Logger.Info("SubscriptionRequest index=%v processed successfully. endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s", - index, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans)) + restSubscription.AddMd5Sum(md5sum) + xapp.Logger.Info("SubscriptionRequest index=%v processed successfullyfor %s. endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s", + index, *restSubId, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans)) c.sendSuccesfullResponseNotification(restSubId, restSubscription, xAppEventInstanceID, e2EventInstanceID, clientEndpoint, trans) } trans.Release() @@ -419,7 +410,7 @@ func (c *Control) processSubscriptionRequests(restSubscription *RESTSubscription // //------------------------------------------------------------------ func (c *Control) handleSubscriptionRequest(trans *TransactionXapp, subReqMsg *e2ap.E2APSubscriptionRequest, meid *string, - restSubId *string) (*e2ap.E2APSubscriptionResponse, error) { + restSubId string) (*e2ap.E2APSubscriptionResponse, error) { err := c.tracker.Track(trans) if err != nil { @@ -462,6 +453,67 @@ func (c *Control) handleSubscriptionRequest(trans *TransactionXapp, subReqMsg *e return nil, err } +//------------------------------------------------------------------- +// +//------------------------------------------------------------------- +func (c *Control) sendUnsuccesfullResponseNotification(restSubId *string, restSubscription *RESTSubscription, xAppEventInstanceID int64, err error, + clientEndpoint *models.SubscriptionParamsClientEndpoint, trans *TransactionXapp) { + + // Send notification to xApp that prosessing of a Subscription Request has failed. + e2EventInstanceID := (int64)(0) + errorCause := err.Error() + resp := &models.SubscriptionResponse{ + SubscriptionID: restSubId, + SubscriptionInstances: []*models.SubscriptionInstance{ + &models.SubscriptionInstance{E2EventInstanceID: &e2EventInstanceID, + ErrorCause: &errorCause, + XappEventInstanceID: &xAppEventInstanceID}, + }, + } + // Mark REST subscription request processed. + restSubscription.SetProcessed(err) + c.UpdateRESTSubscriptionInDB(*restSubId, restSubscription, false) + if trans != nil { + xapp.Logger.Info("Sending unsuccessful REST notification (cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s", + errorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans)) + } else { + xapp.Logger.Info("Sending unsuccessful REST notification (cause %s) to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v", + errorCause, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID) + } + + c.UpdateCounter(cRestSubFailNotifToXapp) + xapp.Subscription.Notify(resp, *clientEndpoint) +} + +//------------------------------------------------------------------- +// +//------------------------------------------------------------------- +func (c *Control) sendSuccesfullResponseNotification(restSubId *string, restSubscription *RESTSubscription, xAppEventInstanceID int64, e2EventInstanceID int64, + clientEndpoint *models.SubscriptionParamsClientEndpoint, trans *TransactionXapp) { + + // Store successfully processed InstanceId for deletion + restSubscription.AddE2InstanceId((uint32)(e2EventInstanceID)) + restSubscription.AddXappIdToE2Id(xAppEventInstanceID, e2EventInstanceID) + + // Send notification to xApp that a Subscription Request has been processed. + resp := &models.SubscriptionResponse{ + SubscriptionID: restSubId, + SubscriptionInstances: []*models.SubscriptionInstance{ + &models.SubscriptionInstance{E2EventInstanceID: &e2EventInstanceID, + ErrorCause: nil, + XappEventInstanceID: &xAppEventInstanceID}, + }, + } + // Mark REST subscription request processesd. + restSubscription.SetProcessed(nil) + c.UpdateRESTSubscriptionInDB(*restSubId, restSubscription, false) + xapp.Logger.Info("Sending successful REST notification to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s", + clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans)) + + c.UpdateCounter(cRestSubNotifToXapp) + xapp.Subscription.Notify(resp, *clientEndpoint) +} + //------------------------------------------------------------------- // //------------------------------------------------------------------- @@ -492,6 +544,7 @@ func (c *Control) SubscriptionDeleteHandlerCB(restSubId string) error { xAppRmrEndPoint := restSubscription.xAppRmrEndPoint go func() { + xapp.Logger.Info("Deleteting instances = %v", restSubscription.InstanceIds) for _, instanceId := range restSubscription.InstanceIds { xAppEventInstanceID, err := c.SubscriptionDeleteHandler(&restSubId, &xAppRmrEndPoint, &restSubscription.Meid, instanceId) @@ -503,6 +556,7 @@ func (c *Control) SubscriptionDeleteHandlerCB(restSubId string) error { restSubscription.DeleteXappIdToE2Id(xAppEventInstanceID) restSubscription.DeleteE2InstanceId(instanceId) } + restDuplicateCtrl.DeleteLastKnownRestSubsIdBasedOnMd5sum(restSubscription.lastReqMd5sum) c.registry.DeleteRESTSubscription(&restSubId) c.RemoveRESTSubscriptionFromDb(restSubId) }() @@ -828,14 +882,14 @@ func (c *Control) handleSubscriptionCreate(subs *Subscription, parentTrans *Tran case *e2ap.E2APSubscriptionFailure: removeSubscriptionFromDb = true subRfMsg, valid = subs.SetCachedResponse(event, false) - xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans)) + xapp.Logger.Info("SUBS-SubReq: internal delete due failure event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans)) c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans) case *SubmgrRestartTestEvent: // This simulates that no response has been received and after restart subscriptions are restored from db xapp.Logger.Debug("Test restart flag is active. Dropping this transaction to test restart case") return default: - xapp.Logger.Info("SUBS-SubReq: internal delete due event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans)) + xapp.Logger.Info("SUBS-SubReq: internal delete due default event(%s) %s", typeofSubsMessage(event), idstring(nil, trans, subs, parentTrans)) removeSubscriptionFromDb = true subRfMsg, valid = subs.SetCachedResponse(nil, false) c.sendE2TSubscriptionDeleteRequest(subs, trans, parentTrans) diff --git a/pkg/control/duplicate.go b/pkg/control/duplicate.go index c6d0c8c..6900941 100644 --- a/pkg/control/duplicate.go +++ b/pkg/control/duplicate.go @@ -36,64 +36,141 @@ type retransEntry struct { } type duplicateCtrl struct { - mutex sync.Mutex - retransMap map[string]retransEntry - collCount int + mutex sync.Mutex + ongoingRequestMap map[string]retransEntry + previousRequestMap map[string]string + collCount int } func (d *duplicateCtrl) Init() { - d.retransMap = make(map[string]retransEntry) + d.ongoingRequestMap = make(map[string]retransEntry) + d.previousRequestMap = make(map[string]string) } -func (d *duplicateCtrl) IsDuplicateToOngoingTransaction(restSubsId string, payload interface{}) (error, bool, string) { +func (d *duplicateCtrl) SetMd5sumFromLastOkRequest(restSubsId string, md5sum string) { + d.mutex.Lock() + defer d.mutex.Unlock() + + if md5sum == "" { + xapp.Logger.Error("Attempt to store empty md5sum for restubsId %s retransmission map skipped", restSubsId) + return + } + + d.removeOngoingTransaction(md5sum) + + prevRestSubsId, exists := d.previousRequestMap[md5sum] + + if exists { + if prevRestSubsId != restSubsId { + xapp.Logger.Error("Storing md5sum for a processed request for restSubsId %s md5sum %s over a previous restSubsId %s", restSubsId, md5sum, prevRestSubsId) + } else { + return + } + } else { + xapp.Logger.Debug("Storing md5sum for a processed request for restSubsId %s md5sum %s", restSubsId, md5sum) + } + + d.previousRequestMap[md5sum] = restSubsId +} + +func (d *duplicateCtrl) GetLastKnownRestSubsIdBasedOnMd5sum(md5sum string) (string, bool) { + + d.mutex.Lock() + defer d.mutex.Unlock() + + if md5sum == "" { + return "", false + } + + m, e := d.previousRequestMap[md5sum] + + return m, e +} + +func (d *duplicateCtrl) DeleteLastKnownRestSubsIdBasedOnMd5sum(md5sum string) { + + d.mutex.Lock() + defer d.mutex.Unlock() + + restSubsId, exists := d.previousRequestMap[md5sum] + + if !exists { + if md5sum == "" { + xapp.Logger.Info("Attempted to delete a cached md5sum, md5sum not set yet") + } else { + xapp.Logger.Error("Attempted to delete a cached md5sum %s, but the value was not found", md5sum) + } + } else { + xapp.Logger.Debug("Deleted a cached md5sum %s for restSubsId %s", md5sum, restSubsId) + delete(d.previousRequestMap, md5sum) + } +} + +func CalculateRequestMd5sum(payload interface{}) (string, error) { var data bytes.Buffer enc := gob.NewEncoder(&data) if err := enc.Encode(payload); err != nil { - xapp.Logger.Error("Failed to encode %v\n", payload) - return err, false, "" + xapp.Logger.Error("%s", err.Error()) + return "", err } hash := md5.Sum(data.Bytes()) - md5sum := hex.EncodeToString(hash[:]) + return hex.EncodeToString(hash[:]), nil +} + +func (d *duplicateCtrl) IsDuplicateToOngoingTransaction(restSubsId string, md5sum string) bool { + + if md5sum == "" { + return false + } d.mutex.Lock() defer d.mutex.Unlock() - entry, present := d.retransMap[md5sum] + entry, present := d.ongoingRequestMap[md5sum] if present { - xapp.Logger.Info("Collision detected. REST subs ID %s has ongoing transaction with MD5SUM : %s started at %s\n", entry.restSubsId, md5sum, entry.startTime.Format(time.ANSIC)) + xapp.Logger.Info("Collision detected. REST subs ID %s has ongoing transaction with md5sum : %s started at %s\n", entry.restSubsId, md5sum, entry.startTime.Format(time.ANSIC)) d.collCount++ - return nil, true, md5sum + return true } entry = retransEntry{restSubsId: restSubsId, startTime: time.Now()} - xapp.Logger.Debug("Added Md5SUM %s for restSubsId %s at %s\n", md5sum, entry.restSubsId, entry.startTime) + xapp.Logger.Debug("No collision detected against ongoing transaction. Added md5sum %s for restSubsId %s at %s\n", md5sum, entry.restSubsId, entry.startTime) - d.retransMap[md5sum] = entry + d.ongoingRequestMap[md5sum] = entry - return nil, false, md5sum + return false } func (d *duplicateCtrl) TransactionComplete(md5sum string) error { + if md5sum == "" { + return nil + } + d.mutex.Lock() defer d.mutex.Unlock() - entry, present := d.retransMap[md5sum] + return d.removeOngoingTransaction(md5sum) +} + +func (d *duplicateCtrl) removeOngoingTransaction(md5sum string) error { + + entry, present := d.ongoingRequestMap[md5sum] if !present { - xapp.Logger.Error("MD5SUM : %s NOT found from table (%v)\n", md5sum, entry) - return fmt.Errorf("Retransmission entry not found for MD5SUM %s", md5sum) + xapp.Logger.Error("md5sum : %s NOT found from retransmission table", md5sum) + return fmt.Errorf("Retransmission entry not found for md5sum %s", md5sum) } - xapp.Logger.Debug("Releasing transaction duplicate blocker for %s, MD5SUM : %s\n", entry.restSubsId, md5sum) + xapp.Logger.Debug("Releasing transaction duplicate blocker for %s, md5sum : %s\n", entry.restSubsId, md5sum) - delete(d.retransMap, md5sum) + delete(d.ongoingRequestMap, md5sum) return nil } diff --git a/pkg/control/duplicate_test.go b/pkg/control/duplicate_test.go index 0b33906..f072881 100644 --- a/pkg/control/duplicate_test.go +++ b/pkg/control/duplicate_test.go @@ -44,14 +44,17 @@ func TestDefaultUseCase(t *testing.T) { retransCtrl.Init() - _, duplicate, md5sum := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, data) + md5sum, err := CalculateRequestMd5sum(data) + assert.Empty(t, err) + + duplicate := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, md5sum) - assert.Equal(t, 1, len(retransCtrl.retransMap)) + assert.Equal(t, 1, len(retransCtrl.ongoingRequestMap)) assert.Equal(t, false, duplicate) retransCtrl.TransactionComplete(md5sum) - assert.Equal(t, 0, len(retransCtrl.retransMap)) + assert.Equal(t, 0, len(retransCtrl.ongoingRequestMap)) } func TestDuplicate(t *testing.T) { @@ -75,17 +78,23 @@ func TestDuplicate(t *testing.T) { retransCtrl.Init() - _, duplicate, md5sum := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, data) - assert.Equal(t, 1, len(retransCtrl.retransMap)) + md5sum, err := CalculateRequestMd5sum(data) + assert.Empty(t, err) + + duplicate := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, md5sum) + assert.Equal(t, 1, len(retransCtrl.ongoingRequestMap)) assert.Equal(t, false, duplicate) - _, duplicate, md5sum = retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, data2) - assert.Equal(t, 1, len(retransCtrl.retransMap)) + md5sum, err = CalculateRequestMd5sum(data2) + assert.Empty(t, err) + + duplicate = retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, md5sum) + assert.Equal(t, 1, len(retransCtrl.ongoingRequestMap)) assert.Equal(t, true, duplicate) retransCtrl.TransactionComplete(md5sum) - assert.Equal(t, 0, len(retransCtrl.retransMap)) + assert.Equal(t, 0, len(retransCtrl.ongoingRequestMap)) } func TestNoneDuplicate(t *testing.T) { @@ -109,18 +118,24 @@ func TestNoneDuplicate(t *testing.T) { retransCtrl.Init() - _, duplicate, md5sum := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, data) - assert.Equal(t, 1, len(retransCtrl.retransMap)) + md5sum, err := CalculateRequestMd5sum(data) + assert.Empty(t, err) + + duplicate := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, md5sum) + assert.Equal(t, 1, len(retransCtrl.ongoingRequestMap)) assert.Equal(t, false, duplicate) - _, duplicate2, md5sum2 := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, data2) - assert.Equal(t, 2, len(retransCtrl.retransMap)) + md5sum2, err := CalculateRequestMd5sum(data2) + assert.Empty(t, err) + + duplicate2 := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, md5sum2) + assert.Equal(t, 2, len(retransCtrl.ongoingRequestMap)) assert.Equal(t, false, duplicate2) retransCtrl.TransactionComplete(md5sum) retransCtrl.TransactionComplete(md5sum2) - assert.Equal(t, 0, len(retransCtrl.retransMap)) + assert.Equal(t, 0, len(retransCtrl.ongoingRequestMap)) } func TestEncodingError(t *testing.T) { @@ -128,15 +143,12 @@ func TestEncodingError(t *testing.T) { fmt.Println("##################### TestEncodingError #####################") var retransCtrl duplicateCtrl - restSubdId := "898dfkjashntgkjasgho4" var data interface{} retransCtrl.Init() - err, duplicate, _ := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, data) + _, err := CalculateRequestMd5sum(data) assert.NotEqual(t, err, nil) - assert.Equal(t, 0, len(retransCtrl.retransMap)) - assert.Equal(t, false, duplicate) } func TestRemovalError(t *testing.T) { @@ -149,8 +161,11 @@ func TestRemovalError(t *testing.T) { retransCtrl.Init() - err, duplicate, md5sum := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, data) - assert.Equal(t, 1, len(retransCtrl.retransMap)) + md5sum, err := CalculateRequestMd5sum(data) + assert.Empty(t, err) + + duplicate := retransCtrl.IsDuplicateToOngoingTransaction(restSubdId, md5sum) + assert.Equal(t, 1, len(retransCtrl.ongoingRequestMap)) assert.Equal(t, false, duplicate) err = retransCtrl.TransactionComplete(md5sum) @@ -171,15 +186,21 @@ func TestXappRestReqDuplicate(t *testing.T) { retransCtrl.Init() - _, duplicate, md5sum := retransCtrl.IsDuplicateToOngoingTransaction("foobar", msg1) - assert.Equal(t, 1, len(retransCtrl.retransMap)) + md5sum, err := CalculateRequestMd5sum(msg1) + assert.Empty(t, err) + + duplicate := retransCtrl.IsDuplicateToOngoingTransaction("foobar", md5sum) + assert.Equal(t, 1, len(retransCtrl.ongoingRequestMap)) assert.Equal(t, false, duplicate) - _, duplicate, md5sum = retransCtrl.IsDuplicateToOngoingTransaction("foobar", msg2) - assert.Equal(t, 1, len(retransCtrl.retransMap)) + md5sum2, err := CalculateRequestMd5sum(msg2) + assert.Empty(t, err) + + duplicate = retransCtrl.IsDuplicateToOngoingTransaction("foobar", md5sum2) + assert.Equal(t, 1, len(retransCtrl.ongoingRequestMap)) assert.Equal(t, true, duplicate) retransCtrl.TransactionComplete(md5sum) - assert.Equal(t, 0, len(retransCtrl.retransMap)) + assert.Equal(t, 0, len(retransCtrl.ongoingRequestMap)) } diff --git a/pkg/control/registry.go b/pkg/control/registry.go index 671cf51..2495d3b 100644 --- a/pkg/control/registry.go +++ b/pkg/control/registry.go @@ -40,13 +40,29 @@ type RESTSubscription struct { xAppIdToE2Id map[int64]int64 SubReqOngoing bool SubDelReqOngoing bool - Md5sum string + lastReqMd5sum string } func (r *RESTSubscription) AddE2InstanceId(instanceId uint32) { + + for _, v := range r.InstanceIds { + if v == instanceId { + return + } + + } + r.InstanceIds = append(r.InstanceIds, instanceId) } +func (r *RESTSubscription) AddMd5Sum(md5sum string) { + if md5sum != "" { + r.lastReqMd5sum = md5sum + } else { + xapp.Logger.Error("EMPTY md5sum attempted to be add to subscrition") + } +} + func (r *RESTSubscription) DeleteE2InstanceId(instanceId uint32) { r.InstanceIds = r.InstanceIds[1:] } @@ -63,9 +79,11 @@ func (r *RESTSubscription) DeleteXappIdToE2Id(xAppEventInstanceID int64) { delete(r.xAppIdToE2Id, xAppEventInstanceID) } -func (r *RESTSubscription) SetProcessed() { +func (r *RESTSubscription) SetProcessed(err error) { r.SubReqOngoing = false - r.Md5sum = "" + if err != nil { + r.lastReqMd5sum = "" + } } type Registry struct { diff --git a/pkg/control/sdl_restSubsDb.go b/pkg/control/sdl_restSubsDb.go index 782108f..1c46856 100644 --- a/pkg/control/sdl_restSubsDb.go +++ b/pkg/control/sdl_restSubsDb.go @@ -50,7 +50,7 @@ func (c *Control) WriteRESTSubscriptionToSdl(restSubId string, restSubs *RESTSub restSubscriptionInfo.xAppIdToE2Id = restSubs.xAppIdToE2Id restSubscriptionInfo.SubReqOngoing = restSubs.SubReqOngoing restSubscriptionInfo.SubDelReqOngoing = restSubs.SubDelReqOngoing - restSubscriptionInfo.Md5sum = restSubs.Md5sum + restSubscriptionInfo.Md5sum = restSubs.lastReqMd5sum jsonData, err := json.Marshal(restSubscriptionInfo) if err != nil { @@ -93,6 +93,8 @@ func (c *Control) ReadRESTSubscriptionFromSdl(restSubId string) (*RESTSubscripti } restSubs = c.CreateRESTSubscription(restSubscriptionInfo, &jsonSubscriptionInfo) + + restDuplicateCtrl.SetMd5sumFromLastOkRequest(restSubId, restSubs.lastReqMd5sum) } return restSubs, nil } @@ -106,7 +108,7 @@ func (c *Control) CreateRESTSubscription(restSubscriptionInfo *RESTSubscriptionI restSubs.xAppIdToE2Id = restSubscriptionInfo.xAppIdToE2Id restSubs.SubReqOngoing = restSubscriptionInfo.SubReqOngoing restSubs.SubDelReqOngoing = restSubscriptionInfo.SubDelReqOngoing - restSubs.Md5sum = restSubscriptionInfo.Md5sum + restSubs.lastReqMd5sum = restSubscriptionInfo.Md5sum return restSubs } diff --git a/pkg/control/sdl_restSubsDb_test.go b/pkg/control/sdl_restSubsDb_test.go index ac3c8e3..12bf1eb 100644 --- a/pkg/control/sdl_restSubsDb_test.go +++ b/pkg/control/sdl_restSubsDb_test.go @@ -94,7 +94,7 @@ func CreateRESTSubscription(t *testing.T) *RESTSubscription { restSubscription.SubReqOngoing = true restSubscription.SubDelReqOngoing = false restSubscription.xAppIdToE2Id = make(map[int64]int64) - restSubscription.Md5sum = "856e9546f6f7b65a13a86996f2d1686a" + restSubscription.lastReqMd5sum = "856e9546f6f7b65b13a86956f2e16f6a" return restSubscription } diff --git a/pkg/control/ut_messaging_test.go b/pkg/control/ut_messaging_test.go index 69a9533..63ffaaf 100644 --- a/pkg/control/ut_messaging_test.go +++ b/pkg/control/ut_messaging_test.go @@ -2606,7 +2606,7 @@ func TestRESTSubReqRetransmission(t *testing.T) { Counter{cSubDelRespFromE2, 1}, Counter{cRestSubDelRespToXapp, 1}, }) - // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests + // Retry/duplicate will get the same way as the first request. // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending // second request from same xapp as doing it from xappConn1 would not work as notification would not be received @@ -2642,6 +2642,536 @@ func TestRESTSubReqRetransmission(t *testing.T) { mainCtrl.VerifyCounterValues(t) } +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [RETRANS1] | | | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [RETRANS2] | | | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | SubDelReq | | +// | |------------->| | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqRetransmissionV2(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV2") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 3}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) + + //1.st resend + restSubId_resend := xappConn1.SendRESTSubsReq(t, params) + + assert.Equal(t, restSubId_resend, restSubId) + + <-time.After(100 * time.Millisecond) + + //2.nd resend + restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params) + + assert.Equal(t, restSubId_resend2, restSubId) + + <-time.After(100 * time.Millisecond) + + deleteSubscription(t, xappConn1, e2termConn1, &restSubId) + + waitSubsCleanup(t, e2SubsId, 10) + + //Wait that subs is cleaned + mainCtrl.VerifyCounterValues(t) +} + +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| // The order of these events may vary +// | | SubReq | | +// | |------------->| | // The order of these events may vary +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [RETRANS, with RESTsubsId] | | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [RETRANS, without RESTsubsId] | | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | | SubDelReq | | +// | |------------->| | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqRetransmissionV3(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV3") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 1}, + Counter{cSubRespFromE2, 1}, + Counter{cRestSubNotifToXapp, 3}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 1}, + Counter{cSubDelRespFromE2, 1}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"}) + + <-time.After(100 * time.Millisecond) + + //1.st resend with subscription ID + params.SetSubscriptionID(&restSubId) + restSubId_resend := xappConn1.SendRESTSubsReq(t, params) + + assert.Equal(t, restSubId_resend, restSubId) + + <-time.After(100 * time.Millisecond) + + //2.nd resend without subscription ID (faking app restart) + params = xappConn1.GetRESTSubsReqReportParams(subReqCount) + restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params) + + assert.Equal(t, restSubId_resend2, restSubId) + + <-time.After(100 * time.Millisecond) + + deleteSubscription(t, xappConn1, e2termConn1, &restSubId) + + waitSubsCleanup(t, e2SubsId, 10) + + //Wait that subs is cleaned + mainCtrl.VerifyCounterValues(t) +} + +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [with RestSUbsId + one additional e2 subDetail] +// |---------------->| | | +// | RESTNotif1 | | | +// | [for initial e2 subDetail] | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [with RESTsubsId initial request] | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqRetransmissionV4(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV4") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 2}, + Counter{cSubRespFromE2, 2}, + Counter{cRestSubNotifToXapp, 4}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 2}, + Counter{cSubDelRespFromE2, 2}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + <-time.After(100 * time.Millisecond) + + // Send modified requst, this time with e2 subscriptions. + params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1) + params2.SetSubscriptionID(&restSubId) + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + xappConn1.WaitRESTNotificationForAnySubscriptionId(t) + // Resend the original request with an additional e2 subscription (detail), this time with restsubsid + restSubId_resend := xappConn1.SendRESTSubsReq(t, params2) + + crereq2, cremsg2 := e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId_resend) + e2termConn1.SendSubsResp(t, crereq2, cremsg2) + e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend) + assert.NotEqual(t, e2SubsId2, 0) + + <-time.After(100 * time.Millisecond) + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + params = xappConn1.GetRESTSubsReqReportParams(subReqCount) + params.SetSubscriptionID(&restSubId) + xappConn1.WaitRESTNotificationForAnySubscriptionId(t) + // Resend the original request again with only one e2 subscription (detail), this time with restsubsid + restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params) + assert.Equal(t, restSubId_resend, restSubId_resend2) + + // Delete both e2 subscriptions + xappConn1.SendRESTSubsDelReq(t, &restSubId) + e2SubsIds := []uint32{e2SubsId, e2SubsId2} + sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1) + + waitSubsCleanup(t, e2SubsId, 10) + + //Wait that subs is cleaned + mainCtrl.VerifyCounterValues(t) +} + +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [with RestSUbsId + one additional e2 subDetail] +// |---------------->| | | +// | RESTNotif1 | | | +// | [for initial e2 subDetail] | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [without RESTsubsId initial request] | +// |---------------->| | | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | | | +// +//----------------------------------------------------------------------------- + +func TestRESTSubReqRetransmissionV5(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV5") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 2}, + Counter{cSubRespFromE2, 2}, + Counter{cRestSubNotifToXapp, 4}, + Counter{cRestSubDelReqFromXapp, 1}, + Counter{cSubDelReqToE2, 2}, + Counter{cSubDelRespFromE2, 2}, + Counter{cRestSubDelRespToXapp, 1}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + <-time.After(100 * time.Millisecond) + + // Send modified requst, this time with e2 subscriptions. + params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1) + params2.SetSubscriptionID(&restSubId) + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + xappConn1.WaitRESTNotificationForAnySubscriptionId(t) + // Resend the original request with an additional e2 subscription (detail), this time with restsubsid + restSubId_resend := xappConn1.SendRESTSubsReq(t, params2) + + crereq2, cremsg2 := e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId_resend) + e2termConn1.SendSubsResp(t, crereq2, cremsg2) + e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend) + assert.NotEqual(t, e2SubsId2, 0) + + <-time.After(100 * time.Millisecond) + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + params = xappConn1.GetRESTSubsReqReportParams(subReqCount) + xappConn1.WaitRESTNotificationForAnySubscriptionId(t) + // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid + // md5sum shall find the original request + restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params) + assert.Equal(t, restSubId_resend, restSubId_resend2) + + // Delete both e2 subscriptions + xappConn1.SendRESTSubsDelReq(t, &restSubId) + e2SubsIds := []uint32{e2SubsId, e2SubsId2} + sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1) + + waitSubsCleanup(t, e2SubsId, 10) + + //Wait that subs is cleaned + mainCtrl.VerifyCounterValues(t) +} + +//----------------------------------------------------------------------------- +// stub stub stub +// +-------+ +---------+ +---------+ +---------+ +// | xapp | | submgr | | e2term | | rtmgr | +// +-------+ +---------+ +---------+ +---------+ +// | | | | +// | RESTSubReq | | | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubReq | | | +// | [with RestSUbsId + one additional e2 subDetail] +// |---------------->| | | +// | RESTNotif1 | | | +// | [for initial e2 subDetail] | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | RESTSubDelReq | | | +// |---------------->| | | +// | RESTSubDelResp| | | +// |<----------------| | | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | | SubDelReq | | +// | |------------->| | +// | | SubDelResp | | +// | |<-------------| | +// | RESTSubReq | | | +// | [with RESTsubsId initial request] | +// |---------------->| | | +// | RESTSubResp | | | +// |<----------------| | | +// | | RouteCreate | | +// | |--------------------------->| +// | | RouteResponse| | +// | |<---------------------------| +// | | SubReq | | +// | |------------->| | +// | | SubResp | | +// | |<-------------| | +// | RESTNotif1 | | | +// |<----------------| | | +// | | | | +// +//----------------------------------------------------------------------------- +func TestRESTSubReqRetransmissionV6(t *testing.T) { + CaseBegin("TestRESTSubReqRetransmissionV6") + + mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{ + Counter{cRestSubReqFromXapp, 3}, + Counter{cRestSubRespToXapp, 3}, + Counter{cSubReqToE2, 3}, + Counter{cSubRespFromE2, 3}, + Counter{cRestSubNotifToXapp, 4}, + Counter{cRestSubDelReqFromXapp, 2}, + Counter{cSubDelReqToE2, 3}, + Counter{cSubDelRespFromE2, 3}, + Counter{cRestSubDelRespToXapp, 2}, + }) + + params := xappConn1.GetRESTSubsReqReportParams(subReqCount) + + restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params) + + <-time.After(100 * time.Millisecond) + + // Send modified requst, this time with e2 subscriptions. + params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1) + params2.SetSubscriptionID(&restSubId) + + xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler) + xappConn1.WaitRESTNotificationForAnySubscriptionId(t) + // Resend the original request with an additional e2 subscription (detail), this time with restsubsid + restSubId_resend := xappConn1.SendRESTSubsReq(t, params2) + + crereq2, cremsg2 := e2termConn1.RecvSubsReq(t) + + xappConn1.ExpectRESTNotification(t, restSubId_resend) + e2termConn1.SendSubsResp(t, crereq2, cremsg2) + e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend) + assert.NotEqual(t, e2SubsId2, 0) + + <-time.After(100 * time.Millisecond) + + // Delete both e2 subscriptions + xappConn1.SendRESTSubsDelReq(t, &restSubId) + e2SubsIds := []uint32{e2SubsId, e2SubsId2} + sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1) + + waitSubsCleanup(t, e2SubsId, 10) + + // Resend the original request, we shall find it's previous md5sum/restsubs + // but the restsubscription has been already removed. This shall trigger a + // fresh create. + restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params) + + <-time.After(100 * time.Millisecond) + + deleteSubscription(t, xappConn1, e2termConn1, &restSubId) + + waitSubsCleanup(t, e2SubsId, 10) + + //Wait that subs is cleaned + mainCtrl.VerifyCounterValues(t) +} + func TestRESTSubDelReqRetransmission(t *testing.T) { CaseBegin("TestRESTSubDelReqRetransmission") diff --git a/pkg/teststube2ap/stubE2.go b/pkg/teststube2ap/stubE2.go index 98c98f4..f20afed 100644 --- a/pkg/teststube2ap/stubE2.go +++ b/pkg/teststube2ap/stubE2.go @@ -664,6 +664,7 @@ func (tc *E2Stub) SendSubsDelFail(t *testing.T, req *e2ap.E2APSubscriptionDelete // Callback handler for subscription response notifications //----------------------------------------------------------------------------- func (tc *E2Stub) SubscriptionRespHandler(resp *clientmodel.SubscriptionResponse) { + if tc.subscriptionId == "SUBSCRIPTIONID NOT SET" { tc.Info("REST notification received for %v while no SubscriptionID was not set for E2EventInstanceID=%v, XappEventInstanceID=%v (%v)", *resp.SubscriptionID, *resp.SubscriptionInstances[0].E2EventInstanceID, *resp.SubscriptionInstances[0].XappEventInstanceID, tc) @@ -832,7 +833,7 @@ func (tc *E2Stub) SendRESTSubsReq(t *testing.T, params *RESTSubsReqParams) strin return "" } - tc.subscriptionId = "SUBSCIPTIONID NOT SET" + tc.subscriptionId = "SUBSCRIPTIONID NOT SET" resp, err := xapp.Subscription.Subscribe(¶ms.SubsReqParams) if err != nil { -- 2.16.6