diff --git a/0001-counter-fix-tests-in-release-mode-246.patch b/0001-counter-fix-tests-in-release-mode-246.patch new file mode 100644 index 0000000..a046021 --- /dev/null +++ b/0001-counter-fix-tests-in-release-mode-246.patch @@ -0,0 +1,50 @@ +From 356220985d3c0f87b545b3f9f8997833e1e9ada1 Mon Sep 17 00:00:00 2001 +From: Luca Bruno +Date: Thu, 6 Jun 2019 08:11:45 +0000 +Subject: [PATCH 1/2] counter: fix tests in release mode (#246) + +This fixes `should_panic` tests in release mode, as they rely on +debug assertions. +--- + src/counter.rs | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/counter.rs b/src/counter.rs +index 2099933..a2b9bdb 100644 +--- a/src/counter.rs ++++ b/src/counter.rs +@@ -511,6 +511,7 @@ mod tests { + assert_eq!(vec.with_label_values(&["v1", "v2"]).get(), 34); + } + ++ #[cfg(debug_assertions)] + #[test] + #[should_panic(expected = "assertion failed")] + fn test_counter_negative_inc() { +@@ -518,6 +519,7 @@ mod tests { + counter.inc_by(-42.0); + } + ++ #[cfg(debug_assertions)] + #[test] + #[should_panic(expected = "assertion failed")] + fn test_local_counter_negative_inc() { +@@ -526,6 +528,7 @@ mod tests { + local.inc_by(-42.0); + } + ++ #[cfg(debug_assertions)] + #[test] + #[should_panic(expected = "assertion failed")] + fn test_int_counter_negative_inc() { +@@ -533,6 +536,7 @@ mod tests { + counter.inc_by(-42); + } + ++ #[cfg(debug_assertions)] + #[test] + #[should_panic(expected = "assertion failed")] + fn test_int_local_counter_negative_inc() { +-- +2.22.0 + diff --git a/0001-update-example-hyper.diff b/0001-update-example-hyper.diff deleted file mode 100644 index 4003636..0000000 --- a/0001-update-example-hyper.diff +++ /dev/null @@ -1,62 +0,0 @@ -diff --git a/examples/example_hyper.rs b/examples/example_hyper.rs -index c9d02bc..a6eda1b 100644 ---- a/examples/example_hyper.rs -+++ b/examples/example_hyper.rs -@@ -16,9 +16,7 @@ extern crate lazy_static; - #[macro_use] - extern crate prometheus; - --use hyper::header::ContentType; --use hyper::mime::Mime; --use hyper::server::{Request, Response, Server}; -+use hyper::{header::CONTENT_TYPE, rt::Future, service::service_fn_ok, Body, Response, Server}; - - use prometheus::{Counter, Encoder, Gauge, HistogramVec, TextEncoder}; - -@@ -44,24 +42,35 @@ lazy_static! { - } - - fn main() { -- let encoder = TextEncoder::new(); -- let addr = "127.0.0.1:9898"; -- println!("listening addr {:?}", addr); -- Server::http(addr) -- .unwrap() -- .handle(move |_: Request<'_, '_>, mut res: Response<'_>| { -+ let addr = ([127, 0, 0, 1], 9898).into(); -+ println!("Listening address: {:?}", addr); -+ -+ let new_service = || { -+ let encoder = TextEncoder::new(); -+ service_fn_ok(move |_request| { - HTTP_COUNTER.inc(); - let timer = HTTP_REQ_HISTOGRAM.with_label_values(&["all"]).start_timer(); - - let metric_families = prometheus::gather(); - let mut buffer = vec![]; - encoder.encode(&metric_families, &mut buffer).unwrap(); -- res.headers_mut() -- .set(ContentType(encoder.format_type().parse::().unwrap())); -- res.send(&buffer).unwrap(); -+ HTTP_BODY_GAUGE.set(buffer.len() as f64); -+ -+ let response = Response::builder() -+ .status(200) -+ .header(CONTENT_TYPE, encoder.format_type()) -+ .body(Body::from(buffer)) -+ .unwrap(); - - timer.observe_duration(); -- HTTP_BODY_GAUGE.set(buffer.len() as f64); -+ -+ response - }) -- .unwrap(); -+ }; -+ -+ let server = Server::bind(&addr) -+ .serve(new_service) -+ .map_err(|e| eprintln!("Server error: {}", e)); -+ -+ hyper::rt::run(server); - } diff --git a/0002-Update-hyper-example-to-work-with-hyper-0.12-249.patch b/0002-Update-hyper-example-to-work-with-hyper-0.12-249.patch new file mode 100644 index 0000000..164cc04 --- /dev/null +++ b/0002-Update-hyper-example-to-work-with-hyper-0.12-249.patch @@ -0,0 +1,75 @@ +From 05e15b526f730b7ee650b9b6e846cadc0ad99ed6 Mon Sep 17 00:00:00 2001 +From: crash-g +Date: Mon, 17 Jun 2019 04:17:00 +0200 +Subject: [PATCH 2/2] Update hyper example to work with hyper 0.12 (#249) + +* Update hyper example to work with hyper 0.12 +--- + examples/example_hyper.rs | 37 +++++++++++++++++++++++-------------- + 1 file changed, 23 insertions(+), 14 deletions(-) + +diff --git a/examples/example_hyper.rs b/examples/example_hyper.rs +index c9d02bc..a6eda1b 100644 +--- a/examples/example_hyper.rs ++++ b/examples/example_hyper.rs +@@ -16,9 +16,7 @@ extern crate lazy_static; + #[macro_use] + extern crate prometheus; + +-use hyper::header::ContentType; +-use hyper::mime::Mime; +-use hyper::server::{Request, Response, Server}; ++use hyper::{header::CONTENT_TYPE, rt::Future, service::service_fn_ok, Body, Response, Server}; + + use prometheus::{Counter, Encoder, Gauge, HistogramVec, TextEncoder}; + +@@ -44,24 +42,35 @@ lazy_static! { + } + + fn main() { +- let encoder = TextEncoder::new(); +- let addr = "127.0.0.1:9898"; +- println!("listening addr {:?}", addr); +- Server::http(addr) +- .unwrap() +- .handle(move |_: Request<'_, '_>, mut res: Response<'_>| { ++ let addr = ([127, 0, 0, 1], 9898).into(); ++ println!("Listening address: {:?}", addr); ++ ++ let new_service = || { ++ let encoder = TextEncoder::new(); ++ service_fn_ok(move |_request| { + HTTP_COUNTER.inc(); + let timer = HTTP_REQ_HISTOGRAM.with_label_values(&["all"]).start_timer(); + + let metric_families = prometheus::gather(); + let mut buffer = vec![]; + encoder.encode(&metric_families, &mut buffer).unwrap(); +- res.headers_mut() +- .set(ContentType(encoder.format_type().parse::().unwrap())); +- res.send(&buffer).unwrap(); ++ HTTP_BODY_GAUGE.set(buffer.len() as f64); ++ ++ let response = Response::builder() ++ .status(200) ++ .header(CONTENT_TYPE, encoder.format_type()) ++ .body(Body::from(buffer)) ++ .unwrap(); + + timer.observe_duration(); +- HTTP_BODY_GAUGE.set(buffer.len() as f64); ++ ++ response + }) +- .unwrap(); ++ }; ++ ++ let server = Server::bind(&addr) ++ .serve(new_service) ++ .map_err(|e| eprintln!("Server error: {}", e)); ++ ++ hyper::rt::run(server); + } +-- +2.22.0 + diff --git a/0002-fix-should-panic-tests.diff b/0002-fix-should-panic-tests.diff deleted file mode 100644 index 742ba9c..0000000 --- a/0002-fix-should-panic-tests.diff +++ /dev/null @@ -1,43 +0,0 @@ -Indicate that the tests using should_panic need debug -assertions, so that the tests are run only on a debug -build. - -Pulled from the upstream change: -https://github.com/pingcap/rust-prometheus/pull/246 - -diff --git a/src/counter.rs b/src/counter.rs -index 2099933..a2b9bdb 100644 ---- a/src/counter.rs -+++ b/src/counter.rs -@@ -511,6 +511,7 @@ mod tests { - assert_eq!(vec.with_label_values(&["v1", "v2"]).get(), 34); - } - -+ #[cfg(debug_assertions)] - #[test] - #[should_panic(expected = "assertion failed")] - fn test_counter_negative_inc() { -@@ -518,6 +519,7 @@ mod tests { - counter.inc_by(-42.0); - } - -+ #[cfg(debug_assertions)] - #[test] - #[should_panic(expected = "assertion failed")] - fn test_local_counter_negative_inc() { -@@ -526,6 +528,7 @@ mod tests { - local.inc_by(-42.0); - } - -+ #[cfg(debug_assertions)] - #[test] - #[should_panic(expected = "assertion failed")] - fn test_int_counter_negative_inc() { -@@ -533,6 +536,7 @@ mod tests { - counter.inc_by(-42); - } - -+ #[cfg(debug_assertions)] - #[test] - #[should_panic(expected = "assertion failed")] - fn test_int_local_counter_negative_inc() { diff --git a/prometheus-fix-manifest.diff b/prometheus-fix-manifest.diff deleted file mode 100644 index 06b49c3..0000000 --- a/prometheus-fix-manifest.diff +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/Cargo.toml b/Cargo.toml -index 44f5796..d77f9eb 100644 ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -54,8 +54,7 @@ version = "0.5" - version = "0.2" - - [dev-dependencies.hyper] --version = "0.9" --default-features = false -+version = "0.12" - [build-dependencies.protobuf-codegen-pure] - version = "2.0" - optional = true diff --git a/prometheus-fix-metadata.diff b/prometheus-fix-metadata.diff new file mode 100644 index 0000000..f451d0d --- /dev/null +++ b/prometheus-fix-metadata.diff @@ -0,0 +1,12 @@ +--- prometheus-0.6.1/Cargo.toml 1970-01-01T00:00:00+00:00 ++++ prometheus-0.6.1/Cargo.toml 2019-06-18T01:41:45.385772+00:00 +@@ -54,8 +54,7 @@ + version = "0.2" + + [dev-dependencies.hyper] +-version = "0.9" +-default-features = false ++version = "0.12" + [build-dependencies.protobuf-codegen-pure] + version = "2.0" + optional = true diff --git a/rust-prometheus.spec b/rust-prometheus.spec index d49c76f..1a139d2 100644 --- a/rust-prometheus.spec +++ b/rust-prometheus.spec @@ -1,4 +1,4 @@ -# Generated by rust2rpm 9 +# Generated by rust2rpm 10 %bcond_without check %global debug_package %{nil} @@ -6,19 +6,20 @@ Name: rust-%{crate} Version: 0.6.1 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Prometheus instrumentation library for Rust applications # Upstream license specification: Apache-2.0 License: ASL 2.0 URL: https://crates.io/crates/prometheus Source: %{crates_source} -# Fix manifest to update to hyper 0.12 -Patch0: prometheus-fix-manifest.diff -# See: https://github.com/pingcap/rust-prometheus/pull/249 -Patch0001: 0001-update-example-hyper.diff -# See: https://github.com/pingcap/rust-prometheus/pull/246 -Patch0002: 0002-fix-should-panic-tests.diff +# Initial patched metadata +# * Update hyper to 0.12, https://github.com/pingcap/rust-prometheus/commit/05e15b526f730b7ee650b9b6e846cadc0ad99ed6 +Patch0: prometheus-fix-metadata.diff +# Fix tests in release mode, https://github.com/pingcap/rust-prometheus/commit/356220985d3c0f87b545b3f9f8997833e1e9ada1 +Patch0001: 0001-counter-fix-tests-in-release-mode-246.patch +# Finish migration to new hyper +Patch0002: 0002-Update-hyper-example-to-work-with-hyper-0.12-249.patch ExclusiveArch: %{rust_arches} %if %{__cargo_skip_build} @@ -26,18 +27,6 @@ BuildArch: noarch %endif BuildRequires: rust-packaging -%if ! %{__cargo_skip_build} -BuildRequires: (crate(cfg-if/default) >= 0.1.0 with crate(cfg-if/default) < 0.2.0) -BuildRequires: (crate(fnv/default) >= 1.0.0 with crate(fnv/default) < 2.0.0) -BuildRequires: (crate(lazy_static/default) >= 1.1.0 with crate(lazy_static/default) < 2.0.0) -BuildRequires: (crate(protobuf/default) >= 2.0.0 with crate(protobuf/default) < 3.0.0) -BuildRequires: (crate(quick-error/default) >= 1.2.2 with crate(quick-error/default) < 2.0.0) -BuildRequires: (crate(spin/default) >= 0.5.0 with crate(spin/default) < 0.6.0) -%if %{with check} -BuildRequires: (crate(getopts/default) >= 0.2.0 with crate(getopts/default) < 0.3.0) -BuildRequires: (crate(hyper) >= 0.12.0 with crate(hyper) < 0.13.0) -%endif -%endif %global _description %{expand: Prometheus instrumentation library for Rust applications.} @@ -54,9 +43,9 @@ This package contains library source intended for building other packages which use "%{crate}" crate. %files devel +%license LICENSE %doc README.md %{cargo_registry}/%{crate}-%{version}/ -%license LICENSE %package -n %{name}+default-devel Summary: %{summary} @@ -182,6 +171,9 @@ which use "reqwest" feature of "%{crate}" crate. %autosetup -n %{crate}-%{version_no_tilde} -p1 %cargo_prep +%generate_buildrequires +%cargo_generate_buildrequires + %build %cargo_build @@ -194,6 +186,9 @@ which use "reqwest" feature of "%{crate}" crate. %endif %changelog +* Tue Jun 18 03:41:45 CEST 2019 Igor Gnatenko - 0.6.1-3 +- Regenerate + * Mon Jun 17 10:50:00 UTC 2019 Robert Fairley - 0.6.1-2 - Update to hyper 0.12 (https://github.com/pingcap/rust-prometheus/pull/249)