diff --git a/Cargo.lock b/Cargo.lock index 88fda7b9e575d6988e3babc92328aafa4675712c..5e7e635cc09bb0edf07cfde999bcddd97c3ba95c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "1.1.2" @@ -59,12 +74,17 @@ dependencies = [ ] [[package]] -name = "autocfg" -version = "0.1.8" +name = "async-tungstenite" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" +checksum = "2cca750b12e02c389c1694d35c16539f88b8bbaa5945934fdc1b41a776688589" dependencies = [ - "autocfg 1.1.0", + "futures-io", + "futures-util", + "log", + "pin-project-lite", + "tokio", + "tungstenite", ] [[package]] @@ -74,22 +94,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" -dependencies = [ - "byteorder", - "safemem", -] - -[[package]] -name = "base64" -version = "0.10.1" +name = "backtrace" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" +checksum = "26b05800d2e817c8b3b4b54abd461726265fa9789ae34330622f2db9ee696f9d" dependencies = [ - "byteorder", + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", ] [[package]] @@ -106,25 +122,13 @@ checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" -version = "0.7.3" +version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "block-padding", - "byte-tools", - "byteorder", "generic-array", ] -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - [[package]] name = "bstr" version = "1.9.1" @@ -136,18 +140,24 @@ dependencies = [ "serde", ] -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "cc" +version = "1.0.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" + [[package]] name = "cfg-if" version = "1.0.0" @@ -160,15 +170,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "command-group" version = "2.1.0" @@ -189,7 +190,26 @@ dependencies = [ "lazy_static", "libc", "unicode-width", - "windows-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", ] [[package]] @@ -199,9 +219,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" dependencies = [ "nix 0.28.0", - "windows-sys", + "windows-sys 0.52.0", ] +[[package]] +name = "data-encoding" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" + [[package]] name = "difflib" version = "0.4.0" @@ -210,11 +236,12 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" [[package]] name = "digest" -version = "0.8.1" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "generic-array", + "block-buffer", + "crypto-common", ] [[package]] @@ -241,7 +268,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ - "log 0.4.21", + "log", ] [[package]] @@ -257,15 +284,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - [[package]] name = "fastrand" version = "2.0.1" @@ -282,31 +303,141 @@ dependencies = [ ] [[package]] -name = "fuchsia-cprng" -version = "0.1.1" +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-executor" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-macro" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] [[package]] name = "generic-array" -version = "0.12.4" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", + "version_check", ] [[package]] -name = "hashbrown" -version = "0.14.3" +name = "getrandom" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] [[package]] -name = "hermit-abi" -version = "0.3.9" +name = "gimli" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "home" @@ -314,41 +445,32 @@ version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] -name = "httparse" -version = "1.8.0" +name = "http" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] [[package]] -name = "hyper" -version = "0.10.16" +name = "httparse" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" -dependencies = [ - "base64 0.9.3", - "httparse", - "language-tags", - "log 0.3.9", - "mime", - "num_cpus", - "time", - "traitobject", - "typeable", - "unicase", - "url", -] +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "idna" -version = "0.1.5" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ - "matches", "unicode-bidi", "unicode-normalization", ] @@ -391,12 +513,6 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" -[[package]] -name = "language-tags" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" - [[package]] name = "lazy_static" version = "1.4.0" @@ -415,27 +531,12 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" -dependencies = [ - "log 0.4.21", -] - [[package]] name = "log" version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - [[package]] name = "memchr" version = "2.7.1" @@ -443,12 +544,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] -name = "mime" -version = "0.2.6" +name = "miniz_oxide" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ - "log 0.3.9", + "adler", ] [[package]] @@ -457,7 +558,18 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb3371dfc7b772c540da1380123674a8e20583aca99907087d990ca58cf44203" dependencies = [ - "log 0.4.21", + "log", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", ] [[package]] @@ -495,17 +607,7 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", + "autocfg", ] [[package]] @@ -514,6 +616,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -521,16 +632,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "opaque-debug" -version = "0.2.3" +name = "percent-encoding" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] -name = "percent-encoding" -version = "1.0.1" +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "portable-atomic" @@ -538,6 +655,12 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + [[package]] name = "predicates" version = "3.1.0" @@ -588,117 +711,32 @@ dependencies = [ [[package]] name = "rand" -version = "0.6.5" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ - "autocfg 0.1.8", "libc", "rand_chacha", - "rand_core 0.4.2", - "rand_hc", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi", + "rand_core", ] [[package]] name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ - "rand_core 0.4.2", + "ppv-lite86", + "rand_core", ] [[package]] name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "rand_core 0.3.1", + "getrandom", ] [[package]] @@ -730,6 +768,12 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + [[package]] name = "rustix" version = "0.38.31" @@ -740,7 +784,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -749,12 +793,6 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" -[[package]] -name = "safemem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072" - [[package]] name = "serde" version = "1.0.197" @@ -800,15 +838,33 @@ dependencies = [ ] [[package]] -name = "sha-1" -version = "0.8.2" +name = "sha1" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "block-buffer", + "cfg-if", + "cpufeatures", "digest", - "fake-simd", - "opaque-debug", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -818,12 +874,14 @@ dependencies = [ "anyhow", "arg", "assert_cmd", + "async-tungstenite", "command-group", "console", "ctrlc", "env_logger", + "futures", "indicatif", - "log 0.4.21", + "log", "minreq", "nix 0.28.0", "predicates", @@ -831,7 +889,8 @@ dependencies = [ "serde_json", "serde_yaml", "tempfile", - "websocket", + "tokio", + "tungstenite", "which", ] @@ -875,7 +934,7 @@ dependencies = [ "cfg-if", "fastrand", "rustix", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -885,14 +944,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] -name = "time" -version = "0.1.45" +name = "thiserror" +version = "1.0.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" dependencies = [ - "libc", - "wasi", - "winapi", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", ] [[package]] @@ -911,31 +979,55 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] -name = "traitobject" -version = "0.1.0" +name = "tokio" +version = "1.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" +checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +dependencies = [ + "backtrace", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.48.0", +] [[package]] -name = "typeable" -version = "0.1.2" +name = "tokio-macros" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.52", +] [[package]] -name = "typenum" -version = "1.17.0" +name = "tungstenite" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand", + "sha1", + "thiserror", + "url", + "utf-8", +] [[package]] -name = "unicase" -version = "1.4.2" +name = "typenum" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" -dependencies = [ - "version_check", -] +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" @@ -972,20 +1064,26 @@ checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" [[package]] name = "url" -version = "1.7.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ + "form_urlencoded", "idna", - "matches", "percent-encoding", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "version_check" -version = "0.1.5" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wait-timeout" @@ -998,35 +1096,9 @@ dependencies = [ [[package]] name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "websocket" -version = "0.26.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92aacab060eea423e4036820ddd28f3f9003b2c4d8048cbda985e5a14e18038d" -dependencies = [ - "hyper", - "rand", - "unicase", - "url", - "websocket-base", -] - -[[package]] -name = "websocket-base" -version = "0.26.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49aec794b07318993d1db16156d5a9c750120597a5ee40c6b928d416186cb138" -dependencies = [ - "base64 0.10.1", - "bitflags 1.3.2", - "byteorder", - "rand", - "sha-1", -] +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "which" @@ -1062,13 +1134,37 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.4", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -1077,51 +1173,93 @@ version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.4", + "windows_aarch64_msvc 0.52.4", + "windows_i686_gnu 0.52.4", + "windows_i686_msvc 0.52.4", + "windows_x86_64_gnu 0.52.4", + "windows_x86_64_gnullvm 0.52.4", + "windows_x86_64_msvc 0.52.4", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.4" diff --git a/Cargo.toml b/Cargo.toml index 0e860a05f2c6335394d44ce753cdf9baf5844079..d76346a3a1a08120eec01a03ec233a220fb9d2d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,17 +8,20 @@ edition = "2021" [dependencies] anyhow = "1.0.69" arg = { version = "0.4.1", features = ["std"] } +async-tungstenite = { version = "0.25.1", features = ["tokio-runtime"] } command-group = "2.1.0" console = "0.15.7" ctrlc = "3.2.5" env_logger = { version = "0.10.0", default_features = false, features = [] } +futures = "0.3.30" indicatif = "0.17.6" log = "0.4.17" minreq = "2.8.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.105" serde_yaml = "0.9" -websocket = { version = "0.26.5", default_features = false, features = ["sync"] } +tokio = { version = "1.37.0", features = ["rt", "sync", "macros"] } +tungstenite = "0.21.0" which = "4.4.2" [profile.release] diff --git a/docs/Changelog.md b/docs/Changelog.md index 744fc7eb234cec27b98a51ae9ba8f957f12a3bb6..d4e391b018b91e751f9a1dfb2a0bf6c4171ec609 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,3 +1,12 @@ +Unreleased +---------- + + * Internal changes: + + * Use [tungstenite](https://github.com/snapview/tungstenite-rs) to communicate with + websockets instead of [Rust-WebSocket](https://github.com/websockets-rs/rust-websocket). + * Reliability improvements in error situations. + 1.2.0 ----- diff --git a/src/backend/mod.rs b/src/backend/mod.rs index a7f4b0e78fba4bed3f36b78fb2006050ee6fb837..a36104fbf87ae0528cb4640ba0355cdfd8692ae2 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -145,10 +145,10 @@ impl Backend { if test_result == TestResult::Abort { self.stop_and_remove(); + } else { + self.remove_container_maybe(); } - self.remove_container_maybe(); - log_follower.kill() .unwrap_or_else(|err| error!("Failed to kill log follower process: {}", err)); let log_follower_wait_result = log_follower.wait(); @@ -241,9 +241,14 @@ impl Backend { } } - self.process_events(&rx, frontend_event_rx, &mut send_to_frontend, &isotovideo, &mut run_state)?; + let process_events_result = self.process_events(&rx, frontend_event_rx, &mut send_to_frontend, &isotovideo, &mut run_state); + if let Err(e) = process_events_result { + debug!("Error while processing events: {}", e); + run_state.result = TestResult::Abort; + break; + } if run_state.finished { - return Ok(run_state.result); + break; } let now = Instant::now(); @@ -255,6 +260,9 @@ impl Backend { tick = Instant::now(); next_tick = tick + Duration::from_millis(TICK_INTERVAL_MS); }; + + isotovideo.disconnect(); + return Ok(run_state.result); } fn process_events( @@ -276,6 +284,9 @@ impl Backend { send_to_frontend(&event); match status { + IsotovideoStatusMessage::ConnectionFailed { error } => { + bail!("Connection error to isotovideo: {}", error); + } IsotovideoStatusMessage::Paused { reason: _reason } => { run_state.paused = true; }, diff --git a/src/frontends/interactive/mod.rs b/src/frontends/interactive/mod.rs index f802b7aa8caa47c9f560a5ad5e48c1627f37faf4..43f1a64fa4e9cb3ae406c1957b991f209b229df0 100644 --- a/src/frontends/interactive/mod.rs +++ b/src/frontends/interactive/mod.rs @@ -150,9 +150,14 @@ impl InteractiveFrontend { match self.runner_event_rx.try_recv() { Ok(message) => { self.state = self.handle_event(&message); + if self.state == State::Exit { + break; + } } Err(TryRecvError::Empty) => break, - Err(error) => return Err(anyhow::Error::new(error)) + Err(_error) => { + panic!("Backend closed its channel without sending ProgramExit"); + }, } } @@ -245,8 +250,6 @@ impl InteractiveFrontend { next_tick = tick + Duration::from_millis(TICK_INTERVAL_MS); }; - self.await_program_exit(); - Ok(()) } @@ -357,23 +360,6 @@ impl InteractiveFrontend { } } - fn await_program_exit(&mut self) { - loop { - let result = self.runner_event_rx.recv(); - match result { - Ok(BackendEvent::ProgramExit { testsuite_result: _testsuite_result, error: _error }) => { - break; - } - Ok(_event) => { - debug!("Ignored, waiting for ProgramExit"); - }, - Err(_error) => { - break; - } - } - } - } - fn show_isotovideo_logs(&self) -> Result<(), anyhow::Error> { let log = self.output.get_isotovideo_log_for_testsuite(&self.testsuite_name)?; let log_messages = isotovideo::get_isotovideo_log_highlights(log.as_path())?; diff --git a/src/helpers/isotovideo/control.rs b/src/helpers/isotovideo/control.rs index 18d5b9a6ab88b98249d00a7323891459fcd98224..25f2cb5f62675dc9374e0a87e78d531d93ce93da 100644 --- a/src/helpers/isotovideo/control.rs +++ b/src/helpers/isotovideo/control.rs @@ -2,11 +2,12 @@ use anyhow::{anyhow, bail, Context}; use log::*; -use websocket::{ClientBuilder, WebSocketError}; -use websocket::sync::{Client, Reader, Writer}; -use websocket::stream::sync::TcpStream; +use futures::stream::StreamExt; +use futures::sink::SinkExt; +use tokio::runtime; +use tokio::sync::mpsc; -use std::sync::mpsc; +use std::env; use std::thread; use std::time::{Duration, Instant}; @@ -32,9 +33,24 @@ impl IsotovideoControl { } fn websocket_url(&self) -> String { - self.url("ws") + match env::var("_SSAM_OPENQA_WEBSOCKET_URL") { + Ok(url) => { + // This is used for fault injection during integration tests. + debug!("Injecting custom websocket URL {}", url); + url + }, + Err(env::VarError::NotPresent) => { + // This is the correct URL to use for the websocket. + format!("ws://localhost:{}/{}/ws", self.port, self.job_token) + }, + Err(env::VarError::NotUnicode(_)) => panic!("Invalid UTF-8 in _SSAM_OPENQA_WEBSOCKET_URL env var") + } } + // Get the version reported by isotovideo. + // + // This uses synchronous IO and will block until the endpoint responds + // or a request timeout or other error occurs. fn get_isotovideo_version(&self) -> Result { let url = self.url("isotovideo/version"); @@ -47,12 +63,13 @@ impl IsotovideoControl { .context("Failed to parse isotovideo version response") } + // Block the thread until the isotovideo control HTTP endpoint is responsive. fn await_ready(&self) -> Result<(), anyhow::Error> { let start_time = Instant::now(); loop { // Start by waiting a whole second - isotovideo is unlikely to respond // faster than that, as of 2023-06-04. - thread::sleep(Duration::from_secs(1)); + std::thread::sleep(Duration::from_secs(1)); if let Ok(version) = self.get_isotovideo_version() { info!("isotovideo HTTP endpoint version {} is ready", version); @@ -71,95 +88,112 @@ impl IsotovideoControl { } Ok(()) } - - fn connect_to_websocket(&self) -> Result<(Reader, Writer), anyhow::Error> { - self.await_ready()?; - - let mut client_builder = ClientBuilder::new(&self.websocket_url())?; - let client: Client = client_builder.connect_insecure()?; - - let (websocket_rx, websocket_tx) = client.split()?; - - Ok((websocket_rx, websocket_tx)) - } } /// Open control endpoint to running Isotovideo process. /// /// Status messages are passed to the `status_message_callback` function. /// -/// Control messages can be sent using the returned [mpsc::Sender] channel. +/// Control messages can be sent using the returned [mpsc::Sender] channel. The caller MUST send +/// message [IsotovideoControlMessage::DisconnectWatcher] before closing the channel. /// /// This function blocks until websocket is ready to send and receive messages. -pub fn watch_websocket_in_thread(port: u32, job_token: &str, mut status_message_callback: F) -> Result, anyhow::Error> +pub fn watch_websocket_in_thread(port: u32, job_token: &str, mut status_message_callback: F) -> Result, anyhow::Error> where F: FnMut(IsotovideoStatusMessage) + Send + 'static { let control = IsotovideoControl::new(port, job_token.to_string()); - let (control_tx, control_rx) = mpsc::channel::(); + + // Following the docs at : + // + // > For sending a message from sync to async, you should use an unbounded Tokio mpsc channel. + // + let (control_tx, mut control_rx) = mpsc::unbounded_channel::(); - // First start the reader thread, which will bring up the websocket connection. thread::spawn(move || { - let connection_result = control.connect_to_websocket(); - - if let Err(err) = connection_result { - status_message_callback(IsotovideoStatusMessage::ConnectionFailed { error: err.to_string() }); - return; - } - - let (mut websocket_rx, mut websocket_tx) = connection_result.unwrap(); + let runtime = runtime::Builder::new_current_thread() + .enable_io() + .build() + .unwrap(); + + runtime.block_on(async move { + // This will block the runtime thread. + let ready_result = control.await_ready(); + if let Err(err) = ready_result { + status_message_callback( + IsotovideoStatusMessage::ConnectionFailed { + error: format!("await_ready failed: {err}").to_string() + } + ); + return; + }; + + let url = control.websocket_url(); + let connect_result = async_tungstenite::tokio::connect_async(&url) + .await; + if let Err(err) = connect_result { + status_message_callback( + IsotovideoStatusMessage::ConnectionFailed { + error: format!("connect_async({url}) failed: {err}").to_string() + } + ); + return; + }; + let (mut websocket, _response) = connect_result.unwrap(); - // Start the writer thread now we have the websocket connection. - thread::spawn(move || { loop { - match control_rx.recv() { - Ok(control_message) => { - let message = websocket::Message::text(control_message.to_json()); - websocket_tx.send_message(&message) - .unwrap_or_else(|err| error!("Failed to send message to isotovideo control socket: {}", err)); - }, - Err(_) => { - debug!("isotovideo control socket closed, exiting writer thead"); - break; - }, - } - } - debug!("Exiting isotovideo websocket writer thread"); - }); - - // Reader thread main loop - loop { - match websocket_rx.recv_message() { - Ok(websocket_message) => { - match IsotovideoStatusMessage::from_websocket_message(&websocket_message) { - Ok(isotovideo_message) => { - let should_exit = matches!{ - isotovideo_message, - IsotovideoStatusMessage::StopProcessingIsotovideoCommands { stop: _stop } - }; - - status_message_callback(isotovideo_message); - - if should_exit { + tokio::select!{ + websocket_message = websocket.next() => { + let websocket_message = match websocket_message { + Some(websocket_message) => websocket_message, + None => { + status_message_callback(IsotovideoStatusMessage::ConnectionFailed { + error: "Websocket closed unexpectedly".to_string() + }); break; } + }; + + match websocket_message { + Ok(websocket_message) => { + match IsotovideoStatusMessage::from_websocket_message(&websocket_message) { + Ok(isotovideo_message) => { + let should_exit = matches!{ + isotovideo_message, + IsotovideoStatusMessage::StopProcessingIsotovideoCommands { stop: _stop } + }; + + status_message_callback(isotovideo_message); + + if should_exit { + break; + } + } + Err(e) => { + eprintln!("Unhandled isotovideo status message: {}", e); + } + } + }, + Err(e) => { + error!("Unable to read isotovideo status message: {}", e); + }, } - Err(e) => { - eprintln!("Unhandled isotovideo status message: {}", e); + }, + control_message_option = control_rx.recv() => { + let control_message = control_message_option + .expect("Control websocket snould not close until DisconnectWatcher message is sent."); + if let IsotovideoControlMessage::DisconnectWatcher = control_message { + break; } + let message = tungstenite::Message::text(control_message.to_json()); + websocket.send(message) + .await + .unwrap_or_else(|err| error!("Failed to send message to isotovideo control socket: {}", err)); } - }, - Err(WebSocketError::NoDataAvailable) => { - // This happens on shutdown - info!("No data available on websocket, exiting read loop"); - break; - }, - Err(e) => { - error!("Unable to read isotovideo status message: {}", e); - }, - } - } - debug!("Exiting isotovideo websocket reader thread"); + } + debug!("Exiting isotovideo websocket thread"); + }; + }); }); Ok(control_tx) diff --git a/src/helpers/isotovideo/control_message.rs b/src/helpers/isotovideo/control_message.rs index 169ec76b2688633766ee7e402635505b6081e247..b05ab79e4a670037bc35e4b174ef9967ac0e281a 100644 --- a/src/helpers/isotovideo/control_message.rs +++ b/src/helpers/isotovideo/control_message.rs @@ -20,6 +20,9 @@ pub enum IsotovideoControlMessage { SetPauseOnNextCommand { flag: bool }, SetPauseOnScreenMismatch { pause_on: String }, Status, + // This is a special message to the websocket watch thread + // to shut down. + DisconnectWatcher, } impl IsotovideoControlMessage { @@ -32,6 +35,7 @@ impl IsotovideoControlMessage { IsotovideoControlMessage::SetPauseOnNextCommand { flag: _ } => "set_pause_on_next_command", IsotovideoControlMessage::SetPauseOnScreenMismatch { pause_on: _ } => "set_pause_on_screen_mismatch", IsotovideoControlMessage::Status => "status", + IsotovideoControlMessage::DisconnectWatcher => "[disconnect watcher thread]", } } diff --git a/src/helpers/isotovideo/mod.rs b/src/helpers/isotovideo/mod.rs index 84f91d193c673dba3ae1a03a572dc6de8c3e8622..6fdae0d2d6f3c5295fc3afa6e06c6e745fe06d8d 100644 --- a/src/helpers/isotovideo/mod.rs +++ b/src/helpers/isotovideo/mod.rs @@ -11,11 +11,11 @@ pub mod status_message; pub mod test_order; pub mod test_result; -use std::sync::mpsc::{self, TryRecvError}; - use anyhow::{self, bail}; use log::*; +use std::sync::mpsc::{self, TryRecvError}; + use crate::helpers::container::ContainerRuntime; pub use self::config::IsotovideoConfig; @@ -35,7 +35,11 @@ pub const OPENQA_VNC_PORT: u32 = 5990; /// Top level helper class for communicating with a running Isotovideo process /// using the control websocket. pub struct IsotovideoHelper { - control_tx: mpsc::Sender::, + // This uses the tokio async channel type, because its communicating with + // an async_tungstenite websocket. Tungstenite websockets can only be + // used from async code. + control_tx: tokio::sync::mpsc::UnboundedSender::, + status_tx: mpsc::Sender::, status_rx: mpsc::Receiver::, } @@ -46,8 +50,8 @@ impl IsotovideoHelper { /// This function will block until able to connect with the /// control websocket. /// - /// This function spawns a thread which will run as long as the - /// control websocket remains open. + /// This function spawns a thread which will run until the + /// [IsotovideoHelper::disconnect()] method is called /// /// The `event_callback` will be called from the thread every time /// a message is received from Isotovideo. @@ -74,6 +78,12 @@ impl IsotovideoHelper { Ok(Self { control_tx, status_tx, status_rx }) } + pub fn disconnect(&self) { + self.control_tx.send(IsotovideoControlMessage::DisconnectWatcher) + // This can happen if there's an error with the websocket connection. + .unwrap_or_else(|_e| debug!("isotovideo control channel already closed")); + } + /// Receive status messages from Isotovideo, if available. /// /// See mpsc::Receiver::try_recv() for details on how this works. diff --git a/src/helpers/isotovideo/status_message.rs b/src/helpers/isotovideo/status_message.rs index fb1e48467f947d95983feaa8267f9629e7a2c494..29b5315a92881b63dc4c0e4b4b5e0d266f37d612 100644 --- a/src/helpers/isotovideo/status_message.rs +++ b/src/helpers/isotovideo/status_message.rs @@ -10,7 +10,7 @@ use anyhow::{anyhow, bail}; use log::*; use serde::Serialize; -use websocket::OwnedMessage; +use tungstenite::Message; type JsonValue = serde_json::value::Value; type JsonObject = serde_json::Map; @@ -107,9 +107,9 @@ impl IsotovideoStatusMessage { bail!("Unknown status message: {:?}", object); } - pub fn from_websocket_message(message: &OwnedMessage) -> Result { + pub fn from_websocket_message(message: &Message) -> Result { match message { - OwnedMessage::Text(text) => { + Message::Text(text) => { match serde_json::from_str(text) { Ok(JsonValue::Object(object)) => { Self::from_json_object(&object) diff --git a/src/main.rs b/src/main.rs index c00081968befe82e608833233664532556643c96..bbac2b5ea7fe2e508a4128a6fa0398c7a56b5194 100644 --- a/src/main.rs +++ b/src/main.rs @@ -328,6 +328,7 @@ impl CommandRun { } } + info!("Sending ProgramExit to frontend"); match overall_result { Err(e) => { runner_event_tx.send(BackendEvent::ProgramExit { diff --git a/tests/minimal_abort.rs b/tests/minimal_abort.rs new file mode 100644 index 0000000000000000000000000000000000000000..9f065b37f2df707edc357353afbaa0b3dbfcff3d --- /dev/null +++ b/tests/minimal_abort.rs @@ -0,0 +1,38 @@ +mod fixtures; + +use assert_cmd::prelude::*; + +use serde_json::json; + +use fixtures::{assert_frontend_message, parse_json_frontend_output, RealScenario}; + +/// Scenario in which connection to isotovideo control socket fails. +#[test] +#[ignore] +fn test_minimal_abort() { + let fixture = RealScenario::new(); + + let mut cmd = fixture.cmd("minimal_test_expected_fail"); + cmd.env("_SSAM_OPENQA_WEBSOCKET_URL", "http://fault-injection-invalid-url"); + let cmd_result = cmd.assert(); + + let messages = parse_json_frontend_output(&cmd_result.get_output().stdout); + + for message in &messages { + println!("{}", message); + } + + assert_frontend_message( + &messages, + &json!({"IsotovideoContainerStart":"ssam_openqa_minimal_test_expected_fail"}), + ); + assert_frontend_message(&messages, &json!({"TestOrder":["expected_fail"]})); + assert_frontend_message( + &messages, + &json!({"IsotovideoStatus":{"ConnectionFailed":{"error": "connect_async(http://fault-injection-invalid-url) failed: URL error: URL scheme not supported"}}}), + ); + assert_frontend_message( + &messages, + &json!({"ProgramExit":{"testsuite_result":"Abort","error":null}}), + ); +}