all tests passing in docker
This commit is contained in:
parent
0d1569c1a0
commit
0f2975630f
12
.travis.yml
12
.travis.yml
@ -9,56 +9,68 @@ matrix:
|
||||
- rust: stable
|
||||
env: OPTIONS="--all-features"
|
||||
RUN_KCOV=1
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
# no features
|
||||
- rust: stable
|
||||
env: MODULES="client integration-tests proto resolver server"
|
||||
OPTIONS="--no-default-features"
|
||||
RUN_KCOV=1
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
# default features...
|
||||
- rust: stable
|
||||
env: MODULES="client integration-tests proto resolver server"
|
||||
RUN_KCOV=1
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
# just openssl
|
||||
- rust: stable
|
||||
env: MODULES="client integration-tests proto resolver server"
|
||||
OPTIONS="--no-default-features --features=dnssec-openssl"
|
||||
RUN_KCOV=1
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
# just ring
|
||||
- rust: stable
|
||||
env: MODULES="client integration-tests proto resolver server"
|
||||
OPTIONS="--no-default-features --features=dnssec-ring"
|
||||
RUN_KCOV=1
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
# just tls using openssl
|
||||
- rust: stable
|
||||
env: MODULES="integration-tests server"
|
||||
OPTIONS="--no-default-features --features=tls-openssl"
|
||||
RUN_KCOV=1
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
# min rust version
|
||||
# - rust: 1.14.0
|
||||
- rust: beta
|
||||
env: RUST_BACKTRACE=full
|
||||
|
||||
- os: osx
|
||||
rust: stable
|
||||
env: OPTIONS="--all-features"
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
- rust: nightly
|
||||
env: RUST_BACKTRACE=full
|
||||
|
||||
- rust: nightly
|
||||
env: CLIPPY=true
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
- rust: nightly
|
||||
env: RUSTFMT=true
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
- rust: stable
|
||||
env: MODULES="compatibility-tests"
|
||||
TDNS_BIND_PATH="../../bind-9.11.0-P1/bin/named/named"
|
||||
OPTIONS="--no-default-features --features=bind"
|
||||
RUST_BACKTRACE=full
|
||||
|
||||
allow_failures:
|
||||
- rust: nightly
|
||||
|
@ -23,13 +23,13 @@ use tokio_core::reactor::{Core, Timeout};
|
||||
|
||||
use trust_dns::error::*;
|
||||
use trust_dns::client::{ClientFuture, ClientHandle};
|
||||
use trust_dns::multicast::{MdnsStream, MdnsClientStream};
|
||||
use trust_dns::multicast::{MdnsClientStream, MdnsStream};
|
||||
use trust_dns::multicast::MdnsQueryType;
|
||||
use trust_dns::op::Message;
|
||||
use trust_dns::rr::{DNSClass, Name, RecordType};
|
||||
use trust_dns::serialize::binary::BinDecodable;
|
||||
|
||||
const MDNS_PORT: u16 = 5353;
|
||||
const MDNS_PORT: u16 = 5353;
|
||||
|
||||
lazy_static! {
|
||||
/// 250 appears to be unused/unregistered
|
||||
@ -38,38 +38,50 @@ lazy_static! {
|
||||
static ref TEST_MDNS_IPV6: SocketAddr = SocketAddr::new(Ipv6Addr::new(0xFF02, 0, 0, 0, 0, 0, 0, 0x00F9).into(), MDNS_PORT);
|
||||
}
|
||||
|
||||
|
||||
fn mdns_responsder(test_name: &'static str, client_done: Arc<AtomicBool>, mdns_addr: SocketAddr) -> JoinHandle<()> {
|
||||
fn mdns_responsder(
|
||||
test_name: &'static str,
|
||||
client_done: Arc<AtomicBool>,
|
||||
mdns_addr: SocketAddr,
|
||||
) -> JoinHandle<()> {
|
||||
std::thread::Builder::new()
|
||||
.name(format!("{}:server", test_name))
|
||||
.spawn(move || {
|
||||
let mut io_loop = Core::new().unwrap();
|
||||
let loop_handle = io_loop.handle();
|
||||
|
||||
|
||||
// a max time for the test to run
|
||||
let mut timeout = Timeout::new(Duration::from_millis(100), &io_loop.handle()).expect("failed to register timeout");
|
||||
|
||||
let mut timeout = Timeout::new(Duration::from_millis(100), &io_loop.handle())
|
||||
.expect("failed to register timeout");
|
||||
|
||||
// FIXME: ipv6 if is hardcoded, need a different strategy
|
||||
let (mdns_stream, mdns_handle) = MdnsStream::new::<ClientError>(
|
||||
mdns_addr,
|
||||
MdnsQueryType::OneShotJoin,
|
||||
Some(0),
|
||||
Some(1),
|
||||
None,
|
||||
Some(5),
|
||||
&io_loop.handle(),
|
||||
);
|
||||
|
||||
let mut stream = io_loop.run(mdns_stream).ok().expect("failed to create server stream").into_future();
|
||||
let mut stream = io_loop
|
||||
.run(mdns_stream)
|
||||
.ok()
|
||||
.expect("failed to create server stream")
|
||||
.into_future();
|
||||
|
||||
while !client_done.load(std::sync::atomic::Ordering::Relaxed) {
|
||||
match io_loop.run(stream.select2(timeout)).ok().expect("server stream closed") {
|
||||
match io_loop
|
||||
.run(stream.select2(timeout))
|
||||
.ok()
|
||||
.expect("server stream closed")
|
||||
{
|
||||
Either::A((data_src_stream_tmp, timeout_tmp)) => {
|
||||
let (data_src, stream_tmp) = data_src_stream_tmp;
|
||||
let (data, src) = data_src.expect("no buffer received");
|
||||
|
||||
stream = stream_tmp.into_future();
|
||||
timeout = timeout_tmp;
|
||||
|
||||
|
||||
let message = Message::from_bytes(&data).expect("message decode failed");
|
||||
|
||||
// we're just going to bounce this message back
|
||||
@ -80,7 +92,8 @@ fn mdns_responsder(test_name: &'static str, client_done: Arc<AtomicBool>, mdns_a
|
||||
}
|
||||
Either::B(((), data_src_stream_tmp)) => {
|
||||
stream = data_src_stream_tmp;
|
||||
timeout = Timeout::new(Duration::from_millis(100), &loop_handle).expect("failed to register timeout");
|
||||
timeout = Timeout::new(Duration::from_millis(100), &loop_handle)
|
||||
.expect("failed to register timeout");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -91,10 +104,18 @@ fn mdns_responsder(test_name: &'static str, client_done: Arc<AtomicBool>, mdns_a
|
||||
#[test]
|
||||
fn test_query_mdns_ipv4() {
|
||||
let client_done = Arc::new(AtomicBool::new(false));
|
||||
let _server_thread = mdns_responsder("test_query_mdns_ipv4", client_done.clone(), *TEST_MDNS_IPV4);
|
||||
let _server_thread =
|
||||
mdns_responsder("test_query_mdns_ipv4", client_done.clone(), *TEST_MDNS_IPV4);
|
||||
let mut io_loop = Core::new().unwrap();
|
||||
//let addr: SocketAddr = ("8.8.8.8", 53).to_socket_addrs().unwrap().next().unwrap();
|
||||
let (stream, sender) = MdnsClientStream::new(*TEST_MDNS_IPV4, MdnsQueryType::OneShot, None, None, None, &io_loop.handle());
|
||||
let (stream, sender) = MdnsClientStream::new(
|
||||
*TEST_MDNS_IPV4,
|
||||
MdnsQueryType::OneShot,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
&io_loop.handle(),
|
||||
);
|
||||
let mut client = ClientFuture::new(stream, sender, &io_loop.handle(), None);
|
||||
|
||||
// A PTR request is the DNS-SD method for doing a directory listing...
|
||||
@ -102,9 +123,9 @@ fn test_query_mdns_ipv4() {
|
||||
let future = client.query(name.clone(), DNSClass::IN, RecordType::PTR);
|
||||
|
||||
let message = io_loop.run(future).expect("mdns query failed");
|
||||
|
||||
|
||||
client_done.store(true, Ordering::Relaxed);
|
||||
|
||||
|
||||
println!("message: {:#?}", message);
|
||||
}
|
||||
|
||||
@ -112,11 +133,19 @@ fn test_query_mdns_ipv4() {
|
||||
#[ignore]
|
||||
fn test_query_mdns_ipv6() {
|
||||
let client_done = Arc::new(AtomicBool::new(false));
|
||||
let _server_thread = mdns_responsder("test_query_mdns_ipv4", client_done.clone(), *TEST_MDNS_IPV6);
|
||||
let _server_thread =
|
||||
mdns_responsder("test_query_mdns_ipv4", client_done.clone(), *TEST_MDNS_IPV6);
|
||||
let mut io_loop = Core::new().unwrap();
|
||||
|
||||
|
||||
// FIXME: ipv6 if is hardcoded...
|
||||
let (stream, sender) = MdnsClientStream::new(*TEST_MDNS_IPV6, MdnsQueryType::OneShot, None, None, Some(5), &io_loop.handle());
|
||||
let (stream, sender) = MdnsClientStream::new(
|
||||
*TEST_MDNS_IPV6,
|
||||
MdnsQueryType::OneShot,
|
||||
None,
|
||||
None,
|
||||
Some(5),
|
||||
&io_loop.handle(),
|
||||
);
|
||||
let mut client = ClientFuture::new(stream, sender, &io_loop.handle(), None);
|
||||
|
||||
// A PTR request is the DNS-SD method for doing a directory listing...
|
||||
@ -124,8 +153,8 @@ fn test_query_mdns_ipv6() {
|
||||
let future = client.query(name.clone(), DNSClass::IN, RecordType::PTR);
|
||||
|
||||
let message = io_loop.run(future).expect("mdns query failed");
|
||||
|
||||
|
||||
client_done.store(true, Ordering::Relaxed);
|
||||
|
||||
|
||||
println!("message: {:#?}", message);
|
||||
}
|
||||
}
|
||||
|
@ -147,6 +147,10 @@ impl MdnsStream {
|
||||
ipv6_if,
|
||||
);
|
||||
|
||||
if let Some(ttl) = packet_ttl {
|
||||
assert!(ttl > 0, "TTL must be greater than 0");
|
||||
}
|
||||
|
||||
// This set of futures collapses the next udp socket into a stream which can be used for
|
||||
// sending and receiving udp packets.
|
||||
let stream: Box<Future<Item = MdnsStream, Error = io::Error>> = {
|
||||
@ -427,8 +431,8 @@ pub mod tests {
|
||||
// one_shot tests are basically clones from the udp tests
|
||||
#[test]
|
||||
fn test_next_random_socket() {
|
||||
use env_logger;
|
||||
env_logger::init();
|
||||
// use env_logger;
|
||||
// env_logger::init();
|
||||
|
||||
let mut io_loop = tokio_core::reactor::Core::new().unwrap();
|
||||
let (stream, _) = MdnsStream::new::<ProtoError>(
|
||||
|
@ -2,6 +2,19 @@
|
||||
|
||||
trust_dns_dir=$(dirname $0)/..
|
||||
|
||||
readonly OPTS="--tests --all-features -j 3"
|
||||
readonly TEST_OPTS="--test-threads=3"
|
||||
|
||||
builds=""
|
||||
builds="${builds} && echo '==> proto' && cd proto && cargo test ${OPTS} -- ${TEST_OPTS} && cd .."
|
||||
builds="${builds} && echo '==> resolver' && cd resolver && cargo test ${OPTS} -- ${TEST_OPTS} && cd .."
|
||||
builds="${builds} && echo '==> client' && cd client && cargo test ${OPTS} -- ${TEST_OPTS} && cd .."
|
||||
builds="${builds} && echo '==> server' && cd server && cargo test ${OPTS} -- ${TEST_OPTS} && cd .."
|
||||
builds="${builds} && echo '==> native-tls' && cd native-tls && cargo test ${OPTS} -- ${TEST_OPTS} && cd .."
|
||||
builds="${builds} && echo '==> openssl' && cd openssl && cargo test ${OPTS} -- ${TEST_OPTS} && cd .."
|
||||
builds="${builds} && echo '==> rustls' && cd rustls && cargo test ${OPTS} -- ${TEST_OPTS} && cd .."
|
||||
builds="${builds} && echo '==> integration-tests' && cd integration-tests && cargo test ${OPTS} -- ${TEST_OPTS} && cd .."
|
||||
|
||||
pushd ${trust_dns_dir}
|
||||
docker run \
|
||||
--rm \
|
||||
@ -10,5 +23,7 @@ docker run \
|
||||
-a STDERR -a STDOUT \
|
||||
-v ${PWD}/../:/src \
|
||||
rust:latest bash \
|
||||
-c "cd src/trust-dns && cargo test --features=mdns $@" | tee target/linux_output.txt
|
||||
-c "cd src/trust-dns \
|
||||
${builds}
|
||||
" | tee target/linux_output.txt
|
||||
popd
|
||||
|
Loading…
Reference in New Issue
Block a user