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 indexmap::IndexMap;
use once_cell::sync::Lazy;
use pingora_error::{Error, ErrorType, Result};
use pingora_http::ResponseHeader;
use pingora_error::{Error, ErrorType};
use regex::bytes::Regex;
use std::num::IntErrorKind;
use std::slice;
@ -434,7 +433,6 @@ pub trait InterpretCacheControl {
mod tests {
use super::*;
use http::header::CACHE_CONTROL;
use http::HeaderValue;
use http::{request, response};
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 {
use super::*;
use crate::CacheKey;
use EvictionManager;
// we use shard (N) = 1 for eviction consistency in all tests

View file

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

View file

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

View file

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

View file

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

View file

@ -427,7 +427,7 @@ mod tests {
let stream = connector.new_stream(&peer).await;
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)
}

View file

@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use chrono::NaiveDateTime;
use chrono::DateTime;
use http::header::HeaderValue;
use std::cell::RefCell;
use std::time::{Duration, SystemTime};
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()
}

View file

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

View file

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

View file

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

View file

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

View file

@ -343,7 +343,6 @@ where
mod tests {
use super::*;
use log::{debug, error};
use std::thread;
fn init_log() {
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::uri::Uri;
use pingora_error::{ErrorType::*, OrErr, Result};
use std::convert::TryInto;
use std::ops::Deref;
pub use http::method::Method;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -25,7 +25,6 @@ use structopt::StructOpt;
use tokio::time::interval;
use std::time::Duration;
use std::vec::Vec;
mod app;
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>> {
loop {
let Some(to_evict) = self.main.pop() else {
return None;
};
let to_evict = self.main.pop()?;
let buckets = buckets.pin();
let maybe_bucket = buckets.get(&to_evict);
if let Some(bucket) = maybe_bucket.as_ref() {