sozu-proxy / sozu-integration-tests Goto Github PK
View Code? Open in Web Editor NEWIntegration tests for sozu with https://www.testcontainers.org/
Integration tests for sozu with https://www.testcontainers.org/
For now, all the sozu containers use the same config.toml
and maybe for some tests we 'll need some specific global options that will collide with other tests. So we must be able to specify the config.toml
that will be use by sozu during the test.
That need:
configure()
by adding a mount volume
or copy
the config.toml in the containerconfig.toml
in multiple config fileindicate what the project does, how to run it, how to add tests, how to update containers
example client:
var WebSocket = require('ws');
/*
var ws = new WebSocket('ws://echo.websocket.org:8080/', {
origin: 'http://websocket.org'
});
*/
var ws = new WebSocket('ws://lolcatho.st:33450/', {
origin: 'http://lolcatho.st:33450',
protocolVersion: 8
});
ws.on('open', function open() {
console.log('connected');
ws.send(Date.now().toString(), {mask: true});
});
ws.on('close', function close() {
console.log('disconnected');
});
ws.on('message', function message(data, flags) {
console.log('Roundtrip time: ' + (Date.now() - parseInt(data)) + 'ms', flags);
setTimeout(function timeout() {
ws.send(Date.now().toString(), {mask: true});
}, 500);
});
example server code:
var WebSocketServer = require('ws').Server;
//var ws = new WebSocket('ws://lolcatho.st:1026/');
var ws = new WebSocketServer({ port: 1026, origin: 'http://lolcatho.st:8080' });
ws.on('open', function open() {
console.log("client opened");
ws.send('opened');
});
ws.on('message', function(data, flags) {
// flags.binary will be set if a binary data is received.
// flags.masked will be set if the data was masked.
console.log("message: "+message);
ws.send(data);
});
ws.on('connection', function connection(c) {
console.log("got connection");
c.on('message', function message(data) {
console.log("message: "+data);
// Broadcast to everyone else.
/*ws.clients.forEach(function each(client) {
if (client !== c) client.send(data);
});*/
c.send(data);
});
});
Maybe the configuration of ipv6 for the daemon break the tests.
Here is the stack trace I'll take a look
HaproxyContainerTest STANDARD_ERROR
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
HaproxyContainerTest STANDARD_OUT
ℹ︎ Checking the system...
✔ Docker version should be at least 1.6.0
✔ Docker environment should have more than 2GB free disk space
✔ File should be mountable
NodeBackendContainerTest > testCorrectResponseFromNodeBackend STANDARD_ERROR
Nov 02, 2018 11:53:13 AM NodeBackendContainerTest testCorrectResponseFromNodeBackend
INFO: Running node backend at http://localhost:32843
SozuContainerTest > testStickySessions FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > testRetryPolicy FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > testHttpsredirect FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > shouldGet100ContinueStatusCode FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > shouldWorkWithWebsocket FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > testPathbeginWithKeepAlive FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > testPathbegin FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > shouldNotPanicWhenHostIsEmpty FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > testRemoveBackendBetweenRequests FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
SozuContainerTest > testCorrectResponseFromSozu FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
Gradle Test Executor 1 finished executing tests.
> Task :test
SozuContainerTest > testHttpCircuitBreaker FAILED
org.testcontainers.containers.ContainerLaunchException: Container startup failed
Caused by:
org.rnorth.ducttape.RetryCountExceededException: Retry limit hit with exception
Caused by:
org.testcontainers.containers.ContainerLaunchException: Could not create/start container
Caused by:
java.lang.reflect.UndeclaredThrowableException
Caused by:
java.lang.reflect.InvocationTargetException
Caused by:
com.github.dockerjava.api.exception.DockerException: {"message":"Address already in use"}
13 tests completed, 11 failed
The test testStickySessions
failed with the log:
SozuContainerTest > testStickySessions FAILED
java.lang.NullPointerException
at SozuContainerTest.testStickySessions(SozuContainerTest.java:243)
That can be interesting to have a feature to dump the packets of a sozu container.
A way to do that is by adding tcpdump
at the sozu image and use execCommand
method.
how could this project be run regularly, on the master branch's modifications and on pull requests? Could we wrap it under gitlab runners on Clever Cloud's infrastructure? ping @k33g
We must create a local bridge network named "my-net" to run the test suite :
docker network create --driver=bridge --subnet=172.18.0.0/16 my-net
It's because we have to know the ipv4 address backends to register them in the sozu config.toml
testcontainers
provide this feature but it's not documented for the moment (issues/509) . They have unit tests to show how to use this feature.
The current code downloads the latest container from hub.docker.com, but to test with a local sozu repository, we should be able to point to a path on the filesystem to a Dockerfile that would be used instead.
See https://www.testcontainers.org/usage/dockerfile.html for more info on running testcontainers from a Dockerfile
We should modify the constructor and the configure()
to apply this.
The default log level value will be "info".
GET /
requestit might be interesting to have variations in chunk size and frequency (example: send some 1 byte chunks, or wait a few milliseconds before sending the next chunk)
The 100 HTTP status code needs special handling, because the server will do a first validation and send a response, then the client will send the rest of the response. It can be used when the client wants to send a huge file but check authorization before sending the actual data.
References:
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1.1
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/100
example server code:
const http = require('http');
const net = require('net');
const url = require('url');
const server = http.createServer()
// listen for checkContinue events
server.on('checkContinue', function(req, res) {
console.log("check_continue")
req.checkContinue = true;
handlePostFile(req, res); // call express directly to route the request
});
// example request handler
function handlePostFile(req, res) {
console.log("handle post file")
// was this a conditional request?
if (req.checkContinue === true) {
req.checkContinue = false;
// send 100 Continue response
res.writeContinue();
console.log("wrote continue");
// client will now send us the request body
}
// collect request body
var body = '';
req.once('readable', function() {
var chunk;
console.log("readable()");
while ((chunk = req.read()) !== null) {
console.log("read");
body += chunk;
}
// do something with request body
});
}
server.listen(1029)
send_proxy=true
send_proxy
with expect_proxy=true
and in http modeX-Forwarded-Proto: http
X-Forwarded-For: <identifier>
X-Forwarded-Port: <port>
Forwarded: proto=http;for=<identifier>;by=<host>
apparently testcontainers downloads a container once, and does not check for updates afterwards. We should either have a command to update the container we use, or have the tool check for updates before running
this is a way for some servers to stop big uploads if the client did not send a Expect: 100-continue
in its request headers
there's probably a way to get what's written on stdout in the sozu container, but also in the client and backend containers. This output should be displayed in case the test fails
Forwarded-*
headersis it possible to perform some tests over ipv6? To check that sozu works properly with ipv6 addresses
For some integration test e.g. #15 we have to send command through the sozu socket unix in the container.
A solution could be to add sozuctl
binary in the sozu Dockerfile
and use docker exec
endpoint to make commands.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.