compile and test cleanly with nightly

The vast majority of these are redundant imports.
This commit is contained in:
Matthew Gumport 2024-03-05 17:04:13 -08:00 committed by Edward Wang
parent 81e6adea4d
commit ae8ea771b1
25 changed files with 21 additions and 41 deletions

2
.bleep
View file

@ -1 +1 @@
7226cbe46016b51a2f76743555e734415f67923b f414cd9a922f157165dc954757e9ba3aca30fa53

View file

@ -20,8 +20,7 @@ use http::header::HeaderName;
use http::HeaderValue; use http::HeaderValue;
use indexmap::IndexMap; use indexmap::IndexMap;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use pingora_error::{Error, ErrorType, Result}; use pingora_error::{Error, ErrorType};
use pingora_http::ResponseHeader;
use regex::bytes::Regex; use regex::bytes::Regex;
use std::num::IntErrorKind; use std::num::IntErrorKind;
use std::slice; use std::slice;
@ -434,7 +433,6 @@ pub trait InterpretCacheControl {
mod tests { mod tests {
use super::*; use super::*;
use http::header::CACHE_CONTROL; use http::header::CACHE_CONTROL;
use http::HeaderValue;
use http::{request, response}; use http::{request, response};
fn build_response(cc_key: HeaderName, cc_value: &str) -> response::Parts { fn build_response(cc_key: HeaderName, cc_value: &str) -> response::Parts {

View file

@ -233,7 +233,6 @@ impl<const N: usize> EvictionManager for Manager<N> {
mod test { mod test {
use super::*; use super::*;
use crate::CacheKey; use crate::CacheKey;
use EvictionManager;
// we use shard (N) = 1 for eviction consistency in all tests // we use shard (N) = 1 for eviction consistency in all tests

View file

@ -16,12 +16,12 @@
use super::*; use super::*;
use crate::cache_control::{CacheControl, Cacheable, InterpretCacheControl}; use crate::cache_control::{CacheControl, Cacheable, InterpretCacheControl};
use crate::{RespCacheable, RespCacheable::*}; use crate::RespCacheable::*;
use http::{header, HeaderValue}; use http::{header, HeaderValue};
use httpdate::HttpDate; use httpdate::HttpDate;
use log::warn; use log::warn;
use pingora_http::{RequestHeader, ResponseHeader}; use pingora_http::RequestHeader;
/// Decide if the request can be cacheable /// Decide if the request can be cacheable
pub fn request_cacheable(req_header: &ReqHeader) -> bool { pub fn request_cacheable(req_header: &ReqHeader) -> bool {
@ -206,6 +206,7 @@ pub mod upstream {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::RespCacheable::Cacheable;
use http::header::{HeaderName, CACHE_CONTROL, EXPIRES, SET_COOKIE}; use http::header::{HeaderName, CACHE_CONTROL, EXPIRES, SET_COOKIE};
use http::StatusCode; use http::StatusCode;
use httpdate::fmt_http_date; use httpdate::fmt_http_date;

View file

@ -19,8 +19,8 @@
//TODO: Mark this module #[test] only //TODO: Mark this module #[test] only
use super::*; use super::*;
use crate::key::{CacheHashKey, CompactCacheKey}; use crate::key::CompactCacheKey;
use crate::storage::{HandleHit, HandleMiss, Storage}; use crate::storage::{HandleHit, HandleMiss};
use crate::trace::SpanHandle; use crate::trace::SpanHandle;
use async_trait::async_trait; use async_trait::async_trait;

View file

@ -264,14 +264,12 @@ mod test {
mod parse_response { mod parse_response {
use super::*; use super::*;
use bytes::{Bytes, BytesMut}; use bytes::BytesMut;
use httparse::Status; use httparse::Status;
use pingora_error::{ use pingora_error::{
Error, Error,
ErrorType::{self, *}, ErrorType::{self, *},
Result,
}; };
use pingora_http::ResponseHeader;
pub const INVALID_CHUNK: ErrorType = ErrorType::new("InvalidChunk"); pub const INVALID_CHUNK: ErrorType = ErrorType::new("InvalidChunk");
pub const INCOMPLETE_BODY: ErrorType = ErrorType::new("IncompleteHttpBody"); pub const INCOMPLETE_BODY: ErrorType = ErrorType::new("IncompleteHttpBody");
@ -280,7 +278,7 @@ mod parse_response {
const INIT_HEADER_BUF_SIZE: usize = 4096; const INIT_HEADER_BUF_SIZE: usize = 4096;
const CHUNK_DELIMITER_SIZE: usize = 2; // \r\n const CHUNK_DELIMITER_SIZE: usize = 2; // \r\n
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy, PartialEq)]
enum ParseState { enum ParseState {
Init, Init,
PartialHeader, PartialHeader,
@ -561,6 +559,10 @@ mod parse_response {
let output = parser.inject_data(input); let output = parser.inject_data(input);
// header is not complete // header is not complete
assert!(output.is_err()); assert!(output.is_err());
match parser.state {
ParseState::Invalid(httparse::Error::Version) => {}
_ => panic!("should have failed to parse"),
}
} }
#[test] #[test]

View file

@ -15,7 +15,7 @@
//! An HTTP application that reports Prometheus metrics. //! An HTTP application that reports Prometheus metrics.
use async_trait::async_trait; use async_trait::async_trait;
use http::{self, Response}; use http::Response;
use prometheus::{Encoder, TextEncoder}; use prometheus::{Encoder, TextEncoder};
use super::http_app::HttpServer; use super::http_app::HttpServer;

View file

@ -427,7 +427,7 @@ mod tests {
let stream = connector.new_stream(&peer).await; let stream = connector.new_stream(&peer).await;
let error = stream.unwrap_err(); let error = stream.unwrap_err();
// XXX: some system will allow the socket to bind and connect without error, only to timeout // XXX: some systems will allow the socket to bind and connect without error, only to timeout
assert!(error.etype() == &ConnectError || error.etype() == &ConnectTimedout) assert!(error.etype() == &ConnectError || error.etype() == &ConnectTimedout)
} }

View file

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use chrono::NaiveDateTime; use chrono::DateTime;
use http::header::HeaderValue; use http::header::HeaderValue;
use std::cell::RefCell; use std::cell::RefCell;
use std::time::{Duration, SystemTime}; use std::time::{Duration, SystemTime};
fn to_date_string(epoch_sec: i64) -> String { fn to_date_string(epoch_sec: i64) -> String {
let dt = NaiveDateTime::from_timestamp_opt(epoch_sec, 0).unwrap(); let dt = DateTime::from_timestamp(epoch_sec, 0).unwrap();
dt.format("%a, %d %b %Y %H:%M:%S GMT").to_string() dt.format("%a, %d %b %Y %H:%M:%S GMT").to_string()
} }

View file

@ -644,7 +644,6 @@ impl BodyWriter {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::utils::BufRef;
use tokio_test::io::Builder; use tokio_test::io::Builder;
fn init_log() { fn init_log() {

View file

@ -672,8 +672,6 @@ mod tests_stream {
use super::*; use super::*;
use crate::protocols::http::v1::body::ParseState; use crate::protocols::http::v1::body::ParseState;
use crate::ErrorType; use crate::ErrorType;
use std::str;
use std::time::Duration;
use tokio_test::io::Builder; use tokio_test::io::Builder;
fn init_log() { fn init_log() {

View file

@ -983,9 +983,8 @@ fn http_resp_header_to_buf(
mod tests_stream { mod tests_stream {
use super::*; use super::*;
use crate::protocols::http::v1::body::{BodyMode, ParseState}; use crate::protocols::http::v1::body::{BodyMode, ParseState};
use http::{Method, StatusCode}; use http::StatusCode;
use std::str; use std::str;
use std::time::Duration;
use tokio_test::io::Builder; use tokio_test::io::Builder;
fn init_log() { fn init_log() {

View file

@ -22,7 +22,6 @@ use daemon::daemonize;
use log::{debug, error, info}; use log::{debug, error, info};
use pingora_runtime::Runtime; use pingora_runtime::Runtime;
use pingora_timeout::fast_timeout; use pingora_timeout::fast_timeout;
use std::clone::Clone;
use std::sync::Arc; use std::sync::Arc;
use std::thread; use std::thread;
use tokio::signal::unix; use tokio::signal::unix;

View file

@ -343,7 +343,6 @@ where
mod tests { mod tests {
use super::*; use super::*;
use log::{debug, error}; use log::{debug, error};
use std::thread;
fn init_log() { fn init_log() {
let _ = env_logger::builder().is_test(true).try_init(); let _ = env_logger::builder().is_test(true).try_init();

View file

@ -30,7 +30,6 @@ use http::response::Builder as RespBuilder;
use http::response::Parts as RespParts; use http::response::Parts as RespParts;
use http::uri::Uri; use http::uri::Uri;
use pingora_error::{ErrorType::*, OrErr, Result}; use pingora_error::{ErrorType::*, OrErr, Result};
use std::convert::TryInto;
use std::ops::Deref; use std::ops::Deref;
pub use http::method::Method; pub use http::method::Method;

View file

@ -18,7 +18,6 @@ use super::*;
use pingora_core::protocols::l4::socket::SocketAddr; use pingora_core::protocols::l4::socket::SocketAddr;
use pingora_ketama::{Bucket, Continuum}; use pingora_ketama::{Bucket, Continuum};
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc;
/// Weighted Ketama consistent hashing /// Weighted Ketama consistent hashing
pub struct KetamaHashing { pub struct KetamaHashing {

View file

@ -15,7 +15,6 @@
use super::*; use super::*;
use crate::proxy_cache::{range_filter::RangeBodyFilter, ServeFromCache}; use crate::proxy_cache::{range_filter::RangeBodyFilter, ServeFromCache};
use crate::proxy_common::*; use crate::proxy_common::*;
use http::Version;
impl<SV> HttpProxy<SV> { impl<SV> HttpProxy<SV> {
pub(crate) async fn proxy_1to1( pub(crate) async fn proxy_1to1(

View file

@ -14,9 +14,6 @@
use super::*; use super::*;
use once_cell::sync::Lazy;
use pingora_core::protocols::http::SERVER_NAME;
fn gen_purge_response(code: u16) -> ResponseHeader { fn gen_purge_response(code: u16) -> ResponseHeader {
let mut resp = ResponseHeader::build(code, Some(3)).unwrap(); let mut resp = ResponseHeader::build(code, Some(3)).unwrap();
resp.insert_header(header::SERVER, &SERVER_NAME[..]) resp.insert_header(header::SERVER, &SERVER_NAME[..])

View file

@ -13,9 +13,7 @@
// limitations under the License. // limitations under the License.
use super::*; use super::*;
use pingora_cache::{ use pingora_cache::{key::HashBinary, CacheKey, CacheMeta, RespCacheable, RespCacheable::*};
key::HashBinary, CacheKey, CacheMeta, NoCacheReason, RespCacheable, RespCacheable::*,
};
/// The interface to control the HTTP proxy /// The interface to control the HTTP proxy
/// ///

View file

@ -135,7 +135,7 @@ async fn test_ws_server_ends_conn() {
mod test_cache { mod test_cache {
use super::*; use super::*;
use tokio::time::{sleep, Duration}; use tokio::time::sleep;
#[tokio::test] #[tokio::test]
async fn test_basic_caching() { async fn test_basic_caching() {

View file

@ -94,7 +94,6 @@ pub fn unpause() {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::time::Duration;
#[tokio::test] #[tokio::test]
async fn test_timeout() { async fn test_timeout() {

View file

@ -147,7 +147,6 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::time::Duration;
#[tokio::test] #[tokio::test]
async fn test_timeout() { async fn test_timeout() {

View file

@ -248,7 +248,6 @@ impl TimerManager {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::sync::Arc;
#[test] #[test]
fn test_round() { fn test_round() {

View file

@ -25,7 +25,6 @@ use structopt::StructOpt;
use tokio::time::interval; use tokio::time::interval;
use std::time::Duration; use std::time::Duration;
use std::vec::Vec;
mod app; mod app;
mod service; mod service;

View file

@ -329,9 +329,7 @@ impl<T: Clone + Send + Sync> FiFoQueues<T> {
fn evict_one_from_main(&self, buckets: &Buckets<T>) -> Option<KV<T>> { fn evict_one_from_main(&self, buckets: &Buckets<T>) -> Option<KV<T>> {
loop { loop {
let Some(to_evict) = self.main.pop() else { let to_evict = self.main.pop()?;
return None;
};
let buckets = buckets.pin(); let buckets = buckets.pin();
let maybe_bucket = buckets.get(&to_evict); let maybe_bucket = buckets.get(&to_evict);
if let Some(bucket) = maybe_bucket.as_ref() { if let Some(bucket) = maybe_bucket.as_ref() {