diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d6192a1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,71 @@ +# copy of https://github.com/actions-rs/meta/blob/master/recipes/quickstart.md +on: [push, pull_request] + +name: Continuous integration + +jobs: + check: + name: Check + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: check + + test: + name: Test Suite + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add clippy + - uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21a72d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +book +/target +/vendor +.idea/ +.vscode/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..bf1bebe --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1980 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "addr2line" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccc9a9dd069569f212bc4330af9f17c4afb5e8ce185e83dbb14f1349dda18b10" + +[[package]] +name = "aho-corasick" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" +dependencies = [ + "memchr", +] + +[[package]] +name = "arc-swap" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" + +[[package]] +name = "assert_fs" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dabd011e19821a348abb0dec7b7fda959cd6b3477c474395b958b291942b0e" +dependencies = [ + "doc-comment", + "globwalk", + "predicates", + "predicates-core", + "predicates-tree", + "tempfile", +] + +[[package]] +name = "autocfg" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" + +[[package]] +name = "backtrace" +version = "0.3.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46254cf2fdcdf1badb5934448c1bcbe046a56537b3987d96c51a7afc5d03f293" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" + +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[package]] +name = "bawawa" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8a0b511f881feae65eb88a002da86c4346f2fc09135ac0934d420ef79cc7ee1" +dependencies = [ + "error-chain", + "futures", + "tokio-codec", + "tokio-io", + "tokio-process", +] + +[[package]] +name = "bech32" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdcf67bb7ba7797a081cd19009948ab533af7c355d5caf1d08c777582d351e9c" + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "bstr" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31accafdb70df7871592c058eca3985b71104e15ac32f64706022c58867da931" +dependencies = [ + "memchr", +] + +[[package]] +name = "bumpalo" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "bytes" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" +dependencies = [ + "byteorder", + "iovec", +] + +[[package]] +name = "bytes" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "118cf036fbb97d0816e3c34b2d7a1e8cfc60f68fcf63d550ddbe9bd5f59c213b" +dependencies = [ + "loom", +] + +[[package]] +name = "bytesize" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81a18687293a1546b67c246452202bbbf143d239cb43494cc163da14979082da" + +[[package]] +name = "bzip2" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.9+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad3b39a260062fca31f7b0b12f207e8f2590a67d32ec7d59c20484b07ea7285e" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "cc" +version = "1.0.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "chrono" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c74d84029116787153e02106bf53e66828452a4b325cc8652b788b5967c0a0b6" +dependencies = [ + "num-integer", + "num-traits", + "serde", + "time", +] + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils 0.7.2", + "lazy_static", + "maybe-uninit", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b" +dependencies = [ + "crossbeam-utils 0.6.6", +] + +[[package]] +name = "crossbeam-queue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +dependencies = [ + "cfg-if", + "crossbeam-utils 0.7.2", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-utils" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6" +dependencies = [ + "cfg-if", + "lazy_static", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if", + "lazy_static", +] + +[[package]] +name = "custom_debug" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8225047674d65dcf4321e6bd3e060bdbbe940604a99b1559827f3e61c498d1e" +dependencies = [ + "custom_debug_derive", +] + +[[package]] +name = "custom_debug_derive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b35d34eb004bf2d33c093f1c55ee77829e8654644288d3b6afd8c2d99d23729" +dependencies = [ + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "dtoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" + +[[package]] +name = "either" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" + +[[package]] +name = "encoding_rs" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "error-chain" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d371106cc88ffdfb1eabd7111e432da544f16f3e2d7bf1dfe8bf575f1df045cd" +dependencies = [ + "backtrace", + "version_check", +] + +[[package]] +name = "filetime" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "affc17579b132fc2461adf7c575cc6e8b134ebca52c51f5411388965227dc695" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + +[[package]] +name = "flate2" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c90b0fc46cf89d227cc78b40e494ff81287a92dd07631e5af0d06fe3cf885e" +dependencies = [ + "cfg-if", + "crc32fast", + "libc", + "miniz_oxide", +] + +[[package]] +name = "float-cmp" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da62c4f1b81918835a8c6a484a397775fff5953fe83529afd51b05f5c6a6617d" +dependencies = [ + "num-traits", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" + +[[package]] +name = "futures-channel" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" + +[[package]] +name = "futures-io" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" + +[[package]] +name = "futures-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" + +[[package]] +name = "futures-task" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +dependencies = [ + "once_cell", +] + +[[package]] +name = "futures-util" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +dependencies = [ + "futures-core", + "futures-io", + "futures-macro", + "futures-task", + "memchr", + "pin-project", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "generator" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add72f17bb81521258fcc8a7a3245b1e184e916bfbe34f0ea89558f440df5c68" +dependencies = [ + "cc", + "libc", + "log", + "rustc_version", + "winapi 0.3.9", +] + +[[package]] +name = "getrandom" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724" + +[[package]] +name = "globset" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ad1da430bd7281dde2576f44c84cc3f0f7b475e7202cd503042dff01a8c8120" +dependencies = [ + "aho-corasick", + "bstr", + "fnv", + "log", + "regex", +] + +[[package]] +name = "globwalk" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9db17aec586697a93219b19726b5b68307eba92898c34b170857343fe67c99d" +dependencies = [ + "ignore", + "walkdir", +] + +[[package]] +name = "h2" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b7246d7e4b979c03fa093da39cfb3617a96bbeee6310af63991668d7e843ff" +dependencies = [ + "bytes 0.5.5", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "log", + "slab", + "tokio", + "tokio-util", +] + +[[package]] +name = "hermit-abi" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35" + +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes 0.5.5", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes 0.5.5", + "http", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "humantime" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a" + +[[package]] +name = "hyper" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6e7655b9594024ad0ee439f3b5a7299369dc2a3f459b47c696f9ff676f9aa1f" +dependencies = [ + "bytes 0.5.5", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "log", + "pin-project", + "socket2", + "time", + "tokio", + "tower-service", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac965ea399ec3a25ac7d13b8affd4b8f39325cca00858ddf5eb29b79e6b14b08" +dependencies = [ + "bytes 0.5.5", + "futures-util", + "hyper", + "log", + "rustls", + "tokio", + "tokio-rustls", + "webpki", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "ignore" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22dcbf2a4a289528dbef21686354904e1c694ac642610a9bff9e7df730d9ec72" +dependencies = [ + "crossbeam-utils 0.7.2", + "globset", + "lazy_static", + "log", + "memchr", + "regex", + "same-file", + "thread_local", + "walkdir", + "winapi-util", +] + +[[package]] +name = "indexmap" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" +dependencies = [ + "autocfg", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + +[[package]] +name = "jortestkit" +version = "0.1.0" +dependencies = [ + "assert_fs", + "bawawa", + "bech32", + "bytesize", + "chrono", + "custom_debug", + "flate2", + "futures", + "hex", + "humantime", + "lazy_static", + "os_info", + "rand", + "rand_chacha", + "rand_core", + "reqwest", + "serde", + "serde_derive", + "serde_json", + "serde_yaml", + "sysinfo", + "tar", + "thiserror", + "tokio-codec", + "zip", +] + +[[package]] +name = "js-sys" +version = "0.3.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4b9172132a62451e56142bff9afc91c8e4a4500aa5b847da36815b63bfda916" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701" + +[[package]] +name = "linked-hash-map" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" + +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "loom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ecc775857611e1df29abba5c41355cdf540e7e9d4acfdf0f355eefee82330b7" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" + +[[package]] +name = "memoffset" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mime_guess" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0f75932c1f6cfae3c04000e40114adf955636e19040f9c0a2c380702aa1c7f" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +dependencies = [ + "cfg-if", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow 0.2.1", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-named-pipes" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" +dependencies = [ + "log", + "mio", + "miow 0.3.5", + "winapi 0.3.9", +] + +[[package]] +name = "mio-uds" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +dependencies = [ + "iovec", + "libc", + "mio", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "miow" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +dependencies = [ + "socket2", + "winapi 0.3.9", +] + +[[package]] +name = "net2" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + +[[package]] +name = "ntapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a31937dea023539c72ddae0e3571deadc1414b300483fa7aaec176168cfa9d2" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "num-integer" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" + +[[package]] +name = "once_cell" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" + +[[package]] +name = "os_info" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cc1fe7b45f7e51f755195fd86b0483dbae30fdcf831a3254438d29118d12c4" +dependencies = [ + "log", + "winapi 0.3.9", +] + +[[package]] +name = "parking_lot" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +dependencies = [ + "lock_api", + "parking_lot_core", + "rustc_version", +] + +[[package]] +name = "parking_lot_core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +dependencies = [ + "cfg-if", + "cloudabi", + "libc", + "redox_syscall", + "rustc_version", + "smallvec", + "winapi 0.3.9", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" + +[[package]] +name = "podio" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b18befed8bc2b61abc79a457295e7e838417326da1586050b919414073977f19" + +[[package]] +name = "ppv-lite86" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" + +[[package]] +name = "predicates" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "347a1b6f0b21e636bc9872fb60b83b8e185f6f5516298b8238699f7f9a531030" +dependencies = [ + "difference", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" + +[[package]] +name = "predicates-tree" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +dependencies = [ + "predicates-core", + "treeline", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" + +[[package]] +name = "proc-macro-nested" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" + +[[package]] +name = "proc-macro2" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "rayon" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" +dependencies = [ + "crossbeam-deque", + "crossbeam-queue 0.2.3", + "crossbeam-utils 0.7.2", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" + +[[package]] +name = "regex" +version = "1.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "reqwest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b82c9238b305f26f53443e3a4bc8528d64b8d0bee408ec949eb7bf5635ec680" +dependencies = [ + "base64 0.12.3", + "bytes 0.5.5", + "encoding_rs", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "hyper-rustls", + "js-sys", + "lazy_static", + "log", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "rustls", + "serde", + "serde_urlencoded", + "tokio", + "tokio-rustls", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + +[[package]] +name = "ring" +version = "0.16.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "952cd6b98c85bbc30efa1ba5783b8abf12fec8b3287ffa52605b9432313e34e4" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi 0.3.9", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver", +] + +[[package]] +name = "rustls" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0d4a31f5d68413404705d6982529b0e11a9aacd4839d1d6222ee3b8cb4015e1" +dependencies = [ + "base64 0.11.0", + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sct" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3042af939fca8c3453b7af0f1c66e533a15a86169e39de2657310ade8f98d3c" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3433e879a558dde8b5e8feb2a04899cf34fdde1fafb894687e52105fc1162ac3" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa", + "serde", + "url", +] + +[[package]] +name = "serde_yaml" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae3e2dd40a7cdc18ca80db804b7f461a39bb721160a85c9a1fa30134bf3c02a5" +dependencies = [ + "dtoa", + "linked-hash-map", + "serde", + "yaml-rust", +] + +[[package]] +name = "signal-hook-registry" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" +dependencies = [ + "arc-swap", + "libc", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "smallvec" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" +dependencies = [ + "maybe-uninit", +] + +[[package]] +name = "socket2" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "syn" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "synstructure" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "unicode-xid", +] + +[[package]] +name = "sysinfo" +version = "0.14.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da868225e7c7c75342ee400f8e2de2da0e8e07c9cd73649f4a2b961f2f71a171" +dependencies = [ + "cfg-if", + "doc-comment", + "libc", + "ntapi", + "once_cell", + "rayon", + "winapi 0.3.9", +] + +[[package]] +name = "tar" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8a4c1d0bee3230179544336c15eefb563cf0302955d962e456542323e8c2e8a" +dependencies = [ + "filetime", + "libc", + "redox_syscall", + "xattr", +] + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.9", +] + +[[package]] +name = "thiserror" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "time" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +dependencies = [ + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "tinyvec" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" + +[[package]] +name = "tokio" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d099fa27b9702bed751524694adbe393e18b36b204da91eb1cbbbbb4a5ee2d58" +dependencies = [ + "bytes 0.5.5", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "memchr", + "mio", + "num_cpus", + "pin-project-lite", + "slab", +] + +[[package]] +name = "tokio-codec" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" +dependencies = [ + "bytes 0.4.12", + "futures", + "tokio-io", +] + +[[package]] +name = "tokio-executor" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures", +] + +[[package]] +name = "tokio-io" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" +dependencies = [ + "bytes 0.4.12", + "futures", + "log", +] + +[[package]] +name = "tokio-process" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382d90f43fa31caebe5d3bc6cfd854963394fff3b8cb59d5146607aaae7e7e43" +dependencies = [ + "crossbeam-queue 0.1.2", + "futures", + "lazy_static", + "libc", + "log", + "mio", + "mio-named-pipes", + "tokio-io", + "tokio-reactor", + "tokio-signal", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-reactor" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" +dependencies = [ + "crossbeam-utils 0.7.2", + "futures", + "lazy_static", + "log", + "mio", + "num_cpus", + "parking_lot", + "slab", + "tokio-executor", + "tokio-io", + "tokio-sync", +] + +[[package]] +name = "tokio-rustls" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15cb62a0d2770787abc96e99c1cd98fcf17f94959f3af63ca85bdfb203f051b4" +dependencies = [ + "futures-core", + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-signal" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c34c6e548f101053321cba3da7cbb87a610b85555884c41b07da2eb91aff12" +dependencies = [ + "futures", + "libc", + "mio", + "mio-uds", + "signal-hook-registry", + "tokio-executor", + "tokio-io", + "tokio-reactor", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-sync" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" +dependencies = [ + "fnv", + "futures", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes 0.5.5", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] +name = "treeline" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" + +[[package]] +name = "try-lock" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +dependencies = [ + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "walkdir" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +dependencies = [ + "same-file", + "winapi 0.3.9", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasm-bindgen" +version = "0.2.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2" +dependencies = [ + "cfg-if", + "serde", + "serde_json", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df" +dependencies = [ + "bumpalo", + "lazy_static", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba48d66049d2a6cc8488702e7259ab7afc9043ad0dc5448444f46f2a453b362" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae" + +[[package]] +name = "web-sys" +version = "0.3.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863539788676619aac1a23e2df3655e96b32b0e05eb72ca34ba045ad573c625d" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab146130f5f790d45f82aeeb09e55a256573373ec64409fc19a6fb82fb1032ae" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8eff4b7516a57307f9349c64bf34caa34b940b66fed4b2fb3136cb7386e5739" +dependencies = [ + "webpki", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winreg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "xattr" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c" +dependencies = [ + "libc", +] + +[[package]] +name = "yaml-rust" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "zip" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58287c28d78507f5f91f2a4cf1e8310e2c76fd4c6932f93ac60fd1ceb402db7d" +dependencies = [ + "bzip2", + "crc32fast", + "flate2", + "podio", + "time", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..1f210e2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "jortestkit" +version = "0.1.0" +authors = ["dkijania "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +bawawa = "0.1.5" +bech32 = "0.7" +bytesize = "1.0.1" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +rand = "0.7" +rand_core = "0.5" +rand_chacha = "0.2" +chrono = { version = "0.4", features = ["serde"] } +humantime = "2.0" +custom_debug = "0.5" +thiserror = "1.0" +sysinfo = { version = "0.14.10" } +os_info = { version = "2.0.6", default-features = false } +zip = "0.5.6" +flate2 = "1.0.16" +tar = "0.4" +hex = "0.4" +lazy_static = "1" +serde_derive = "1.0" +assert_fs = "1.0" +serde_yaml = "0.8" +tokio-codec = "0.1" +futures = "0.1" + +[dependencies.reqwest] +version = "0.10.6" +default-features = false +features = ["blocking", "rustls-tls"] \ No newline at end of file diff --git a/images/automation_coverage.PNG b/images/automation_coverage.PNG deleted file mode 100644 index 87d8278..0000000 Binary files a/images/automation_coverage.PNG and /dev/null differ diff --git a/images/automation_passrate.PNG b/images/automation_passrate.PNG deleted file mode 100644 index 7b6b06f..0000000 Binary files a/images/automation_passrate.PNG and /dev/null differ diff --git a/src/archive/mod.rs b/src/archive/mod.rs new file mode 100644 index 0000000..a5801ca --- /dev/null +++ b/src/archive/mod.rs @@ -0,0 +1,54 @@ +extern crate flate2; +extern crate tar; +extern crate zip; + +use flate2::read::GzDecoder; +use std::fs::File; +use std::io; +use std::path::Path; +use tar::Archive; +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum DecompressError { + #[error("could not open input file")] + CannotOpenArchiveFile, + #[error("could not write output file")] + CannotWriteOutputFile(#[from] io::Error), + #[error("internal unpack error")] + IntenralZipError(#[from] zip::result::ZipError), + #[error("internal unpack error")] + UnpackError, + #[error("unsupported format")] + UnsupportedFormat, +} + +pub fn decompress(input: &Path, output: &Path) -> Result<(), DecompressError> { + let path = input + .as_os_str() + .to_str() + .expect("cannot convert input path to os str"); + if path.ends_with(".zip") { + let file = File::open(&path).map_err(|_| DecompressError::CannotOpenArchiveFile)?; + let mut archive = zip::ZipArchive::new(file)?; + for i in 0..archive.len() { + let mut file = archive + .by_index(i) + .map_err(|_| DecompressError::UnpackError)?; + let outpath = output.join(file.sanitized_name()); + let mut outfile = + File::create(&outpath).map_err(DecompressError::CannotWriteOutputFile)?; + io::copy(&mut file, &mut outfile)?; + } + return Ok(()); + } else if path.ends_with(".tar.gz") { + let tar_gz = File::open(path).map_err(|_| DecompressError::CannotOpenArchiveFile)?; + let tar = GzDecoder::new(tar_gz); + let mut archive = Archive::new(tar); + archive + .unpack(output) + .map_err(|_| DecompressError::UnpackError)?; + return Ok(()); + } + Err(DecompressError::UnsupportedFormat) +} diff --git a/src/github/mod.rs b/src/github/mod.rs new file mode 100644 index 0000000..25766d5 --- /dev/null +++ b/src/github/mod.rs @@ -0,0 +1,119 @@ +mod release; + +use os_info::Type as OsType; +pub use release::{AssetDto, ReleaseDto}; +use reqwest::header::USER_AGENT; +use std::collections::HashMap; +use std::time::SystemTime; +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum GitHubApiError { + #[error("could not deserialize response")] + CannotDeserialize(#[from] serde_json::Error), + #[error("could not send reqeuest")] + RequestError(#[from] reqwest::Error), +} + +#[derive(Clone, Debug)] +pub struct Release { + version: String, + released_date: SystemTime, + releases_per_os: HashMap, + prerelease: bool, +} + +impl Release { + pub fn get_release_for_os(&self, os_type: OsType) -> Option { + let compacted_os_type = self.compact_os_types(os_type); + self.releases_per_os().get(&compacted_os_type).cloned() + } + + /// narrow linux distribution to linux type + fn compact_os_types(&self, os_type: OsType) -> OsType { + match os_type { + OsType::Emscripten => OsType::Linux, + OsType::Redhat => OsType::Linux, + OsType::RedHatEnterprise => OsType::Linux, + OsType::Ubuntu => OsType::Linux, + OsType::Debian => OsType::Linux, + OsType::Arch => OsType::Linux, + OsType::Centos => OsType::Linux, + OsType::Fedora => OsType::Linux, + OsType::Amazon => OsType::Linux, + OsType::SUSE => OsType::Linux, + OsType::openSUSE => OsType::Linux, + OsType::Alpine => OsType::Linux, + OsType::OracleLinux => OsType::Linux, + _ => os_type, + } + } + + pub fn releases_per_os(&self) -> &HashMap { + &self.releases_per_os + } + + pub fn version(&self) -> String { + self.version.clone() + } + + pub fn prerelease(&self) -> bool { + self.prerelease + } +} + +pub struct GitHubApi { + base_url: String, +} + +impl Default for GitHubApi { + fn default() -> Self { + Self::new() + } +} + +impl GitHubApi { + pub fn new() -> Self { + Self { + base_url: "https://api.github.com/repos/input-output-hk/jormungandr".to_string(), + } + } + + fn get(&self, path: &str) -> Result { + let client = reqwest::blocking::Client::new(); + client + .get(&format!("{}/{}", self.base_url, path)) + .header(USER_AGENT, "request") + .send() + .map_err(GitHubApiError::RequestError) + } + + pub fn describe_releases(&self) -> Result, GitHubApiError> { + let response_text = self.get("releases")?.text()?; + let releases: Vec = + serde_json::from_str(&response_text).map_err(GitHubApiError::CannotDeserialize)?; + Ok(releases + .iter() + .cloned() + .map(|release| release.into()) + .collect()) + } + + pub fn get_asset_for_current_os_by_version( + &self, + version: String, + ) -> Result, GitHubApiError> { + let info = os_info::get(); + Ok( + match self + .describe_releases()? + .iter() + .cloned() + .find(|x| x.version == version) + { + None => None, + Some(release) => release.get_release_for_os(info.os_type()), + }, + ) + } +} diff --git a/src/github/release.rs b/src/github/release.rs new file mode 100644 index 0000000..ae929a9 --- /dev/null +++ b/src/github/release.rs @@ -0,0 +1,85 @@ +use crate::github::Release; +use os_info::Type as OsType; +use serde::{Deserialize, Serialize}; +use std::time::SystemTime; + +#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] +pub struct ReleaseDto { + tag_name: String, + published_at: SystemTime, + assets: Vec, + prerelease: bool, +} + +impl Into for ReleaseDto { + fn into(self) -> Release { + Release { + version: self.tag_name.clone(), + released_date: self.published_at, + releases_per_os: self + .assets + .iter() + .cloned() + .map(|x| (x.os_type(), x)) + .collect(), + prerelease: self.prerelease, + } + } +} + +impl ReleaseDto { + pub fn tag_name(self) -> String { + self.tag_name + } + + pub fn published_at(&self) -> &SystemTime { + &self.published_at + } + + pub fn assets(&self) -> &Vec { + &self.assets + } + + pub fn prerelease(&self) -> bool { + self.prerelease + } +} + +#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)] +pub struct AssetDto { + browser_download_url: String, + name: String, +} + +impl AssetDto { + pub fn os_type(&self) -> OsType { + if self.is_x86_64() && self.is_windows() { + return OsType::Windows; + } else if self.is_x86_64() && self.is_unix() { + return OsType::Linux; + } else if self.is_x86_64() && self.is_apple() { + return OsType::Macos; + } + OsType::Unknown + } + + fn is_x86_64(&self) -> bool { + self.name.contains("x86_64") + } + + fn is_windows(&self) -> bool { + self.name.contains("windows") + } + + fn is_apple(&self) -> bool { + self.name.contains("apple") + } + + fn is_unix(&self) -> bool { + self.name.contains("linux") + } + + pub fn download_url(&self) -> String { + self.browser_download_url.clone() + } +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..7e1af78 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,20 @@ +pub mod archive; +pub mod github; +pub mod measurement; +pub mod openssl; +pub mod process; +pub mod web; + +pub mod prelude { + pub use crate::archive::decompress; + pub use crate::github::{GitHubApi, GitHubApiError, Release}; + pub use crate::measurement::{ + benchmark_consumption, benchmark_efficiency, benchmark_endurance, benchmark_speed, + ConsumptionBenchmarkError, ConsumptionBenchmarkRun, EfficiencyBenchmarkDef, + EfficiencyBenchmarkFinish, EfficiencyBenchmarkRun, Endurance, EnduranceBenchmarkDef, + EnduranceBenchmarkFinish, EnduranceBenchmarkRun, NamedProcess, ResourcesUsage, Speed, + SpeedBenchmarkDef, SpeedBenchmarkFinish, SpeedBenchmarkRun, Thresholds, Timestamp, + }; + pub use crate::openssl::Openssl; + pub use crate::web::download_file; +} diff --git a/src/measurement/attribute/consumption.rs b/src/measurement/attribute/consumption.rs new file mode 100644 index 0000000..3c303e0 --- /dev/null +++ b/src/measurement/attribute/consumption.rs @@ -0,0 +1,86 @@ +use crate::measurement::{marker::ResourcesUsage, status::Status, thresholds::Thresholds}; +use std::{cmp::Ordering, fmt}; + +#[derive(Debug, Clone, Eq, PartialEq, Hash)] +pub struct NamedProcess { + name: String, + id: usize, +} + +impl NamedProcess { + pub fn new(name: String, id: usize) -> Self { + Self { name, id } + } + + pub fn name(&self) -> String { + self.name.to_string() + } + + pub fn id(&self) -> usize { + self.id + } +} + +impl fmt::Display for NamedProcess { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "id: {}, alias: {}", self.id, self.name) + } +} + +#[derive(Clone, Debug)] +pub struct Consumption { + average_usage: ResourcesUsage, +} + +impl fmt::Display for Consumption { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.average_usage) + } +} + +impl PartialEq for Consumption { + fn eq(&self, other: &Self) -> bool { + self.average_usage == other.average_usage + } +} + +impl PartialOrd for Consumption { + fn partial_cmp(&self, other: &Self) -> Option { + self.average_usage.partial_cmp(&other.average_usage) + } +} + +impl Consumption { + pub fn new(markers: Vec) -> Self { + Self { + average_usage: Self::average_resource_usage(markers), + } + } + + fn average_resource_usage(markers: Vec) -> ResourcesUsage { + let average_cpu = Self::median(markers.iter().map(|x| x.cpu_usage()).collect()); + let average_memory = Self::median(markers.iter().map(|x| x.memory_usage()).collect()); + let average_virtual_memory = + Self::median(markers.iter().map(|x| x.virtual_memory_usage()).collect()); + ResourcesUsage::new(average_cpu, average_memory, average_virtual_memory) + } + + fn median(mut markers: Vec) -> u32 { + markers.sort(); + let mid = markers.len() / 2; + *markers.get(mid).unwrap() + } + + pub fn against(&self, thresholds: &Thresholds) -> Status { + let green = thresholds.green_threshold(); + let yellow = thresholds.yellow_threshold(); + + if *self <= green { + return Status::Green; + } + if *self <= yellow { + return Status::Yellow; + } + Status::Red + } +} diff --git a/src/measurement/attribute/efficiency.rs b/src/measurement/attribute/efficiency.rs new file mode 100644 index 0000000..b3c820f --- /dev/null +++ b/src/measurement/attribute/efficiency.rs @@ -0,0 +1,48 @@ +use crate::measurement::{status::Status, thresholds::Thresholds}; +use std::{cmp::Ordering, fmt}; + +#[derive(Clone, Debug)] +pub struct Efficiency { + counted: u32, + max: u32, +} + +impl PartialOrd for Efficiency { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.counted.cmp(&other.counted)) + } +} + +impl PartialEq for Efficiency { + fn eq(&self, other: &Self) -> bool { + self.counted == other.counted + } +} + +impl fmt::Display for Efficiency { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let counted = self.counted as f32; + let max = self.max as f32; + let percentage = (counted / max) * 100.0; + write!(f, "{:.1} % ({}/{}).", percentage, self.counted, self.max) + } +} + +impl Efficiency { + pub fn new(counted: u32, max: u32) -> Self { + Self { counted, max } + } + + pub fn against(&self, thresholds: &Thresholds) -> Status { + let green = thresholds.green_threshold(); + let yellow = thresholds.yellow_threshold(); + + if *self >= green { + return Status::Green; + } + if *self >= yellow { + return Status::Yellow; + } + Status::Red + } +} diff --git a/src/measurement/attribute/endurance.rs b/src/measurement/attribute/endurance.rs new file mode 100644 index 0000000..4e83768 --- /dev/null +++ b/src/measurement/attribute/endurance.rs @@ -0,0 +1,71 @@ +use crate::measurement::{marker::Timestamp, status::Status, thresholds::Thresholds}; +use std::{cmp::Ordering, fmt, time::Duration}; + +#[derive(Clone, Debug)] +pub struct Endurance(Duration); + +impl From for Endurance { + fn from(duration: Duration) -> Self { + Endurance(duration) + } +} + +impl Into for Endurance { + fn into(self) -> Duration { + self.0 + } +} + +impl PartialOrd for Endurance { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.0.cmp(&other.0)) + } +} + +impl PartialEq for Endurance { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl fmt::Display for Endurance { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} s.", self.0.as_millis() as f32 / 1000.0) + } +} + +impl Endurance { + pub fn new(start_time: &Timestamp, end_time: &Timestamp) -> Self { + Self(end_time.duration_since(&start_time)) + } + + pub fn as_secs(&self) -> u64 { + self.0.as_secs() + } + + pub fn against(&self, thesholds: &Thresholds) -> Status { + let green = thesholds.green_threshold(); + let yellow = thesholds.yellow_threshold(); + + if *self >= green { + return Status::Green; + } + if *self >= yellow { + return Status::Yellow; + } + Status::Red + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn duration_since() { + let start_time: Timestamp = "2020-02-20T17:15:13.596834700+01:00".parse().unwrap(); + let end_time: Timestamp = "2020-02-20T17:15:14.606834700+01:00".parse().unwrap(); + + Endurance::new(&start_time, &end_time); + } +} diff --git a/src/measurement/attribute/mod.rs b/src/measurement/attribute/mod.rs new file mode 100644 index 0000000..232f91c --- /dev/null +++ b/src/measurement/attribute/mod.rs @@ -0,0 +1,9 @@ +mod consumption; +mod efficiency; +mod endurance; +mod speed; + +pub use consumption::{Consumption, NamedProcess}; +pub use efficiency::Efficiency; +pub use endurance::Endurance; +pub use speed::Speed; diff --git a/src/measurement/attribute/speed.rs b/src/measurement/attribute/speed.rs new file mode 100644 index 0000000..8319bf0 --- /dev/null +++ b/src/measurement/attribute/speed.rs @@ -0,0 +1,71 @@ +use crate::measurement::{marker::Timestamp, status::Status, thresholds::Thresholds}; +use std::{cmp::Ordering, fmt, time::Duration}; + +#[derive(Clone, Debug)] +pub struct Speed(Duration); + +impl From for Speed { + fn from(duration: Duration) -> Self { + Speed(duration) + } +} + +impl Into for Speed { + fn into(self) -> Duration { + self.0 + } +} + +impl PartialOrd for Speed { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.0.cmp(&other.0)) + } +} + +impl PartialEq for Speed { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl fmt::Display for Speed { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} s.", self.0.as_millis() as f32 / 1000.0) + } +} + +impl Speed { + pub fn new(start: &Timestamp, end: &Timestamp) -> Self { + Self(end.duration_since(start)) + } + + pub fn as_secs(&self) -> u64 { + self.0.as_secs() + } + + pub fn against(&self, thresholds: &Thresholds) -> Status { + let green = thresholds.green_threshold(); + let yellow = thresholds.yellow_threshold(); + + if *self <= green { + return Status::Green; + } + if *self <= yellow { + return Status::Yellow; + } + Status::Red + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + pub fn duration_since() { + let start_time: Timestamp = "2020-02-20T17:15:13.596834700+01:00".parse().unwrap(); + let end_time: Timestamp = "2020-02-20T17:15:14.606834700+01:00".parse().unwrap(); + + Speed::new(&start_time, &end_time); + } +} diff --git a/src/measurement/benchmark/consumption_benchmark.rs b/src/measurement/benchmark/consumption_benchmark.rs new file mode 100644 index 0000000..4eefea3 --- /dev/null +++ b/src/measurement/benchmark/consumption_benchmark.rs @@ -0,0 +1,161 @@ +use crate::measurement::{ + attribute::{Consumption, NamedProcess}, + marker::ResourcesUsage, + thresholds::Thresholds, +}; +use std::collections::HashMap; +use sysinfo::AsU32; +use sysinfo::{ProcessExt, SystemExt}; +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ConsumptionBenchmarkError { + #[error("couldn't find process {0}")] + NoProcessWitId(NamedProcess), +} + +#[derive(Clone)] +pub struct ConsumptionBenchmarkDef { + name: String, + thresholds: Option>, + pids: Vec, +} + +impl ConsumptionBenchmarkDef { + pub fn new(name: String) -> Self { + ConsumptionBenchmarkDef { + name, + pids: Vec::new(), + thresholds: None, + } + } + + pub fn name(&self) -> String { + self.name.clone() + } + + pub fn bare_metal_stake_pool_consumption_target(&mut self) -> &mut Self { + self.thresholds = Some(Thresholds::::new_consumption( + ResourcesUsage::new(10, 160_000, 20_000_000), + )); + self + } + + pub fn target(&mut self, target: ResourcesUsage) -> &mut Self { + self.thresholds = Some(Thresholds::::new_consumption(target)); + self + } + + pub fn no_target(&mut self) -> &mut Self { + self.thresholds = None; + self + } + + pub fn for_process>(&mut self, name: S, pid: usize) -> &mut Self { + self.pids.push(NamedProcess::new(name.into(), pid)); + self + } + + pub fn for_processes(&mut self, processes: Vec) -> &mut Self { + self.pids.extend(processes); + self + } + + pub fn thresholds(&self) -> Option<&Thresholds> { + self.thresholds.as_ref() + } + + pub fn start(&self) -> ConsumptionBenchmarkRun { + ConsumptionBenchmarkRun { + definition: self.clone(), + markers: self.pids.iter().map(|x| (x.clone(), vec![])).collect(), + } + } +} + +pub struct ConsumptionBenchmarkRun { + definition: ConsumptionBenchmarkDef, + markers: HashMap>, +} + +impl ConsumptionBenchmarkRun { + pub fn snapshot(&mut self) -> Result<(), ConsumptionBenchmarkError> { + let mut system = sysinfo::System::new(); + system.refresh_processes(); + + for (named_process, resources) in self.markers.iter_mut() { + let (_, process) = system + .get_processes() + .iter() + .find(|(pid, _)| (named_process.id() as u32) == pid.as_u32()) + .ok_or_else(|| ConsumptionBenchmarkError::NoProcessWitId(named_process.clone()))?; + + let marker = ResourcesUsage::new( + process.cpu_usage() as u32, + process.memory() as u32, + process.virtual_memory() as u32, + ); + + resources.push(marker); + } + Ok(()) + } + + pub fn exception(self, info: String) -> ConsumptionBenchmarkFinish { + println!("Test finished prematurely, due to: {}", info); + self.stop() + } + + pub fn stop(self) -> ConsumptionBenchmarkFinish { + match self.definition.thresholds() { + Some(_thresholds) => ConsumptionBenchmarkFinish { + definition: self.definition.clone(), + consumptions: self + .markers + .iter() + .map(|(name, data)| (name.clone(), Consumption::new(data.clone()))) + .collect(), + }, + None => ConsumptionBenchmarkFinish { + definition: self.definition.clone(), + consumptions: self + .markers + .iter() + .map(|(name, data)| (name.clone(), Consumption::new(data.clone()))) + .collect(), + }, + } + } +} + +pub struct ConsumptionBenchmarkFinish { + definition: ConsumptionBenchmarkDef, + consumptions: HashMap, +} + +impl ConsumptionBenchmarkFinish { + pub fn print(&self) { + for (named_process, consumption) in self.consumptions.iter() { + self.print_single(named_process, consumption) + } + } + + fn print_single(&self, named_process: &NamedProcess, consumption: &Consumption) { + match self.definition.thresholds() { + Some(thresholds) => println!( + "Measurement: {}_{}. Result: {}. Actual: {} Thresholds: {}", + self.definition.name(), + named_process.name(), + consumption.against(&thresholds), + consumption, + thresholds + ), + None => println!( + "Measurement: {}_{}. Value: {}", + self.definition.name(), + named_process.name(), + consumption + ), + } + } +} diff --git a/src/measurement/benchmark/efficiency_benchmark.rs b/src/measurement/benchmark/efficiency_benchmark.rs new file mode 100644 index 0000000..f55a612 --- /dev/null +++ b/src/measurement/benchmark/efficiency_benchmark.rs @@ -0,0 +1,124 @@ +use crate::measurement::{attribute::Efficiency, marker::Counter, thresholds::Thresholds}; + +use std::fmt; +#[derive(Clone)] +pub struct EfficiencyBenchmarkDef { + name: String, + thresholds: Option>, + max: Counter, +} + +impl EfficiencyBenchmarkDef { + pub fn new(name: String) -> Self { + EfficiencyBenchmarkDef { + name, + thresholds: None, + max: 0u32.into(), + } + } + + pub fn name(&self) -> String { + self.name.clone() + } + + pub fn target(&mut self, target: u32) -> &mut Self { + self.max = target.into(); + self.thresholds = Some(Thresholds::::new_efficiency(target)); + self + } + + pub fn no_target(&mut self) -> &mut Self { + self.thresholds = None; + self + } + + pub fn max(&self) -> Counter { + self.max + } + + pub fn thresholds(&self) -> Option<&Thresholds> { + self.thresholds.as_ref() + } + + pub fn start(&self) -> EfficiencyBenchmarkRun { + EfficiencyBenchmarkRun { + definition: self.clone(), + start_marker: Counter::new(), + current_marker: Counter::new(), + } + } +} + +pub struct EfficiencyBenchmarkRun { + definition: EfficiencyBenchmarkDef, + start_marker: Counter, + current_marker: Counter, +} + +impl EfficiencyBenchmarkRun { + pub fn increment(&mut self) -> &mut Self { + self.increment_by(1) + } + + pub fn increment_by(&mut self, increment: u32) -> &mut Self { + let counter: u32 = self.current_marker.into(); + self.current_marker = (counter + increment).into(); + self + } + + pub fn exception(&self, info: String) -> EfficiencyBenchmarkFinish { + println!("Test finished prematurely, due to: {}", info); + self.stop() + } + + pub fn stop(&self) -> EfficiencyBenchmarkFinish { + match self.definition.thresholds() { + Some(_thresholds) => EfficiencyBenchmarkFinish { + definition: self.definition.clone(), + efficiency: Efficiency::new( + (self.current_marker - self.start_marker).into(), + self.definition.max().into(), + ), + }, + None => EfficiencyBenchmarkFinish { + definition: self.definition.clone(), + efficiency: Efficiency::new( + (self.current_marker - self.start_marker).into(), + self.current_marker.into(), + ), + }, + } + } +} + +pub struct EfficiencyBenchmarkFinish { + definition: EfficiencyBenchmarkDef, + efficiency: Efficiency, +} + +impl EfficiencyBenchmarkFinish { + pub fn print(&self) { + println!("{}", &self); + } +} + +impl fmt::Display for EfficiencyBenchmarkFinish { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.definition.thresholds() { + Some(thresholds) => write!( + f, + "Measurement: {}. Result: {}. Actual: {} Thresholds: {}", + self.definition.name(), + self.efficiency.against(&thresholds), + self.efficiency, + thresholds, + ), + None => write!( + f, + "Measurement: {}. Value: {}", + self.definition.name(), + self.efficiency + ), + } + } +} diff --git a/src/measurement/benchmark/endurance_benchmark.rs b/src/measurement/benchmark/endurance_benchmark.rs new file mode 100644 index 0000000..9e33b94 --- /dev/null +++ b/src/measurement/benchmark/endurance_benchmark.rs @@ -0,0 +1,112 @@ +use crate::measurement::{attribute::Endurance, marker::Timestamp, thresholds::Thresholds}; + +use std::{ + fmt, + time::{Duration, SystemTime}, +}; +#[derive(Clone)] +pub struct EnduranceBenchmarkDef { + name: String, + thresholds: Option>, +} + +impl EnduranceBenchmarkDef { + pub fn new(name: String) -> Self { + EnduranceBenchmarkDef { + name, + thresholds: None, + } + } + + pub fn name(&self) -> String { + self.name.clone() + } + + pub fn target(&mut self, duration: Duration) -> &mut Self { + self.thresholds = Some(Thresholds::::new_endurance(duration)); + self + } + + pub fn no_target(&mut self) -> &mut Self { + self.thresholds = None; + self + } + + pub fn thresholds(&self) -> Option<&Thresholds> { + self.thresholds.as_ref() + } + + pub fn start(&self) -> EnduranceBenchmarkRun { + EnduranceBenchmarkRun { + definition: self.clone(), + start_marker: Timestamp::from(SystemTime::now()), + } + } +} + +pub struct EnduranceBenchmarkRun { + definition: EnduranceBenchmarkDef, + start_marker: Timestamp, +} + +impl EnduranceBenchmarkRun { + pub fn stop(&self) -> EnduranceBenchmarkFinish { + let stop_marker = Timestamp::from(SystemTime::now()); + EnduranceBenchmarkFinish { + definition: self.definition.clone(), + endurance: Endurance::new(&self.start_marker, &stop_marker), + } + } + + pub fn exception(&self, info: String) -> EnduranceBenchmarkFinish { + println!("Test finished prematurely, due to: {}", info); + self.stop() + } + + pub fn max_endurance_reached(&self) -> bool { + if let Some(thresholds) = &self.definition.thresholds { + self.start_marker.elapsed() > thresholds.max().into() + } else { + false + } + } +} + +#[derive(Clone)] +pub struct EnduranceBenchmarkFinish { + definition: EnduranceBenchmarkDef, + endurance: Endurance, +} + +impl EnduranceBenchmarkFinish { + pub fn print(&self) { + println!("{}", &self); + } + + pub fn print_with_thresholds(&self, thresholds: Thresholds) { + let mut benchmark_finish = self.clone(); + benchmark_finish.definition.thresholds = Some(thresholds); + benchmark_finish.print() + } +} + +impl fmt::Display for EnduranceBenchmarkFinish { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.definition.thresholds() { + Some(thresholds) => write!( + f, + "Measurement: {}. Result: {}. Actual: {} Thresholds: {}", + self.definition.name(), + self.endurance.against(&thresholds), + self.endurance, + thresholds, + ), + None => write!( + f, + "Measurement: {}. Value: {}", + self.definition.name(), + self.endurance + ), + } + } +} diff --git a/src/measurement/benchmark/mod.rs b/src/measurement/benchmark/mod.rs new file mode 100644 index 0000000..bb7600a --- /dev/null +++ b/src/measurement/benchmark/mod.rs @@ -0,0 +1,32 @@ +mod consumption_benchmark; +mod efficiency_benchmark; +mod endurance_benchmark; +mod speed_benchmark; + +pub use efficiency_benchmark::{ + EfficiencyBenchmarkDef, EfficiencyBenchmarkFinish, EfficiencyBenchmarkRun, +}; +pub use endurance_benchmark::{ + EnduranceBenchmarkDef, EnduranceBenchmarkFinish, EnduranceBenchmarkRun, +}; + +pub use consumption_benchmark::{ + ConsumptionBenchmarkDef, ConsumptionBenchmarkError, ConsumptionBenchmarkFinish, + ConsumptionBenchmarkRun, +}; + +pub use speed_benchmark::{SpeedBenchmarkDef, SpeedBenchmarkFinish, SpeedBenchmarkRun}; + +pub fn benchmark_efficiency>(name: S) -> EfficiencyBenchmarkDef { + EfficiencyBenchmarkDef::new(name.into()) +} +pub fn benchmark_endurance>(name: S) -> EnduranceBenchmarkDef { + EnduranceBenchmarkDef::new(name.into()) +} +pub fn benchmark_speed>(name: S) -> SpeedBenchmarkDef { + SpeedBenchmarkDef::new(name.into()) +} + +pub fn benchmark_consumption>(name: S) -> ConsumptionBenchmarkDef { + ConsumptionBenchmarkDef::new(name.into()) +} diff --git a/src/measurement/benchmark/speed_benchmark.rs b/src/measurement/benchmark/speed_benchmark.rs new file mode 100644 index 0000000..83245fd --- /dev/null +++ b/src/measurement/benchmark/speed_benchmark.rs @@ -0,0 +1,113 @@ +use crate::measurement::{attribute::Speed, marker::Timestamp, thresholds::Thresholds}; + +use std::{ + fmt, + time::{Duration, SystemTime}, +}; + +#[derive(Clone)] +pub struct SpeedBenchmarkDef { + name: String, + thresholds: Option>, +} + +impl SpeedBenchmarkDef { + pub fn new(name: String) -> Self { + SpeedBenchmarkDef { + name, + thresholds: None, + } + } + + pub fn name(&self) -> String { + self.name.clone() + } + + pub fn with_thresholds(&mut self, thresholds: Thresholds) -> &mut Self { + self.thresholds = Some(thresholds); + self + } + + pub fn target(&mut self, duration: Duration) -> &mut Self { + self.with_thresholds(Thresholds::::new_speed(duration)) + } + + pub fn thresholds(&self) -> Option<&Thresholds> { + self.thresholds.as_ref() + } + + pub fn no_target(&mut self) -> &mut Self { + self.thresholds = None; + self + } + + pub fn start(&self) -> SpeedBenchmarkRun { + SpeedBenchmarkRun { + definition: self.clone(), + start_marker: Timestamp::from(SystemTime::now()), + } + } +} + +pub struct SpeedBenchmarkRun { + definition: SpeedBenchmarkDef, + start_marker: Timestamp, +} + +impl SpeedBenchmarkRun { + pub fn stop(&self) -> SpeedBenchmarkFinish { + let stop_marker = Timestamp::from(SystemTime::now()); + SpeedBenchmarkFinish { + definition: self.definition.clone(), + speed: Speed::new(&self.start_marker, &stop_marker), + } + } + + pub fn timeout_exceeded(&self) -> bool { + if let Some(thresholds) = &self.definition.thresholds { + self.start_marker.elapsed() > thresholds.max().into() + } else { + false + } + } + + pub fn definition(&self) -> &SpeedBenchmarkDef { + &self.definition + } +} + +pub struct SpeedBenchmarkFinish { + definition: SpeedBenchmarkDef, + speed: Speed, +} + +impl SpeedBenchmarkFinish { + pub fn print(&self) { + println!("{}", &self); + } + + pub fn new(definition: SpeedBenchmarkDef, speed: Speed) -> Self { + Self { definition, speed } + } +} + +impl fmt::Display for SpeedBenchmarkFinish { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.definition.thresholds() { + Some(thresholds) => write!( + f, + "Measurement: {}. Result: {}. Actual: {} Thresholds: {}", + self.definition.name(), + self.speed.against(&thresholds), + self.speed, + thresholds, + ), + None => write!( + f, + "Measurement: {}. Value: {}", + self.definition.name(), + self.speed + ), + } + } +} diff --git a/src/measurement/marker/counter.rs b/src/measurement/marker/counter.rs new file mode 100644 index 0000000..417a6a7 --- /dev/null +++ b/src/measurement/marker/counter.rs @@ -0,0 +1,46 @@ +use std::ops::{Add, Div, Sub}; + +#[derive(Default, Copy, Clone)] +pub struct Counter(u32); + +impl Counter { + pub fn new() -> Self { + Counter::from(0u32) + } +} + +impl From for Counter { + fn from(from: u32) -> Self { + Counter(from) + } +} + +impl Into for Counter { + fn into(self) -> u32 { + self.0 + } +} + +impl Sub for Counter { + type Output = Counter; + + fn sub(self, other: Counter) -> Counter { + Counter(self.0 - other.0) + } +} + +impl Add for Counter { + type Output = Counter; + + fn add(self, other: Counter) -> Counter { + Counter(self.0 + other.0) + } +} + +impl Div for Counter { + type Output = Counter; + + fn div(self, other: Counter) -> Counter { + Counter(self.0 / other.0) + } +} diff --git a/src/measurement/marker/mod.rs b/src/measurement/marker/mod.rs new file mode 100644 index 0000000..06df777 --- /dev/null +++ b/src/measurement/marker/mod.rs @@ -0,0 +1,7 @@ +mod counter; +mod resources_usage; +mod timestamp; + +pub use counter::Counter; +pub use resources_usage::ResourcesUsage; +pub use timestamp::Timestamp; diff --git a/src/measurement/marker/resources_usage.rs b/src/measurement/marker/resources_usage.rs new file mode 100644 index 0000000..64c780c --- /dev/null +++ b/src/measurement/marker/resources_usage.rs @@ -0,0 +1,82 @@ +use bytesize::ByteSize; +use std::{cmp::Ordering, fmt}; + +#[derive(Clone, Debug)] +pub struct ResourcesUsage { + cpu_usage: u32, + memory_usage: u32, + virtual_memory_usage: u32, +} + +impl Eq for ResourcesUsage {} + +impl PartialEq for ResourcesUsage { + fn eq(&self, other: &Self) -> bool { + self.cpu_usage == other.cpu_usage + && self.memory_usage == other.memory_usage + && self.virtual_memory_usage == other.virtual_memory_usage + } +} + +impl PartialOrd for ResourcesUsage { + fn partial_cmp(&self, other: &Self) -> Option { + let cpu_cmp = self.cpu_usage().partial_cmp(&other.cpu_usage()).unwrap(); + let memory_cmp = self + .memory_usage() + .partial_cmp(&other.memory_usage()) + .unwrap(); + let virtual_memory_cmp = self + .virtual_memory_usage() + .partial_cmp(&other.virtual_memory_usage()) + .unwrap(); + + Some(cpu_cmp.then(memory_cmp).then(virtual_memory_cmp)) + } +} + +impl Ord for ResourcesUsage { + fn cmp(&self, other: &Self) -> Ordering { + let cpu_cmp = self.cpu_usage().cmp(&other.cpu_usage()); + let memory_cmp = self.memory_usage().cmp(&other.memory_usage()); + let virtual_memory_cmp = self + .virtual_memory_usage() + .cmp(&other.virtual_memory_usage()); + + cpu_cmp.then(memory_cmp).then(virtual_memory_cmp) + } +} + +impl fmt::Display for ResourcesUsage { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let memory_usage = ByteSize::kib(self.memory_usage.into()).to_string(); + let virtual_memory_usage = ByteSize::kib(self.virtual_memory_usage.into()).to_string(); + + write!( + f, + "(CPU: {:.1} %. Mem: {}. V_Mem: {})", + self.cpu_usage, memory_usage, virtual_memory_usage + ) + } +} + +impl ResourcesUsage { + pub fn new(cpu_usage: u32, memory_usage: u32, virtual_memory_usage: u32) -> Self { + Self { + cpu_usage, + memory_usage, + virtual_memory_usage, + } + } + + pub fn cpu_usage(&self) -> u32 { + self.cpu_usage + } + + pub fn memory_usage(&self) -> u32 { + self.memory_usage + } + + pub fn virtual_memory_usage(&self) -> u32 { + self.virtual_memory_usage + } +} diff --git a/src/measurement/marker/timestamp.rs b/src/measurement/marker/timestamp.rs new file mode 100644 index 0000000..88adad8 --- /dev/null +++ b/src/measurement/marker/timestamp.rs @@ -0,0 +1,61 @@ +use chrono::DateTime; +use std::{ + fmt, + str::FromStr, + time::{Duration, SystemTime}, +}; +#[derive(Clone, Copy)] +pub struct Timestamp(SystemTime); + +impl Default for Timestamp { + fn default() -> Self { + Self::new() + } +} + +impl Timestamp { + pub fn new() -> Self { + Timestamp::from(SystemTime::now()) + } + + pub fn duration_since(&self, earlier: &Timestamp) -> Duration { + let system_time: SystemTime = earlier.clone().into(); + self.0.duration_since(system_time).unwrap() + } + + pub fn elapsed(&self) -> Duration { + self.0.elapsed().unwrap() + } +} + +impl From for Timestamp { + fn from(from: SystemTime) -> Self { + Timestamp(from) + } +} + +impl Into for Timestamp { + fn into(self) -> SystemTime { + self.0 + } +} +impl FromStr for Timestamp { + type Err = chrono::ParseError; + fn from_str(s: &str) -> Result { + let dt: DateTime = DateTime::parse_from_rfc3339(s)?; + let seconds = dt.timestamp() as u64; + let nsecs = dt.timestamp_subsec_nanos(); + + let elapsed = Duration::new(seconds, nsecs); + + let time = SystemTime::UNIX_EPOCH.checked_add(elapsed).unwrap(); + + Ok(time.into()) + } +} + +impl fmt::Debug for Timestamp { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", self.0) + } +} diff --git a/src/measurement/mod.rs b/src/measurement/mod.rs new file mode 100644 index 0000000..0a1917e --- /dev/null +++ b/src/measurement/mod.rs @@ -0,0 +1,17 @@ +mod attribute; +mod benchmark; +mod marker; +mod status; +mod thresholds; + +pub use attribute::{Efficiency, Endurance, NamedProcess, Speed}; +pub use benchmark::{ + benchmark_consumption, benchmark_efficiency, benchmark_endurance, benchmark_speed, + ConsumptionBenchmarkError, ConsumptionBenchmarkRun, EfficiencyBenchmarkDef, + EfficiencyBenchmarkFinish, EfficiencyBenchmarkRun, EnduranceBenchmarkDef, + EnduranceBenchmarkFinish, EnduranceBenchmarkRun, SpeedBenchmarkDef, SpeedBenchmarkFinish, + SpeedBenchmarkRun, +}; +pub use marker::{Counter, ResourcesUsage, Timestamp}; +pub use status::Status; +pub use thresholds::Thresholds; diff --git a/src/measurement/status.rs b/src/measurement/status.rs new file mode 100644 index 0000000..da54b18 --- /dev/null +++ b/src/measurement/status.rs @@ -0,0 +1,14 @@ +use std::fmt; + +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum Status { + Green, + Yellow, + Red, +} + +impl fmt::Display for Status { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}", self) + } +} diff --git a/src/measurement/thresholds.rs b/src/measurement/thresholds.rs new file mode 100644 index 0000000..77f076d --- /dev/null +++ b/src/measurement/thresholds.rs @@ -0,0 +1,136 @@ +use super::{ + attribute::{Consumption, Efficiency, Endurance, Speed}, + marker::ResourcesUsage, + Status, +}; + +use std::{cmp::PartialOrd, fmt, time::Duration}; + +#[derive(Clone, Debug)] +pub struct Thresholds { + inner_thresholds: Vec<(Status, T)>, + max: T, +} + +impl Thresholds { + pub fn new(green: T, yellow: T, red: T, max: T) -> Self { + Self { + inner_thresholds: vec![ + (Status::Green, green), + (Status::Yellow, yellow), + (Status::Red, red), + ], + max, + } + } + + pub fn thresholds(&self) -> &Vec<(Status, T)> { + &self.inner_thresholds + } + + pub fn max(&self) -> T { + self.max.clone() + } + + pub fn green_threshold(&self) -> T { + self.thresholds() + .iter() + .find(|(x, _)| *x == Status::Green) + .expect("cannot find green threshold") + .1 + .clone() + } + + pub fn yellow_threshold(&self) -> T { + self.thresholds() + .iter() + .find(|(x, _)| *x == Status::Yellow) + .expect("cannot find green threshold") + .1 + .clone() + } + + pub fn red_threshold(&self) -> T { + self.thresholds() + .iter() + .find(|(x, _)| *x == Status::Red) + .expect("cannot find red threshold") + .1 + .clone() + } +} + +impl fmt::Display for Thresholds { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!( + f, + "Green: {} Yellow: {} Red: {} Max: {}", + self.green_threshold(), + self.yellow_threshold(), + self.red_threshold(), + self.max() + ) + } +} + +impl Thresholds { + pub fn new_endurance(duration: Duration) -> Thresholds { + let green = Duration::from_secs(duration.as_secs() / 2); + let yellow = Duration::from_secs(duration.as_secs() / 3); + let red = Duration::from_secs(duration.as_secs() / 4); + Thresholds::::new( + green.into(), + yellow.into(), + red.into(), + Duration::from_secs(duration.as_secs()).into(), + ) + } +} + +impl Thresholds { + pub fn new_speed(duration: Duration) -> Thresholds { + let green = Duration::from_secs(duration.as_secs() / 4); + let yellow = Duration::from_secs(duration.as_secs() / 3); + let red = Duration::from_secs(duration.as_secs() / 2); + Thresholds::::new( + green.into(), + yellow.into(), + red.into(), + Duration::from_secs(duration.as_secs()).into(), + ) + } +} + +impl Thresholds { + pub fn new_efficiency(target: u32) -> Thresholds { + let green = Efficiency::new(target / 2, target); + let yellow = Efficiency::new(target / 3, target); + let red = Efficiency::new(target / 4, target); + let max = Efficiency::new(target, target); + Thresholds::::new(green, yellow, red, max) + } +} + +impl Thresholds { + pub fn new_consumption(resources_usage: ResourcesUsage) -> Thresholds { + let target_cpu = resources_usage.cpu_usage(); + let target_memory = resources_usage.memory_usage(); + let target_virtual_memory = resources_usage.virtual_memory_usage(); + + let green_marker = + ResourcesUsage::new(target_cpu / 4, target_memory / 4, target_virtual_memory / 4); + let green = Consumption::new(vec![green_marker]); + + let yellow_marker = + ResourcesUsage::new(target_cpu / 3, target_memory / 3, target_virtual_memory / 3); + let yellow = Consumption::new(vec![yellow_marker]); + + let red_marker = + ResourcesUsage::new(target_cpu / 2, target_memory / 2, target_virtual_memory / 2); + let red = Consumption::new(vec![red_marker]); + + let max_marker = ResourcesUsage::new(target_cpu, target_memory, target_virtual_memory); + let max = Consumption::new(vec![max_marker]); + Thresholds::::new(green, yellow, red, max) + } +} diff --git a/src/openssl/mod.rs b/src/openssl/mod.rs new file mode 100644 index 0000000..9df1385 --- /dev/null +++ b/src/openssl/mod.rs @@ -0,0 +1,128 @@ +use assert_fs::fixture::ChildPath; +use bawawa::{Command, Error, Process, Program, StandardError, StandardOutput}; +use futures::stream::Stream; +use tokio_codec::LinesCodec; + +use std::path::PathBuf; + +pub struct Openssl { + program: Program, +} + +impl Openssl { + pub fn new() -> Result { + Ok(Openssl { + program: Program::new("openssl".to_owned())?, + }) + } + + pub fn version(&self) -> Result { + let mut openssl = Command::new(self.program.clone()); + openssl.argument("version"); + self.echo_stdout(openssl) + } + + fn echo_stdout(&self, cmd: Command) -> Result { + let captured = Process::spawn(cmd.clone())? + .capture_stdout(LinesCodec::new()) + .capture_stderr(LinesCodec::new()) + .wait(); + println!("{}", cmd); + + let lines: Vec = captured + .map(|r| r.unwrap_or_else(|_| "".to_owned())) + .collect(); + Ok(lines.join("\n")) + } + + pub fn genrsa(&self, length: u32, out_file: &ChildPath) -> Result { + let mut openssl = Command::new(self.program.clone()); + openssl.arguments(&[ + "genrsa", + "-out", + &path_to_str(out_file), + &length.to_string(), + ]); + self.echo_stdout(openssl) + } + + pub fn pkcs8(&self, in_file: &ChildPath, out_file: &ChildPath) -> Result { + let mut openssl = Command::new(self.program.clone()); + openssl.arguments(&[ + "pkcs8", + "-topk8", + "-inform", + "PEM", + "-outform", + "PEM", + "-in", + &path_to_str(in_file), + "-out", + &path_to_str(out_file), + "-nocrypt", + ]); + self.echo_stdout(openssl) + } + + pub fn req(&self, prv_key: &ChildPath, out_cert: &ChildPath) -> Result { + let mut openssl = Command::new(self.program.clone()); + openssl.arguments(&[ + "req", + "-new", + "-nodes", + "-key", + &path_to_str(prv_key), + "-out", + &path_to_str(out_cert), + "-batch", + ]); + self.echo_stdout(openssl) + } + + pub fn x509( + &self, + prv_key: &ChildPath, + in_cert: &ChildPath, + out_cert: &ChildPath, + ) -> Result { + let mut openssl = Command::new(self.program.clone()); + openssl.arguments(&[ + "x509", + "-req", + "-days", + &3650.to_string(), + "-in", + &path_to_str(in_cert), + "-signkey", + &path_to_str(prv_key), + "-out", + &path_to_str(out_cert), + ]); + self.echo_stdout(openssl) + } + + pub fn convert_to_der( + &self, + in_cert: &ChildPath, + out_der: &ChildPath, + ) -> Result { + let mut openssl = Command::new(self.program.clone()); + openssl.arguments(&[ + "x509", + "-inform", + "pem", + "-in", + &path_to_str(in_cert), + "-outform", + "der", + "-out", + &path_to_str(out_der), + ]); + self.echo_stdout(openssl) + } +} + +fn path_to_str(path: &ChildPath) -> String { + let path_buf: PathBuf = path.path().into(); + path_buf.as_os_str().to_owned().into_string().unwrap() +} diff --git a/src/process/mod.rs b/src/process/mod.rs new file mode 100644 index 0000000..dad95fd --- /dev/null +++ b/src/process/mod.rs @@ -0,0 +1,174 @@ +#![allow(dead_code)] + +extern crate serde_yaml; + +pub mod output_extensions; +mod wait; + +pub use wait::{Wait, WaitBuilder}; + +use self::output_extensions::ProcessOutput; +use std::{ + process::{Command, Output, Stdio}, + thread, time, +}; +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum ProcessError { + #[error("could not start process '{message}'")] + ProcessExited { message: String }, +} + +/// Runs command, wait for output and returns it output +/// +/// # Arguments +/// +/// * `command` - Command which will be invoked +/// +pub fn run_process_and_get_output(mut command: Command) -> Output { + // FIXME: switch to something like assert_cmd to wait with a timeout + println!("Running command: {:?}", &command); + let content = command + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .expect("failed to execute process"); + + if content.as_lossy_string() != "" { + println!("Output: {}", content.as_lossy_string()); + } + if content.err_as_lossy_string() != "" { + println!("Error: {}", content.err_as_lossy_string()); + } + println!(); + content +} + +/// Runs command for n times with m second interval. +/// +/// # Panics +/// +/// Panics if max_attempts is exceeded and none of attempts return successful exit code. +/// +/// # Arguments +/// +/// * `command` - Command which will be invoked +/// * `timeout` - Timeout after unsuccesful attempt (in seconds) +/// * `max_attempts` - Maximum number of attempts +/// * `command_description` - User description of command +/// * `error_description` - User description of error +/// +/// # Example +/// +/// use process_utils::run_process_until_exited_successfully; +/// +/// process_utils::run_process_until_exited_successfully( +/// jcli_wrapper::run_rest_stats_command_default(), +/// 2, +/// 5, +/// "get stats from jormungandr node", +/// "jormungandr node is not up" +/// ); +/// +pub fn run_process_until_exited_successfully( + mut command: Command, + timeout: u64, + max_attempts: i32, + command_description: &str, + error_description: &str, +) { + let mut attempts = max_attempts; + + loop { + let status = command.status().unwrap_or_else(|_| { + panic!( + "failed to get exit status of command: {}", + &command_description + ) + }); + + if status.success() { + break; + } + + if attempts <= 0 { + break; + } + + println!( + "non-zero status with message(). {}. waiting {} s and trying again ({} of {})", + command_description, + &timeout, + max_attempts - attempts + 1, + max_attempts + ); + + attempts -= 1; + self::sleep(timeout); + } + + if attempts <= 0 { + panic!( + "{} (tried to connect {} times with {} s interval)", + &error_description, &max_attempts, &timeout + ); + } + println!("Success: {}", &command_description); +} + +pub fn run_process_until_response_matches bool>( + mut command: Command, + is_output_ok: F, + sleep_between_attempt: u64, + max_attempts: u64, + command_description: &str, + error_description: &str, +) -> Result<(), ProcessError> { + let sleep_between_attempt_duration = time::Duration::from_millis(&sleep_between_attempt * 1000); + let mut attempts = 1; + + println!("Running command {:?} in loop", command); + + loop { + let output = command + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .unwrap_or_else(|_| panic!("cannot get output from command {:?}", &command)); + + println!("Standard Output: {}", output.as_lossy_string()); + println!("Standard Error: {}", output.err_as_lossy_string()); + + if output.status.success() && is_output_ok(output) { + println!("Success: {}", &command_description); + return Ok(()); + } + + if attempts >= max_attempts { + return Err(ProcessError::ProcessExited { + message: format!( + "{} (tried to connect {} times with {} s interval)", + &error_description, &max_attempts, &sleep_between_attempt + ), + }); + } + + println!( + "non-zero status with message(). waiting {} s and trying again ({} of {})", + &sleep_between_attempt, &attempts, &max_attempts + ); + + attempts += 1; + thread::sleep(sleep_between_attempt_duration); + } +} + +pub fn sleep(seconds: u64) { + let duration = time::Duration::from_secs(seconds); + thread::sleep(duration); +} diff --git a/src/process/output_extensions.rs b/src/process/output_extensions.rs new file mode 100644 index 0000000..8ad0bb8 --- /dev/null +++ b/src/process/output_extensions.rs @@ -0,0 +1,58 @@ +use serde_yaml::Error as SerdeError; +use std::{collections::BTreeMap, process::Output}; + +pub trait ProcessOutput { + fn as_lossy_string(&self) -> String; + fn as_single_line(&self) -> String; + fn as_multi_node_yaml(&self) -> Vec>; + fn as_single_node_yaml(&self) -> BTreeMap; + fn try_as_single_node_yaml(&self) -> Result, SerdeError>; + fn err_as_lossy_string(&self) -> String; + fn err_as_single_line(&self) -> String; +} + +impl ProcessOutput for Output { + fn as_lossy_string(&self) -> String { + String::from_utf8_lossy(&self.stdout).into_owned() + } + + fn as_single_line(&self) -> String { + let mut content = self.as_lossy_string(); + if content.ends_with('\n') { + let len = content.len(); + content.truncate(len - 1); + } + content.trim().to_string() + } + + fn err_as_lossy_string(&self) -> String { + String::from_utf8_lossy(&self.stderr).into_owned() + } + + fn err_as_single_line(&self) -> String { + let mut content = self.err_as_lossy_string(); + if content.ends_with('\n') { + let len = content.len(); + content.truncate(len - 1); + } + content + } + + fn as_multi_node_yaml(&self) -> Vec> { + let content = self.as_lossy_string(); + let deserialized_map: Vec> = + serde_yaml::from_str(&content).unwrap(); + deserialized_map + } + + fn as_single_node_yaml(&self) -> BTreeMap { + let content = self.as_lossy_string(); + let deserialized_map: BTreeMap = serde_yaml::from_str(&content).unwrap(); + deserialized_map + } + + fn try_as_single_node_yaml(&self) -> Result, SerdeError> { + let content = self.as_lossy_string(); + serde_yaml::from_str(&content) + } +} diff --git a/src/process/wait.rs b/src/process/wait.rs new file mode 100644 index 0000000..54c281d --- /dev/null +++ b/src/process/wait.rs @@ -0,0 +1,69 @@ +use std::time::Duration; + +#[derive(Clone, Debug)] +pub struct Wait { + sleep: Duration, + attempts: u64, +} + +impl Wait { + pub fn new(sleep: Duration, attempts: u64) -> Self { + Wait { sleep, attempts } + } + + pub fn sleep_duration(&self) -> Duration { + self.sleep + } + + pub fn attempts(&self) -> u64 { + self.attempts + } +} + +impl Default for Wait { + fn default() -> Self { + Wait::new(Duration::from_secs(1), 5) + } +} + +impl From for Wait { + fn from(duration: Duration) -> Wait { + let attempts = duration.as_secs(); + let sleep = 1; + Wait::new(Duration::from_secs(sleep), attempts) + } +} + +pub struct WaitBuilder { + sleep: Duration, + attempts: u64, +} + +impl Default for WaitBuilder { + fn default() -> Self { + Self::new() + } +} + +impl WaitBuilder { + pub fn new() -> Self { + WaitBuilder { + sleep: Duration::from_secs(1), + attempts: 5, + } + } + + pub fn tries(&mut self, attempts: u64) -> &mut Self { + self.attempts = attempts; + self + } + + pub fn sleep_between_tries(&mut self, sleep: u64) -> &mut Self { + self.sleep = Duration::from_secs(sleep); + self + } + + pub fn build(&self) -> Wait { + Wait::new(self.sleep, self.attempts) + } +} diff --git a/src/web/mod.rs b/src/web/mod.rs new file mode 100644 index 0000000..dd8fc16 --- /dev/null +++ b/src/web/mod.rs @@ -0,0 +1,22 @@ +extern crate reqwest; +use std::fs::File; +use std::io; +use std::path::Path; +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum WebError { + #[error("could not download file")] + CannotDownloadFile(#[from] reqwest::Error), + #[error("could not save output to file")] + CannotCreateOutputFile, + #[error("could not send reqeuest")] + IOError(#[from] io::Error), +} + +pub fn download_file(link: String, output: &Path) -> Result<(), WebError> { + let mut resp = reqwest::blocking::get(&link).map_err(WebError::CannotDownloadFile)?; + let mut out = File::create(output.as_os_str()).map_err(|_| WebError::CannotCreateOutputFile)?; + io::copy(&mut resp, &mut out)?; + Ok(()) +}