Merge pull request #1363 from rneugeba/tests

Add virtio and Hyper-V socket stress tests
This commit is contained in:
Rolf Neugebauer 2017-03-22 18:12:03 +00:00 committed by GitHub
commit e276de9b49
7 changed files with 131 additions and 2 deletions

View File

@ -13,5 +13,4 @@ files:
outputs:
- format: kernel+initrd
- format: iso-bios
# The initrd is too large for a pre-allocated EFI ISO
# - format: iso-efi
- format: iso-efi

3
test/virtsock/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/bin
/virtsock.tag
/hash

View File

@ -0,0 +1,11 @@
FROM mobylinux/go-compile:3afebc59c5cde31024493c3f91e6102d584a30b9
ENV VIRTSOCK_COMMIT=6b4dec728264e07c41e108caebd6bc2b72559a5f
RUN mkdir -p $GOPATH/src/github.com/rneugeba && \
cd $GOPATH/src/github.com/rneugeba && \
git clone https://github.com/rneugeba/virtsock.git
WORKDIR $GOPATH/src/github.com/rneugeba/virtsock
RUN git checkout $VIRTSOCK_COMMIT
RUN make build/virtsock_stress.linux
ENTRYPOINT ["cat", "build/virtsock_stress.linux"]

View File

@ -0,0 +1,3 @@
FROM scratch
COPY . ./
CMD ["/bin/tini", "/bin/virtsock_stress", "-s", "-v", "1"]

46
test/virtsock/Makefile Normal file
View File

@ -0,0 +1,46 @@
.PHONY: tag push clean container
all: push
# Build the virtsock stress server
VIRTSOCK_BINARY=bin/virtsock_stress
DEPS=Dockerfile.build Makefile
virtsock.tag: $(DEPS)
BUILD=$$(docker build -f $< -q .) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && echo "$$BUILD" > $@
$(VIRTSOCK_BINARY): virtsock.tag
mkdir -p $(dir $@)
docker run --rm --net=none --log-driver=none $(shell cat virtsock.tag) > $@
chmod ugo+x $@
TINI_IMAGE=mobylinux/tini:6b25b62f4d893de8721fd2581411039b17e8a253@sha256:39b4a459018ffc155a9fcbbf952fa625c77f5a8d7599b326eade529d3dc723fc
TINI_BINARY=bin/tini
$(TINI_BINARY):
mkdir -p $(dir $@)
docker run --rm --net=none $(TINI_IMAGE) tar cf - $@ | tar xf -
SHASUM=alpine:3.5
IMAGE=test-virtsock
container: Dockerfile.pkg $(DEPS) $(VIRTSOCK_BINARY) $(TINI_BINARY)
tar cf - $^ | docker build --no-cache -t $(IMAGE):build -f $< -
hash: Dockerfile.pkg $(DEPS)
find $^ -type f | xargs cat | DOCKER_CONTENT_TRUST=1 docker run --rm -i $(SHASUM) sha1sum | sed 's/ .*//' > $@
push: hash container
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
(docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash) && \
docker push mobylinux/$(IMAGE):$(shell cat hash))
docker rmi $(IMAGE):build
rm -f hash
tag: hash container
docker pull mobylinux/$(IMAGE):$(shell cat hash) || \
docker tag $(IMAGE):build mobylinux/$(IMAGE):$(shell cat hash)
docker rmi $(IMAGE):build
rm -f hash
clean:
rm -rf $(VIRTSOCK_BINARY) $(TINI_BINARY) virtsock.tag hash
.DELETE_ON_ERROR:

33
test/virtsock/README.md Normal file
View File

@ -0,0 +1,33 @@
This directory contains the files to build and run a container containing the
virtio and Hyper-V socket stress tests. `test-virtsock-server.yaml` builds images which start the server inside the VM.
The client, to be run on the host as per this [README](https://github.com/rneugeba/virtsock/blob/master/examples/README.md), can be obtained compiled from [here](https://github.com/rneugeba/virtsock).
## How to use (on Windows)
- Build the images: `moby build test-virtsock-server`
- Copy the `test-virtsock-server.iso` to a Windows system
- Create a Type 1 Hyper-V VM (called `virtsock`).
- No Disk or network required
- Add the ISO to the CDROM device
- Make sure you enable a named pipe for COM1 (call it `virtsock`)
- Start the VM
- Connect to the serial console (to get debug output) with `putty -serial \\.\pipe\virtsock`
Run the client:
```
$vmId = (get-vm virtsock).Id
.\virtsock_stress.exe -c $vmId -v 1 -c 1000000 -p 10
```
This creates `1000000` connections from `10` threads to the VM and
sends some random amount of data of the connection before tearing it
down. There are more options to change the behaviour.
## TODO
- Add scripts to create Hyper-V VM
- Enable virtio sockets in `moby run` with HyperKit
- Add some sample client YAML files which would connect from the VM to the host
- Hook up to CI for both HyperKit and Hyper-V

View File

@ -0,0 +1,34 @@
kernel:
# Alternatively:
# image: "mobylinux/kernel:4.10.4-0"
# image: "mobylinux/kernel:4.9.16-1"
# image: "mobylinux/kernel:4.9.14-0"
image: "mobylinux/kernel:4.9.x"
cmdline: "console=ttyS0 page_poison=1"
init: "mobylinux/init:d6d115d601e78f7909d4a2ff7eb4caa3fff65271"
system:
- name: sysctl
image: "mobylinux/sysctl:2cf2f9d5b4d314ba1bfc22b2fe931924af666d8c"
network_mode: host
pid: host
ipc: host
capabilities:
- CAP_SYS_ADMIN
read_only: true
daemon:
- name: rngd
image: "mobylinux/rngd:3dad6dd43270fa632ac031e99d1947f20b22eec9@sha256:1c93c1db7196f6f71f8e300bc1d15f0376dd18e8891c8789d77c8ff19f3a9a92"
capabilities:
- CAP_SYS_ADMIN
oom_score_adj: -800
read_only: true
command: [/bin/tini, /usr/sbin/rngd, -f]
- name: virtsock-server
image: "mobylinux/test-virtsock:35fea96fd01f6edb67021c494ddf098fdb8bbca0"
read_only: true
command: [/bin/tini, /bin/virtsock_stress, -s, -v, 1]
outputs:
- format: kernel+initrd
- format: iso-bios
- format: iso-efi