diff --git a/test/ltp/test-ltp.yaml b/test/ltp/test-ltp.yaml index 24853dab5..14ff8e2b0 100644 --- a/test/ltp/test-ltp.yaml +++ b/test/ltp/test-ltp.yaml @@ -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 diff --git a/test/virtsock/.gitignore b/test/virtsock/.gitignore new file mode 100644 index 000000000..8b100aa4b --- /dev/null +++ b/test/virtsock/.gitignore @@ -0,0 +1,3 @@ +/bin +/virtsock.tag +/hash \ No newline at end of file diff --git a/test/virtsock/Dockerfile.build b/test/virtsock/Dockerfile.build new file mode 100644 index 000000000..8f472d8f6 --- /dev/null +++ b/test/virtsock/Dockerfile.build @@ -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"] diff --git a/test/virtsock/Dockerfile.pkg b/test/virtsock/Dockerfile.pkg new file mode 100644 index 000000000..2f25a302a --- /dev/null +++ b/test/virtsock/Dockerfile.pkg @@ -0,0 +1,3 @@ +FROM scratch +COPY . ./ +CMD ["/bin/tini", "/bin/virtsock_stress", "-s", "-v", "1"] diff --git a/test/virtsock/Makefile b/test/virtsock/Makefile new file mode 100644 index 000000000..287541695 --- /dev/null +++ b/test/virtsock/Makefile @@ -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: diff --git a/test/virtsock/README.md b/test/virtsock/README.md new file mode 100644 index 000000000..af925a32f --- /dev/null +++ b/test/virtsock/README.md @@ -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 diff --git a/test/virtsock/test-virtsock-server.yaml b/test/virtsock/test-virtsock-server.yaml new file mode 100644 index 000000000..bbef8d7b8 --- /dev/null +++ b/test/virtsock/test-virtsock-server.yaml @@ -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