diff --git a/poetry.lock b/poetry.lock index 52cfc41d0..6e72556c5 100644 --- a/poetry.lock +++ b/poetry.lock @@ -52,13 +52,13 @@ pluggy = ">=0.4.0" [[package]] name = "anyio" -version = "4.6.0" +version = "4.6.2.post1" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false python-versions = ">=3.9" files = [ - {file = "anyio-4.6.0-py3-none-any.whl", hash = "sha256:c7d2e9d63e31599eeb636c8c5c03a7e108d73b345f064f1c19fdc87b79036a9a"}, - {file = "anyio-4.6.0.tar.gz", hash = "sha256:137b4559cbb034c477165047febb6ff83f390fc3b20bf181c1fc0a728cb8beeb"}, + {file = "anyio-4.6.2.post1-py3-none-any.whl", hash = "sha256:6d170c36fba3bdd840c73d3868c1e777e33676a69c3a72cf0a0d5d6d8009b61d"}, + {file = "anyio-4.6.2.post1.tar.gz", hash = "sha256:4c8bc31ccdb51c7f7bd251f51c609e038d63e34219b44aa86e47576389880b4c"}, ] [package.dependencies] @@ -69,7 +69,7 @@ typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} [package.extras] doc = ["Sphinx (>=7.4,<8.0)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] -test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.21.0b1)"] +test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "truststore (>=0.9.1)", "uvloop (>=0.21.0b1)"] trio = ["trio (>=0.26.1)"] [[package]] @@ -471,83 +471,73 @@ typing-extensions = "*" [[package]] name = "coverage" -version = "7.6.1" +version = "7.6.3" description = "Code coverage measurement for Python" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "coverage-7.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b06079abebbc0e89e6163b8e8f0e16270124c154dc6e4a47b413dd538859af16"}, - {file = "coverage-7.6.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cf4b19715bccd7ee27b6b120e7e9dd56037b9c0681dcc1adc9ba9db3d417fa36"}, - {file = "coverage-7.6.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e61c0abb4c85b095a784ef23fdd4aede7a2628478e7baba7c5e3deba61070a02"}, - {file = "coverage-7.6.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fd21f6ae3f08b41004dfb433fa895d858f3f5979e7762d052b12aef444e29afc"}, - {file = "coverage-7.6.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f59d57baca39b32db42b83b2a7ba6f47ad9c394ec2076b084c3f029b7afca23"}, - {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:a1ac0ae2b8bd743b88ed0502544847c3053d7171a3cff9228af618a068ed9c34"}, - {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e6a08c0be454c3b3beb105c0596ebdc2371fab6bb90c0c0297f4e58fd7e1012c"}, - {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:f5796e664fe802da4f57a168c85359a8fbf3eab5e55cd4e4569fbacecc903959"}, - {file = "coverage-7.6.1-cp310-cp310-win32.whl", hash = "sha256:7bb65125fcbef8d989fa1dd0e8a060999497629ca5b0efbca209588a73356232"}, - {file = "coverage-7.6.1-cp310-cp310-win_amd64.whl", hash = "sha256:3115a95daa9bdba70aea750db7b96b37259a81a709223c8448fa97727d546fe0"}, - {file = "coverage-7.6.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7dea0889685db8550f839fa202744652e87c60015029ce3f60e006f8c4462c93"}, - {file = "coverage-7.6.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ed37bd3c3b063412f7620464a9ac1314d33100329f39799255fb8d3027da50d3"}, - {file = "coverage-7.6.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d85f5e9a5f8b73e2350097c3756ef7e785f55bd71205defa0bfdaf96c31616ff"}, - {file = "coverage-7.6.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9bc572be474cafb617672c43fe989d6e48d3c83af02ce8de73fff1c6bb3c198d"}, - {file = "coverage-7.6.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c0420b573964c760df9e9e86d1a9a622d0d27f417e1a949a8a66dd7bcee7bc6"}, - {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1f4aa8219db826ce6be7099d559f8ec311549bfc4046f7f9fe9b5cea5c581c56"}, - {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:fc5a77d0c516700ebad189b587de289a20a78324bc54baee03dd486f0855d234"}, - {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b48f312cca9621272ae49008c7f613337c53fadca647d6384cc129d2996d1133"}, - {file = "coverage-7.6.1-cp311-cp311-win32.whl", hash = "sha256:1125ca0e5fd475cbbba3bb67ae20bd2c23a98fac4e32412883f9bcbaa81c314c"}, - {file = "coverage-7.6.1-cp311-cp311-win_amd64.whl", hash = "sha256:8ae539519c4c040c5ffd0632784e21b2f03fc1340752af711f33e5be83a9d6c6"}, - {file = "coverage-7.6.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:95cae0efeb032af8458fc27d191f85d1717b1d4e49f7cb226cf526ff28179778"}, - {file = "coverage-7.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5621a9175cf9d0b0c84c2ef2b12e9f5f5071357c4d2ea6ca1cf01814f45d2391"}, - {file = "coverage-7.6.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:260933720fdcd75340e7dbe9060655aff3af1f0c5d20f46b57f262ab6c86a5e8"}, - {file = "coverage-7.6.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07e2ca0ad381b91350c0ed49d52699b625aab2b44b65e1b4e02fa9df0e92ad2d"}, - {file = "coverage-7.6.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c44fee9975f04b33331cb8eb272827111efc8930cfd582e0320613263ca849ca"}, - {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:877abb17e6339d96bf08e7a622d05095e72b71f8afd8a9fefc82cf30ed944163"}, - {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3e0cadcf6733c09154b461f1ca72d5416635e5e4ec4e536192180d34ec160f8a"}, - {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c3c02d12f837d9683e5ab2f3d9844dc57655b92c74e286c262e0fc54213c216d"}, - {file = "coverage-7.6.1-cp312-cp312-win32.whl", hash = "sha256:e05882b70b87a18d937ca6768ff33cc3f72847cbc4de4491c8e73880766718e5"}, - {file = "coverage-7.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:b5d7b556859dd85f3a541db6a4e0167b86e7273e1cdc973e5b175166bb634fdb"}, - {file = "coverage-7.6.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a4acd025ecc06185ba2b801f2de85546e0b8ac787cf9d3b06e7e2a69f925b106"}, - {file = "coverage-7.6.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a6d3adcf24b624a7b778533480e32434a39ad8fa30c315208f6d3e5542aeb6e9"}, - {file = "coverage-7.6.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0c212c49b6c10e6951362f7c6df3329f04c2b1c28499563d4035d964ab8e08c"}, - {file = "coverage-7.6.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6e81d7a3e58882450ec4186ca59a3f20a5d4440f25b1cff6f0902ad890e6748a"}, - {file = "coverage-7.6.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78b260de9790fd81e69401c2dc8b17da47c8038176a79092a89cb2b7d945d060"}, - {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a78d169acd38300060b28d600344a803628c3fd585c912cacc9ea8790fe96862"}, - {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:2c09f4ce52cb99dd7505cd0fc8e0e37c77b87f46bc9c1eb03fe3bc9991085388"}, - {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6878ef48d4227aace338d88c48738a4258213cd7b74fd9a3d4d7582bb1d8a155"}, - {file = "coverage-7.6.1-cp313-cp313-win32.whl", hash = "sha256:44df346d5215a8c0e360307d46ffaabe0f5d3502c8a1cefd700b34baf31d411a"}, - {file = "coverage-7.6.1-cp313-cp313-win_amd64.whl", hash = "sha256:8284cf8c0dd272a247bc154eb6c95548722dce90d098c17a883ed36e67cdb129"}, - {file = "coverage-7.6.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:d3296782ca4eab572a1a4eca686d8bfb00226300dcefdf43faa25b5242ab8a3e"}, - {file = "coverage-7.6.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:502753043567491d3ff6d08629270127e0c31d4184c4c8d98f92c26f65019962"}, - {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6a89ecca80709d4076b95f89f308544ec8f7b4727e8a547913a35f16717856cb"}, - {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a318d68e92e80af8b00fa99609796fdbcdfef3629c77c6283566c6f02c6d6704"}, - {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13b0a73a0896988f053e4fbb7de6d93388e6dd292b0d87ee51d106f2c11b465b"}, - {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:4421712dbfc5562150f7554f13dde997a2e932a6b5f352edcce948a815efee6f"}, - {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:166811d20dfea725e2e4baa71fffd6c968a958577848d2131f39b60043400223"}, - {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:225667980479a17db1048cb2bf8bfb39b8e5be8f164b8f6628b64f78a72cf9d3"}, - {file = "coverage-7.6.1-cp313-cp313t-win32.whl", hash = "sha256:170d444ab405852903b7d04ea9ae9b98f98ab6d7e63e1115e82620807519797f"}, - {file = "coverage-7.6.1-cp313-cp313t-win_amd64.whl", hash = "sha256:b9f222de8cded79c49bf184bdbc06630d4c58eec9459b939b4a690c82ed05657"}, - {file = "coverage-7.6.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6db04803b6c7291985a761004e9060b2bca08da6d04f26a7f2294b8623a0c1a0"}, - {file = "coverage-7.6.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f1adfc8ac319e1a348af294106bc6a8458a0f1633cc62a1446aebc30c5fa186a"}, - {file = "coverage-7.6.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a95324a9de9650a729239daea117df21f4b9868ce32e63f8b650ebe6cef5595b"}, - {file = "coverage-7.6.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b43c03669dc4618ec25270b06ecd3ee4fa94c7f9b3c14bae6571ca00ef98b0d3"}, - {file = "coverage-7.6.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8929543a7192c13d177b770008bc4e8119f2e1f881d563fc6b6305d2d0ebe9de"}, - {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:a09ece4a69cf399510c8ab25e0950d9cf2b42f7b3cb0374f95d2e2ff594478a6"}, - {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:9054a0754de38d9dbd01a46621636689124d666bad1936d76c0341f7d71bf569"}, - {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:0dbde0f4aa9a16fa4d754356a8f2e36296ff4d83994b2c9d8398aa32f222f989"}, - {file = "coverage-7.6.1-cp38-cp38-win32.whl", hash = "sha256:da511e6ad4f7323ee5702e6633085fb76c2f893aaf8ce4c51a0ba4fc07580ea7"}, - {file = "coverage-7.6.1-cp38-cp38-win_amd64.whl", hash = "sha256:3f1156e3e8f2872197af3840d8ad307a9dd18e615dc64d9ee41696f287c57ad8"}, - {file = "coverage-7.6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:abd5fd0db5f4dc9289408aaf34908072f805ff7792632250dcb36dc591d24255"}, - {file = "coverage-7.6.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:547f45fa1a93154bd82050a7f3cddbc1a7a4dd2a9bf5cb7d06f4ae29fe94eaf8"}, - {file = "coverage-7.6.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:645786266c8f18a931b65bfcefdbf6952dd0dea98feee39bd188607a9d307ed2"}, - {file = "coverage-7.6.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9e0b2df163b8ed01d515807af24f63de04bebcecbd6c3bfeff88385789fdf75a"}, - {file = "coverage-7.6.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:609b06f178fe8e9f89ef676532760ec0b4deea15e9969bf754b37f7c40326dbc"}, - {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:702855feff378050ae4f741045e19a32d57d19f3e0676d589df0575008ea5004"}, - {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:2bdb062ea438f22d99cba0d7829c2ef0af1d768d1e4a4f528087224c90b132cb"}, - {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:9c56863d44bd1c4fe2abb8a4d6f5371d197f1ac0ebdee542f07f35895fc07f36"}, - {file = "coverage-7.6.1-cp39-cp39-win32.whl", hash = "sha256:6e2cd258d7d927d09493c8df1ce9174ad01b381d4729a9d8d4e38670ca24774c"}, - {file = "coverage-7.6.1-cp39-cp39-win_amd64.whl", hash = "sha256:06a737c882bd26d0d6ee7269b20b12f14a8704807a01056c80bb881a4b2ce6ca"}, - {file = "coverage-7.6.1-pp38.pp39.pp310-none-any.whl", hash = "sha256:e9a6e0eb86070e8ccaedfbd9d38fec54864f3125ab95419970575b42af7541df"}, - {file = "coverage-7.6.1.tar.gz", hash = "sha256:953510dfb7b12ab69d20135a0662397f077c59b1e6379a768e97c59d852ee51d"}, + {file = "coverage-7.6.3-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6da42bbcec130b188169107ecb6ee7bd7b4c849d24c9370a0c884cf728d8e976"}, + {file = "coverage-7.6.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c222958f59b0ae091f4535851cbb24eb57fc0baea07ba675af718fb5302dddb2"}, + {file = "coverage-7.6.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ab84a8b698ad5a6c365b08061920138e7a7dd9a04b6feb09ba1bfae68346ce6d"}, + {file = "coverage-7.6.3-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:70a6756ce66cd6fe8486c775b30889f0dc4cb20c157aa8c35b45fd7868255c5c"}, + {file = "coverage-7.6.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3c2e6fa98032fec8282f6b27e3f3986c6e05702828380618776ad794e938f53a"}, + {file = "coverage-7.6.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:921fbe13492caf6a69528f09d5d7c7d518c8d0e7b9f6701b7719715f29a71e6e"}, + {file = "coverage-7.6.3-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:6d99198203f0b9cb0b5d1c0393859555bc26b548223a769baf7e321a627ed4fc"}, + {file = "coverage-7.6.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:87cd2e29067ea397a47e352efb13f976eb1b03e18c999270bb50589323294c6e"}, + {file = "coverage-7.6.3-cp310-cp310-win32.whl", hash = "sha256:a3328c3e64ea4ab12b85999eb0779e6139295bbf5485f69d42cf794309e3d007"}, + {file = "coverage-7.6.3-cp310-cp310-win_amd64.whl", hash = "sha256:bca4c8abc50d38f9773c1ec80d43f3768df2e8576807d1656016b9d3eeaa96fd"}, + {file = "coverage-7.6.3-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c51ef82302386d686feea1c44dbeef744585da16fcf97deea2a8d6c1556f519b"}, + {file = "coverage-7.6.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:0ca37993206402c6c35dc717f90d4c8f53568a8b80f0bf1a1b2b334f4d488fba"}, + {file = "coverage-7.6.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c77326300b839c44c3e5a8fe26c15b7e87b2f32dfd2fc9fee1d13604347c9b38"}, + {file = "coverage-7.6.3-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6e484e479860e00da1f005cd19d1c5d4a813324e5951319ac3f3eefb497cc549"}, + {file = "coverage-7.6.3-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c6c0f4d53ef603397fc894a895b960ecd7d44c727df42a8d500031716d4e8d2"}, + {file = "coverage-7.6.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:37be7b5ea3ff5b7c4a9db16074dc94523b5f10dd1f3b362a827af66a55198175"}, + {file = "coverage-7.6.3-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:43b32a06c47539fe275106b376658638b418c7cfdfff0e0259fbf877e845f14b"}, + {file = "coverage-7.6.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ee77c7bef0724165e795b6b7bf9c4c22a9b8468a6bdb9c6b4281293c6b22a90f"}, + {file = "coverage-7.6.3-cp311-cp311-win32.whl", hash = "sha256:43517e1f6b19f610a93d8227e47790722c8bf7422e46b365e0469fc3d3563d97"}, + {file = "coverage-7.6.3-cp311-cp311-win_amd64.whl", hash = "sha256:04f2189716e85ec9192df307f7c255f90e78b6e9863a03223c3b998d24a3c6c6"}, + {file = "coverage-7.6.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:27bd5f18d8f2879e45724b0ce74f61811639a846ff0e5c0395b7818fae87aec6"}, + {file = "coverage-7.6.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d546cfa78844b8b9c1c0533de1851569a13f87449897bbc95d698d1d3cb2a30f"}, + {file = "coverage-7.6.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9975442f2e7a5cfcf87299c26b5a45266ab0696348420049b9b94b2ad3d40234"}, + {file = "coverage-7.6.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:583049c63106c0555e3ae3931edab5669668bbef84c15861421b94e121878d3f"}, + {file = "coverage-7.6.3-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2341a78ae3a5ed454d524206a3fcb3cec408c2a0c7c2752cd78b606a2ff15af4"}, + {file = "coverage-7.6.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:a4fb91d5f72b7e06a14ff4ae5be625a81cd7e5f869d7a54578fc271d08d58ae3"}, + {file = "coverage-7.6.3-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:e279f3db904e3b55f520f11f983cc8dc8a4ce9b65f11692d4718ed021ec58b83"}, + {file = "coverage-7.6.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:aa23ce39661a3e90eea5f99ec59b763b7d655c2cada10729ed920a38bfc2b167"}, + {file = "coverage-7.6.3-cp312-cp312-win32.whl", hash = "sha256:52ac29cc72ee7e25ace7807249638f94c9b6a862c56b1df015d2b2e388e51dbd"}, + {file = "coverage-7.6.3-cp312-cp312-win_amd64.whl", hash = "sha256:40e8b1983080439d4802d80b951f4a93d991ef3261f69e81095a66f86cf3c3c6"}, + {file = "coverage-7.6.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:9134032f5aa445ae591c2ba6991d10136a1f533b1d2fa8f8c21126468c5025c6"}, + {file = "coverage-7.6.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:99670790f21a96665a35849990b1df447993880bb6463a0a1d757897f30da929"}, + {file = "coverage-7.6.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2dc7d6b380ca76f5e817ac9eef0c3686e7834c8346bef30b041a4ad286449990"}, + {file = "coverage-7.6.3-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f7b26757b22faf88fcf232f5f0e62f6e0fd9e22a8a5d0d5016888cdfe1f6c1c4"}, + {file = "coverage-7.6.3-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4c59d6a4a4633fad297f943c03d0d2569867bd5372eb5684befdff8df8522e39"}, + {file = "coverage-7.6.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f263b18692f8ed52c8de7f40a0751e79015983dbd77b16906e5b310a39d3ca21"}, + {file = "coverage-7.6.3-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:79644f68a6ff23b251cae1c82b01a0b51bc40c8468ca9585c6c4b1aeee570e0b"}, + {file = "coverage-7.6.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:71967c35828c9ff94e8c7d405469a1fb68257f686bca7c1ed85ed34e7c2529c4"}, + {file = "coverage-7.6.3-cp313-cp313-win32.whl", hash = "sha256:e266af4da2c1a4cbc6135a570c64577fd3e6eb204607eaff99d8e9b710003c6f"}, + {file = "coverage-7.6.3-cp313-cp313-win_amd64.whl", hash = "sha256:ea52bd218d4ba260399a8ae4bb6b577d82adfc4518b93566ce1fddd4a49d1dce"}, + {file = "coverage-7.6.3-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:8d4c6ea0f498c7c79111033a290d060c517853a7bcb2f46516f591dab628ddd3"}, + {file = "coverage-7.6.3-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:331b200ad03dbaa44151d74daeb7da2cf382db424ab923574f6ecca7d3b30de3"}, + {file = "coverage-7.6.3-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:54356a76b67cf8a3085818026bb556545ebb8353951923b88292556dfa9f812d"}, + {file = "coverage-7.6.3-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ebec65f5068e7df2d49466aab9128510c4867e532e07cb6960075b27658dca38"}, + {file = "coverage-7.6.3-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d33a785ea8354c480515e781554d3be582a86297e41ccbea627a5c632647f2cd"}, + {file = "coverage-7.6.3-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:f7ddb920106bbbbcaf2a274d56f46956bf56ecbde210d88061824a95bdd94e92"}, + {file = "coverage-7.6.3-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:70d24936ca6c15a3bbc91ee9c7fc661132c6f4c9d42a23b31b6686c05073bde5"}, + {file = "coverage-7.6.3-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:c30e42ea11badb147f0d2e387115b15e2bd8205a5ad70d6ad79cf37f6ac08c91"}, + {file = "coverage-7.6.3-cp313-cp313t-win32.whl", hash = "sha256:365defc257c687ce3e7d275f39738dcd230777424117a6c76043459db131dd43"}, + {file = "coverage-7.6.3-cp313-cp313t-win_amd64.whl", hash = "sha256:23bb63ae3f4c645d2d82fa22697364b0046fbafb6261b258a58587441c5f7bd0"}, + {file = "coverage-7.6.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:da29ceabe3025a1e5a5aeeb331c5b1af686daab4ff0fb4f83df18b1180ea83e2"}, + {file = "coverage-7.6.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:df8c05a0f574d480947cba11b947dc41b1265d721c3777881da2fb8d3a1ddfba"}, + {file = "coverage-7.6.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ec1e3b40b82236d100d259854840555469fad4db64f669ab817279eb95cd535c"}, + {file = "coverage-7.6.3-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b4adeb878a374126f1e5cf03b87f66279f479e01af0e9a654cf6d1509af46c40"}, + {file = "coverage-7.6.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:43d6a66e33b1455b98fc7312b124296dad97a2e191c80320587234a77b1b736e"}, + {file = "coverage-7.6.3-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:1990b1f4e2c402beb317840030bb9f1b6a363f86e14e21b4212e618acdfce7f6"}, + {file = "coverage-7.6.3-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:12f9515d875859faedb4144fd38694a761cd2a61ef9603bf887b13956d0bbfbb"}, + {file = "coverage-7.6.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:99ded130555c021d99729fabd4ddb91a6f4cc0707df4b1daf912c7850c373b13"}, + {file = "coverage-7.6.3-cp39-cp39-win32.whl", hash = "sha256:c3a79f56dee9136084cf84a6c7c4341427ef36e05ae6415bf7d787c96ff5eaa3"}, + {file = "coverage-7.6.3-cp39-cp39-win_amd64.whl", hash = "sha256:aac7501ae73d4a02f4b7ac8fcb9dc55342ca98ffb9ed9f2dfb8a25d53eda0e4d"}, + {file = "coverage-7.6.3-pp39.pp310-none-any.whl", hash = "sha256:b9853509b4bf57ba7b1f99b9d866c422c9c5248799ab20e652bbb8a184a38181"}, + {file = "coverage-7.6.3.tar.gz", hash = "sha256:bb7d5fe92bd0dc235f63ebe9f8c6e0884f7360f88f3411bfed1350c872ef2054"}, ] [package.dependencies] @@ -1400,13 +1390,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "poetry-core" -version = "1.9.0" +version = "1.9.1" description = "Poetry PEP 517 Build Backend" optional = false -python-versions = ">=3.8,<4.0" +python-versions = "<4.0,>=3.8" files = [ - {file = "poetry_core-1.9.0-py3-none-any.whl", hash = "sha256:4e0c9c6ad8cf89956f03b308736d84ea6ddb44089d16f2adc94050108ec1f5a1"}, - {file = "poetry_core-1.9.0.tar.gz", hash = "sha256:fa7a4001eae8aa572ee84f35feb510b321bd652e5cf9293249d62853e1f935a2"}, + {file = "poetry_core-1.9.1-py3-none-any.whl", hash = "sha256:6f45dd3598e0de8d9b0367360253d4c5d4d0110c8f5c71120a14f0e0f116c1a0"}, + {file = "poetry_core-1.9.1.tar.gz", hash = "sha256:7a2d49214bf58b4f17f99d6891d947a9836c9899a67a5069f52d7b67217f61b8"}, ] [[package]] diff --git a/src/charm.py b/src/charm.py index b0fb28867..96023d050 100755 --- a/src/charm.py +++ b/src/charm.py @@ -48,6 +48,9 @@ CrossAppVersionChecker, get_charm_revision, ) +from lightkube import Client +from lightkube.resources.apps_v1 import StatefulSet +from lightkube.types import PatchType from ops.charm import ( ActionEvent, CharmBase, @@ -104,6 +107,8 @@ UNIT_SCOPE = Config.Relations.UNIT_SCOPE Scopes = Config.Relations.Scopes +ONE_MINUTE = 60 +ONE_YEAR = 31540000 USER_CREATING_MAX_ATTEMPTS = 5 USER_CREATION_COOLDOWN = 30 REPLICA_SET_INIT_CHECK_TIMEOUT = 10 @@ -114,7 +119,6 @@ class MongoDBCharm(CharmBase): def __init__(self, *args): super().__init__(*args) - self.framework.observe(self.on.mongod_pebble_ready, self._on_mongod_pebble_ready) self.framework.observe(self.on.config_changed, self._on_config_changed) self.framework.observe(self.on.start, self._on_start) @@ -176,7 +180,6 @@ def __init__(self, *args): ) # BEGIN: properties - @property def monitoring_jobs(self) -> list[dict[str, Any]]: """Defines the labels and targets for metrics.""" @@ -767,6 +770,19 @@ def _on_start(self, event: StartEvent) -> None: It is needed to install mongodb-clients inside the charm container to make this function work correctly. """ + # We must ensure that juju does not overwrite our termination period, so we should update + # it as needed. However, updating the termination period can result in an onslaught of + # events, including the upgrade event. To prevent this from messing with upgrades do not + # update the termination period when an upgrade is occurring. + if ( + self.unit.is_leader() + and self.get_current_termination_period() != ONE_YEAR + and not self.upgrade_in_progress + ): + self.update_termination_grace_period(ONE_YEAR) + event.defer() + return + if not self.__can_charm_start(): event.defer() return @@ -871,6 +887,36 @@ def _reconcile_mongo_hosts_and_users(self, event: RelationEvent) -> None: logger.info("Deferring reconfigure: error=%r", e) event.defer() + def get_current_termination_period(self) -> int: + """Returns the current termination period for the stateful set of this juju application.""" + client = Client() + statefulset = client.get(StatefulSet, name=self.app.name, namespace=self.model.name) + return statefulset.spec.template.spec.terminationGracePeriodSeconds + + def update_termination_grace_period(self, seconds: int) -> None: + """Patch the termination grace period for the stateful set of this juju application.""" + # updating the termination grace period is only useful for shards, whose sudden removal + # can result in data-loss + if not self.is_role(Config.Role.SHARD): + return + + client = Client() + patch_data = { + "spec": { + "template": { + "spec": {"terminationGracePeriodSeconds": ONE_YEAR}, + "metadata": {"annotations": {"force-update": str(int(time.time()))}}, + } + } + } + client.patch( + StatefulSet, + name=self.app.name, + namespace=self.model.name, + obj=patch_data, + patch_type=PatchType.MERGE, + ) + def __handle_partition_on_stop(self) -> None: """Raise partition to prevent other units from restarting if an upgrade is in progress. @@ -933,6 +979,31 @@ def _on_stop(self, event) -> None: return self.__handle_upgrade_on_stop() + # I can add this functionality to mongodb lib - i.e. a function wait_for_new_primary, but + # this is just a POC + old_primary = self.primary + with MongoDBConnection(self.mongodb_config) as mongod: + mongod.step_down_primary() + + for attempt in Retrying(stop=stop_after_attempt(30), wait=wait_fixed(1), reraise=True): + with attempt: + new_primary = self.primary + if new_primary == old_primary: + raise FailedToElectNewPrimaryError() + + if "True" == self.unit_peer_data.get("unit_departed", "False"): + logger.debug(f"{self.unit.name} blocking on_stop") + is_in_replica_set = True + timeout = UNIT_REMOVAL_TIMEOUT + while is_in_replica_set and timeout > 0: + is_in_replica_set = self.is_unit_in_replica_set() + time.sleep(1) + timeout -= 1 + if timeout < 0: + raise Exception(f"{self.unit.name}.on_stop timeout exceeded") + logger.debug(f"{self.unit.name} releasing on_stop") + self.unit_peer_data["unit_departed"] = "" + def _on_update_status(self, event: UpdateStatusEvent): # user-made mistakes might result in other incorrect statues. Prioritise informing users of # their mistake. @@ -973,6 +1044,17 @@ def _on_update_status(self, event: UpdateStatusEvent): self.status.set_and_share_status(self.status.process_statuses()) + # We must ensure that juju does not overwrite our termination period, so we should update + # it as needed. However, updating the termination period can result in an onslaught of + # events, including the upgrade event. To prevent this from messing with upgrades do not + # update the termination period when an upgrade is occurring. + if ( + self.unit.is_leader() + and self.get_current_termination_period() != ONE_YEAR + and not self.upgrade_in_progress + ): + self.update_termination_grace_period(ONE_YEAR) + # END: charm events # BEGIN: actions diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index e9dc6afff..9c5895d64 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -10,15 +10,10 @@ import pytest from charms.mongodb.v1.helpers import CONF_DIR, DATA_DIR, KEY_FILE from ops.model import ActiveStatus, MaintenanceStatus, ModelError -from ops.pebble import APIError, ExecError, PathError, ProtocolError +from ops.pebble import ExecError, PathError, ProtocolError from ops.testing import Harness from parameterized import parameterized -from pymongo.errors import ( - ConfigurationError, - ConnectionFailure, - OperationFailure, - PyMongoError, -) +from pymongo.errors import ConfigurationError, ConnectionFailure, OperationFailure from tenacity import stop_after_attempt, wait_fixed, wait_none from charm import MongoDBCharm, NotReadyError @@ -128,6 +123,8 @@ def test_mongod_pebble_ready(self, connect_exporter, fix_data_dir, defer, pull_l # Ensure that _connect_mongodb_exporter was called connect_exporter.assert_called_once() + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBCharm._push_keyfile_to_workload") def test_pebble_ready_cannot_retrieve_container( @@ -152,6 +149,8 @@ def test_pebble_ready_cannot_retrieve_container( mock_container.replan.assert_not_called() defer.assert_not_called() + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBCharm._push_keyfile_to_workload") def test_pebble_ready_container_cannot_connect(self, push_keyfile_to_workload, defer, *unused): @@ -215,35 +214,39 @@ def test_pebble_ready_no_storage_yet(self, defer): mock_container.replan.assert_not_called() defer.assert_called() - @patch("ops.framework.EventBase.defer") - @patch("charm.MongoDBProvider") - @patch("charm.MongoDBCharm._init_operator_user") - @patch("charm.MongoDBConnection") - def test_start_cannot_retrieve_container( - self, connection, init_user, provider, defer, *unused - ): - """Verifies that failures to get container result in a ModelError being raised. - - Further this function verifies that on error no attempts to set up the replica set or - database users are made. - """ - # presets - self.harness.set_leader(True) - mock_container = mock.Mock() - mock_container.side_effect = ModelError - self.harness.charm.unit.get_container = mock_container - with self.assertRaises(ModelError): - self.harness.charm.on.start.emit() - - # when cannot retrieve a container we should not set up the replica set or handle users - connection.return_value.__enter__.return_value.init_replset.assert_not_called() - init_user.assert_not_called() - provider.return_value.oversee_users.assert_not_called() - - # verify app data - self.assertEqual("db_initialised" in self.harness.charm.app_peer_data, False) - defer.assert_not_called() - + # @patch("charm.MongoDBCharm.get_current_termination_period") + # @patch("charm.MongoDBCharm.update_termination_grace_period") + # @patch("ops.framework.EventBase.defer") + # @patch("charm.MongoDBProvider") + # @patch("charm.MongoDBCharm._init_operator_user") + # @patch("charm.MongoDBConnection") + # def test_start_cannot_retrieve_container( + # self, connection, init_user, provider, defer, *unused + # ): + # """Verifies that failures to get container result in a ModelError being raised. + + # Further this function verifies that on error no attempts to set up the replica set or + # database users are made. + # """ + # # presets + # self.harness.set_leader(True) + # mock_container = mock.Mock() + # mock_container.side_effect = ModelError + # self.harness.charm.unit.get_container = mock_container + # with self.assertRaises(ModelError): + # self.harness.charm.on.start.emit() + + # # when cannot retrieve a container we should not set up the replica set or handle users + # connection.return_value.__enter__.return_value.init_replset.assert_not_called() + # init_user.assert_not_called() + # provider.return_value.oversee_users.assert_not_called() + + # # verify app data + # self.assertEqual("db_initialised" in self.harness.charm.app_peer_data, False) + # defer.assert_not_called() + + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider") @patch("charm.MongoDBCharm._init_operator_user") @@ -271,6 +274,8 @@ def test_start_container_cannot_connect(self, connection, init_user, provider, d self.assertEqual("db_initialised" in self.harness.charm.app_peer_data, False) defer.assert_called() + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider") @patch("charm.MongoDBCharm._init_operator_user") @@ -299,66 +304,8 @@ def test_start_container_does_not_exist(self, connection, init_user, provider, d self.assertEqual("db_initialised" in self.harness.charm.app_peer_data, False) defer.assert_called() - @patch("charm.MongoDBCharm._configure_container", return_value=None) - @patch("ops.framework.EventBase.defer") - @patch("charm.MongoDBProvider") - @patch("charm.MongoDBCharm._init_operator_user") - @patch("charm.MongoDBConnection") - def test_start_container_exists_fails(self, connection, init_user, provider, defer, *unused): - """Tests failure in checking file existence on container raises an APIError. - - Verifies that when checking container files raises an API Error, we raise that same error - and make no attempts to set up the replica set or handle users. - """ - # presets - self.harness.set_leader(True) - mock_container = mock.Mock() - mock_container.return_value.can_connect.return_value = True - mock_container.return_value.exists.side_effect = APIError("body", 0, "status", "message") - self.harness.charm.unit.get_container = mock_container - - with self.assertRaises(APIError): - self.harness.charm.on.start.emit() - - # when container does not exist we should not set up the replica set or handle users - connection.return_value.__enter__.return_value.init_replset.assert_not_called() - init_user.assert_not_called() - provider.return_value.oversee_users.assert_not_called() - - # verify app data - self.assertEqual("db_initialised" in self.harness.charm.app_peer_data, False) - defer.assert_not_called() - - @patch("charm.MongoDBCharm._configure_container", return_value=None) - @patch("ops.framework.EventBase.defer") - @patch("charm.MongoDBProvider") - @patch("charm.MongoDBCharm._init_operator_user") - @patch("charm.MongoDBConnection") - def test_start_already_initialised(self, connection, init_user, provider, defer, *unused): - """Tests that if the replica set has already been set up that we return. - - Verifies that if the replica set is already set up that no attempts to set it up again are - made and that there are no attempts to set up users. - """ - # presets - self.harness.set_leader(True) - - mock_container = mock.Mock() - mock_container.return_value.can_connect.return_value = True - mock_container.return_value.exists.return_value = True - self.harness.charm.unit.get_container = mock_container - self.harness.charm.app_peer_data["replica_set_initialised"] = json.dumps(True) - self.harness.charm.app_peer_data["users_initialized"] = json.dumps(True) - - self.harness.charm.on.start.emit() - - # when the database has already been initialised we should not set up the replica set or - # handle users - connection.return_value.__enter__.return_value.init_replset.assert_not_called() - init_user.assert_not_called() - provider.return_value.oversee_users.assert_not_called() - defer.assert_not_called() - + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider") @patch("charm.MongoDBCharm._init_operator_user") @@ -390,11 +337,15 @@ def test_start_mongod_not_ready(self, connection, init_user, provider, defer, *u self.assertEqual("db_initialised" in self.harness.charm.app_peer_data, False) defer.assert_called() + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") + @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider") @patch("charm.MongoDBCharm._initialise_users") - @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBConnection") - def test_start_mongod_error_initialising_replica_set(self, connection, defer, *unused): + def test_start_mongod_error_initalising_replica_set( + self, connection, init_users, provider, defer, *unused + ): """Tests that failure to initialise replica set is properly handled. Verifies that when there is a failure to initialise replica set the defer is called and @@ -417,6 +368,8 @@ def test_start_mongod_error_initialising_replica_set(self, connection, defer, *u self.assertEqual("replica_set_initialised" in self.harness.charm.app_peer_data, False) defer.assert_called() + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider") @patch("charm.MongoDBCharm._init_operator_user") @@ -447,6 +400,8 @@ def test_error_initialising_users(self, connection, init_user, provider, defer, # verify app data self.assertEqual("db_initialised" in self.harness.charm.app_peer_data, False) + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") @patch("charm.MongoDBCharm._init_operator_user") @patch("ops.framework.EventBase.defer") @patch("charm.MongoDBProvider") @@ -654,53 +609,6 @@ def test_reconfigure_add_member_failure(self, connection, defer, *unused): connection.return_value.__enter__.return_value.add_replset_member.assert_called() defer.assert_called() - @patch("charm.MongoDBCharm._configure_container", return_value=None) - @patch("ops.framework.EventBase.defer") - @patch("charm.MongoDBProvider.oversee_users") - @patch("charm.MongoDBConnection") - def test_start_init_operator_user_after_second_call( - self, connection, oversee_users, defer, *unused - ): - """Tests that the creation of the admin user is only performed once. - - Verifies that if the user is already set up, that no attempts to set it up again are - made when a failure happens causing an event deferring calling the init_user again - """ - self.harness.charm.USER_CREATING_MAX_ATTEMPTS = 1 - self.harness.charm.USER_CREATION_COOLDOWN = 1 - self.harness.charm._initialise_users.retry.wait = wait_none() - - mock_container = mock.Mock() - mock_container.return_value.can_connect.return_value = True - mock_container.return_value.exists.return_value = True - mock_container.return_value.exec.return_value = mock.Mock() - mock_container.return_value.exec.return_value.wait_output.return_value = ("Success", None) - - self.harness.charm.unit.get_container = mock_container - - connection.return_value.__enter__.return_value.is_ready = True - - oversee_users.side_effect = PyMongoError() - - self.harness.charm.app_peer_data["replica_set_initialised"] = json.dumps(True) - self.harness.charm.on.start.emit() - self.assertEqual("operator-user-created" in self.harness.charm.app_peer_data, True) - defer.assert_called() - - # the second call to init user should fail if "exec" is called, but shouldn't happen - oversee_users.side_effect = None - defer.reset_mock() - mock_container.return_value.exec.reset_mock() - mock_container.return_value.exec.side_effect = ExecError([], 1, "", "Dummy Error") - - # re-run the start method without a failing oversee_users - self.harness.charm.on.start.emit() - - # _init_operator_user should have returned before reaching the "exec" call - mock_container.return_value.exec.assert_not_called() - - defer.assert_not_called() - def test_get_password(self, *unused): self._setup_secrets() assert isinstance(self.harness.charm.get_secret("app", "monitor-password"), str) @@ -1014,30 +922,34 @@ def test__connect_mongodb_exporter_success( expected_uri = uri_template.format(password="mongo123") self.assertEqual(expected_uri, new_uri) - @patch("tenacity.nap.time.sleep", MagicMock()) - @patch("charm.USER_CREATING_MAX_ATTEMPTS", 1) - @patch("charm.USER_CREATION_COOLDOWN", 1) - @patch("charm.REPLICA_SET_INIT_CHECK_TIMEOUT", 1) - @patch("charm.MongoDBCharm._configure_container", return_value=None) - @patch("charm.MongoDBCharm._init_operator_user") - @patch("charm.MongoDBCharm._init_monitor_user") - @patch("charm.MongoDBCharm._connect_mongodb_exporter") - @patch("ops.model.Container.exists") - @patch("charm.MongoDBCharm._pull_licenses") - @patch("ops.framework.EventBase.defer") - @patch("charm.MongoDBCharm._set_data_dir_permissions") - @patch("charm.MongoDBConnection") - def test_backup_user_created(self, *unused): - """Tests what backup user was created.""" - self.harness.charm._initialise_users.retry.wait = wait_none() - container = self.harness.model.unit.get_container("mongod") - self.harness.charm.app_peer_data["replica_set_initialised"] = json.dumps(True) - self.harness.set_can_connect(container, True) - self.harness.charm.on.start.emit() - password = self.harness.charm.get_secret("app", "backup-password") - self.harness.charm._initialise_users.retry.wait = wait_none() - self.assertIsNotNone(password) # verify the password is set - + # @patch("charm.MongoDBCharm.get_current_termination_period") + # @patch("charm.MongoDBCharm.update_termination_grace_period") + # @patch("tenacity.nap.time.sleep", MagicMock()) + # @patch("charm.USER_CREATING_MAX_ATTEMPTS", 1) + # @patch("charm.USER_CREATION_COOLDOWN", 1) + # @patch("charm.REPLICA_SET_INIT_CHECK_TIMEOUT", 1) + # @patch("charm.MongoDBCharm._configure_container", return_value=None) + # @patch("charm.MongoDBCharm._init_operator_user") + # @patch("charm.MongoDBCharm._init_monitor_user") + # @patch("charm.MongoDBCharm._connect_mongodb_exporter") + # @patch("ops.model.Container.exists") + # @patch("charm.MongoDBCharm._pull_licenses") + # @patch("ops.framework.EventBase.defer") + # @patch("charm.MongoDBCharm._set_data_dir_permissions") + # @patch("charm.MongoDBConnection") + # def test_backup_user_created(self, *unused): + # """Tests what backup user was created.""" + # self.harness.charm._initialise_users.retry.wait = wait_none() + # container = self.harness.model.unit.get_container("mongod") + # self.harness.charm.app_peer_data["replica_set_initialised"] = json.dumps(True) + # self.harness.set_can_connect(container, True) + # self.harness.charm.on.start.emit() + # password = self.harness.charm.get_secret("app", "backup-password") + # self.harness.charm._initialise_users.retry.wait = wait_none() + # self.assertIsNotNone(password) # verify the password is set + + @patch("charm.MongoDBCharm.get_current_termination_period") + @patch("charm.MongoDBCharm.update_termination_grace_period") @patch("charm.MongoDBConnection") def test_set_password_provided(self, *unused): """Tests that a given password is set as the new mongodb password for backup user."""