From 74faa30af6349a7f87959dcf907092b98af735ec Mon Sep 17 00:00:00 2001 From: sveneh Date: Wed, 14 Jan 2015 16:10:33 +0100 Subject: [PATCH 1/4] first version of automatic testrunner deployment. Uses ansible, vagrant and virtualbox --- .gitignore | 4 ++ ansible/README.md | 5 ++ ansible/Vagrantfile | 75 +++++++++++++++++++++++++ ansible/host-config.yml | 8 +++ ansible/roles/common/tasks/main.yml | 27 +++++++++ ansible/roles/testrunner/tasks/main.yml | 6 ++ ansible/site.yml | 3 + ansible/test-files/docker-go/Dockerfile | 46 +++++++++++++++ ansible/testrunner-config.yml | 12 ++++ 9 files changed, 186 insertions(+) create mode 100644 .gitignore create mode 100644 ansible/README.md create mode 100644 ansible/Vagrantfile create mode 100644 ansible/host-config.yml create mode 100644 ansible/roles/common/tasks/main.yml create mode 100644 ansible/roles/testrunner/tasks/main.yml create mode 100644 ansible/site.yml create mode 100644 ansible/test-files/docker-go/Dockerfile create mode 100644 ansible/testrunner-config.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..cdf615a0fe --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +venv/ +*~ +*.swp +.vagrant/ diff --git a/ansible/README.md b/ansible/README.md new file mode 100644 index 0000000000..558b2e845f --- /dev/null +++ b/ansible/README.md @@ -0,0 +1,5 @@ +# Automatic deployment of the random test generator + +Testing is done in a Vagrant virtual machine + +install vagrant, virtualbox, ansible, then do `vagrant up`. It should provison a basic machine. `vagrant ssh` to verify the machine is working as expected. diff --git a/ansible/Vagrantfile b/ansible/Vagrantfile new file mode 100644 index 0000000000..ca2a7b288c --- /dev/null +++ b/ansible/Vagrantfile @@ -0,0 +1,75 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION ||= "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "ubuntu/trusty64" + config.vm.define "random-test" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + # end + + + # Ubuntu / Virtualbox workaround. + # see http://askubuntu.com/questions/238040/how-do-i-fix-name-service-for-vagrant-client + config.vm.provider "virtualbox" do |vb| + vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + end + + # + # View the documentation for the provider you're using for more + # information on available options. + + + # Ansible + config.vm.provision "ansible" do |ansible| + ansible.playbook = "host-config.yml" + end + +end + diff --git a/ansible/host-config.yml b/ansible/host-config.yml new file mode 100644 index 0000000000..edb4cd8209 --- /dev/null +++ b/ansible/host-config.yml @@ -0,0 +1,8 @@ +--- +- name: Provision the operation system for buildslave + # testing + hosts: all + # live + # hosts: poc-8.ethdev.com + roles: + - common diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml new file mode 100644 index 0000000000..dcffc7b8be --- /dev/null +++ b/ansible/roles/common/tasks/main.yml @@ -0,0 +1,27 @@ +--- +- name: install docker + sudo: true + # install script from https://docs.docker.com/installation/ubuntulinux/ + shell: curl -sSL https://get.docker.com/ubuntu/ | sudo sh + +- name: install package dependencies + sudo: true + apt: name={{ item }} + with_items: + - python-pip + +- name: install python dependencies + sudo: true + pip: name=docker-py + + +- name: enable docker for standard user + sudo: true + # todo: how to logout after this command, otherwise won't be effective in this play + user: name=vagrant groups=docker append=yes + +- name: checkout test repo + git: + repo: https://github.com/sveneh/tests.git + version: develop + dest: git diff --git a/ansible/roles/testrunner/tasks/main.yml b/ansible/roles/testrunner/tasks/main.yml new file mode 100644 index 0000000000..54f7fc5fbb --- /dev/null +++ b/ansible/roles/testrunner/tasks/main.yml @@ -0,0 +1,6 @@ +--- +- name: update Go client + docker_image: + path: git/ansible/test-files/docker-go + name: go + state: build diff --git a/ansible/site.yml b/ansible/site.yml new file mode 100644 index 0000000000..cc04daa940 --- /dev/null +++ b/ansible/site.yml @@ -0,0 +1,3 @@ +--- +- include: host-config.yml +- include: testrunner-config.yml diff --git a/ansible/test-files/docker-go/Dockerfile b/ansible/test-files/docker-go/Dockerfile new file mode 100644 index 0000000000..235ffff440 --- /dev/null +++ b/ansible/test-files/docker-go/Dockerfile @@ -0,0 +1,46 @@ +# Adjusted from https://github.com/ethereum/go-ethereum/blob/develop/Dockerfile +FROM ubuntu:14.04 + +## Environment setup +ENV HOME /root +ENV GOPATH /root/go +ENV PATH /go/bin:/root/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games + +RUN mkdir -p /root/go +ENV DEBIAN_FRONTEND noninteractive + +## Install base dependencies +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y git mercurial build-essential software-properties-common pkg-config libgmp3-dev libreadline6-dev libpcre3-dev libpcre++-dev + +## Build and install Go +RUN hg clone -u release https://code.google.com/p/go +RUN cd go && hg update go1.4 +RUN cd go/src && ./all.bash && go version + +## Install GUI dependencies +RUN add-apt-repository ppa:ubuntu-sdk-team/ppa -y +RUN apt-get update -y +RUN apt-get install -y qtbase5-private-dev qtdeclarative5-private-dev libqt5opengl5-dev + +## Fetch and install serpent-go +RUN go get -v -d github.com/ethereum/serpent-go +WORKDIR $GOPATH/src/github.com/ethereum/serpent-go +# RUN git checkout master +RUN git submodule update --init +RUN go install -v + +# Fetch and install go-ethereum +RUN go get -v -d github.com/ethereum/go-ethereum/... +WORKDIR $GOPATH/src/github.com/ethereum/go-ethereum + +RUN git checkout develop + +RUN git pull +RUN ETH_DEPS=$(go list -f '{{.Imports}} {{.TestImports}} {{.XTestImports}}' github.com/ethereum/go-ethereum/... | sed -e 's/\[//g' | sed -e 's/\]//g' | sed -e 's/C //g'); if [ "$ETH_DEPS" ]; then go get $ETH_DEPS; fi +RUN go install -v ./cmd/ethtest + +# Run JSON RPC +ENTRYPOINT ["ethtest"] +EXPOSE 8080 + diff --git a/ansible/testrunner-config.yml b/ansible/testrunner-config.yml new file mode 100644 index 0000000000..99323f82bc --- /dev/null +++ b/ansible/testrunner-config.yml @@ -0,0 +1,12 @@ +--- +- name: setting up buildslave configuration + # testing + hosts: all + # live + # hosts: poc-8.ethdev.com + + # TODO use the right user for configuring, until credentials set, stay with default vagrant user + # remote_user: buildsalve + + roles: + - buildslave From 9326d0a6dd902435ad13fe23c21d7b8f30fb35ce Mon Sep 17 00:00:00 2001 From: sveneh Date: Wed, 14 Jan 2015 17:03:37 +0100 Subject: [PATCH 2/4] Dockers for go, cpp --- ansible/README.md | 2 +- ansible/Vagrantfile | 8 ++-- ansible/host-config.yml | 4 +- ansible/roles/common/tasks/main.yml | 1 + ansible/test-files/docker-cpp/Dockerfile | 32 ++++++++++++++ ansible/test-files/docker-go/Dockerfile | 2 +- ansible/test-files/testrunner.sh | 55 ++++++++++++++++++++++++ ansible/testrunner-config.yml | 8 ++-- 8 files changed, 101 insertions(+), 11 deletions(-) create mode 100644 ansible/test-files/docker-cpp/Dockerfile create mode 100644 ansible/test-files/testrunner.sh diff --git a/ansible/README.md b/ansible/README.md index 558b2e845f..cef4079865 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -2,4 +2,4 @@ Testing is done in a Vagrant virtual machine -install vagrant, virtualbox, ansible, then do `vagrant up`. It should provison a basic machine. `vagrant ssh` to verify the machine is working as expected. +install vagrant, virtualbox, ansible, then do `vagrant up`. It should provison a basic machine. `vagrant ssh` to verify the machine is working as expected. `vagrant terminate` to reset machine to clean state. diff --git a/ansible/Vagrantfile b/ansible/Vagrantfile index ca2a7b288c..748085a232 100644 --- a/ansible/Vagrantfile +++ b/ansible/Vagrantfile @@ -55,10 +55,12 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # end - # Ubuntu / Virtualbox workaround. - # see http://askubuntu.com/questions/238040/how-do-i-fix-name-service-for-vagrant-client config.vm.provider "virtualbox" do |vb| + # Ubuntu / Virtualbox workaround. + # see http://askubuntu.com/questions/238040/how-do-i-fix-name-service-for-vagrant-client vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + + vb.customize ["modifyvm", :id, "--memory", "1024"] end # @@ -68,7 +70,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Ansible config.vm.provision "ansible" do |ansible| - ansible.playbook = "host-config.yml" + ansible.playbook = "site.yml" end end diff --git a/ansible/host-config.yml b/ansible/host-config.yml index edb4cd8209..571cc141eb 100644 --- a/ansible/host-config.yml +++ b/ansible/host-config.yml @@ -1,8 +1,8 @@ --- -- name: Provision the operation system for buildslave +- name: Provision the operation system for tests # testing hosts: all # live - # hosts: poc-8.ethdev.com + # hosts: TDB roles: - common diff --git a/ansible/roles/common/tasks/main.yml b/ansible/roles/common/tasks/main.yml index dcffc7b8be..3c483ce13c 100644 --- a/ansible/roles/common/tasks/main.yml +++ b/ansible/roles/common/tasks/main.yml @@ -9,6 +9,7 @@ apt: name={{ item }} with_items: - python-pip + - htop - name: install python dependencies sudo: true diff --git a/ansible/test-files/docker-cpp/Dockerfile b/ansible/test-files/docker-cpp/Dockerfile new file mode 100644 index 0000000000..a3b0e4ca6d --- /dev/null +++ b/ansible/test-files/docker-cpp/Dockerfile @@ -0,0 +1,32 @@ +# adjusted from https://github.com/ethereum/cpp-ethereum/blob/develop/docker/Dockerfile +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND noninteractive +RUN apt-get update +RUN apt-get upgrade -y + +# Ethereum dependencies +RUN apt-get install -qy build-essential g++-4.8 git cmake libboost-all-dev libcurl4-openssl-dev wget +RUN apt-get install -qy automake unzip libgmp-dev libtool libleveldb-dev yasm libminiupnpc-dev libreadline-dev scons +RUN apt-get install -qy libjsoncpp-dev libargtable2-dev + +# NCurses based GUI (not optional though for a succesful compilation, see https://github.com/ethereum/cpp-ethereum/issues/452 ) +RUN apt-get install -qy libncurses5-dev + +# Qt-based GUI +# RUN apt-get install -qy qtbase5-dev qt5-default qtdeclarative5-dev libqt5webkit5-dev + +# Ethereum PPA +RUN apt-get install -qy software-properties-common +RUN add-apt-repository ppa:ethereum/ethereum +RUN apt-get update +RUN apt-get install -qy libcryptopp-dev libjson-rpc-cpp-dev + +# Build Ethereum (HEADLESS) +RUN git clone --depth=1 --branch develop https://github.com/ethereum/cpp-ethereum +RUN mkdir -p cpp-ethereum/build +RUN cd cpp-ethereum/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DHEADLESS=1 && make -j $(cat /proc/cpuinfo | grep processor | wc -l) && make install +RUN ldconfig + +ENTRYPOINT ["/cpp-ethereum/build/test/createRandomTest"] + diff --git a/ansible/test-files/docker-go/Dockerfile b/ansible/test-files/docker-go/Dockerfile index 235ffff440..2302518f33 100644 --- a/ansible/test-files/docker-go/Dockerfile +++ b/ansible/test-files/docker-go/Dockerfile @@ -16,7 +16,7 @@ RUN apt-get install -y git mercurial build-essential software-properties-common ## Build and install Go RUN hg clone -u release https://code.google.com/p/go RUN cd go && hg update go1.4 -RUN cd go/src && ./all.bash && go version +RUN cd go/src && ./make.bash && go version ## Install GUI dependencies RUN add-apt-repository ppa:ubuntu-sdk-team/ppa -y diff --git a/ansible/test-files/testrunner.sh b/ansible/test-files/testrunner.sh new file mode 100644 index 0000000000..08b21c88e4 --- /dev/null +++ b/ansible/test-files/testrunner.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# create random virtual machine test +#cd ~/software/Ethereum/pyethereum (python has local dependencies so only works from within the directory) +while [ 1 ] +do + TEST="$(~/software/Ethereum/cpp-ethereum/build/test/createRandomTest)" + # echo "$TEST" + + # test pyethereum + + #OUTPUT_PYTHON="$(python ./tests/test_vm.py "$TEST")" + #RESULT_PYTHON=$? + + # test go + OUTPUT_GO="$(ethtest "$TEST")" + RESULT_GO=$? + + # test cpp-jit + #OUTPUT_CPPJIT="$(~/software/Ethereum/cpp-ethereum/build/test/checkRandomTest "$TEST")" + #RESULT_CPPJIT=$? + +# go fails +if [ "$RESULT_GO" -ne 0 ]; then + echo Failed: + echo Output_GO: + echo $OUTPUT_GO + echo Test: + echo "$TEST" + echo "$TEST" > FailedTest.json + mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")GO.json # replace with scp to central server +fi + +# python fails +#if [ "$RESULT_PYTHON" -ne 0 ]; then +# echo Failed: +# echo Output_PYTHON: +# echo $OUTPUT_PYTHON +# echo Test: +# echo "$TEST" +# echo "$TEST" > FailedTest.json +# mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")PYTHON.json +#fi + +# cppjit fails +#if [ "$RESULT_CPPJIT" -ne 0 ]; then +# echo Failed: +# echo Output_CPPJIT: +# echo $OUTPUT_CPPJIT +# echo Test: +# echo "$TEST" +# echo "$TEST" > FailedTest.json +# mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")CPPJIT.json +#fi + diff --git a/ansible/testrunner-config.yml b/ansible/testrunner-config.yml index 99323f82bc..0304883f18 100644 --- a/ansible/testrunner-config.yml +++ b/ansible/testrunner-config.yml @@ -1,12 +1,12 @@ --- -- name: setting up buildslave configuration +- name: preparing and running tests # testing hosts: all # live - # hosts: poc-8.ethdev.com + # hosts: TBD # TODO use the right user for configuring, until credentials set, stay with default vagrant user - # remote_user: buildsalve + # remote_user: ubuntu roles: - - buildslave + - testrunner From fffd9810585210d9b25d03d378471de2d229d4e2 Mon Sep 17 00:00:00 2001 From: sveneh Date: Wed, 14 Jan 2015 17:53:13 +0100 Subject: [PATCH 3/4] uses docker in tesrunner --- ansible/Vagrantfile | 3 ++- ansible/test-files/testrunner.sh | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ansible/Vagrantfile b/ansible/Vagrantfile index 748085a232..ce6ac3dde6 100644 --- a/ansible/Vagrantfile +++ b/ansible/Vagrantfile @@ -60,7 +60,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # see http://askubuntu.com/questions/238040/how-do-i-fix-name-service-for-vagrant-client vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] - vb.customize ["modifyvm", :id, "--memory", "1024"] + # cpp client needs a lot of RAM to build + vb.customize ["modifyvm", :id, "--memory", "2048"] end # diff --git a/ansible/test-files/testrunner.sh b/ansible/test-files/testrunner.sh index 08b21c88e4..dabea7fb38 100644 --- a/ansible/test-files/testrunner.sh +++ b/ansible/test-files/testrunner.sh @@ -4,7 +4,7 @@ #cd ~/software/Ethereum/pyethereum (python has local dependencies so only works from within the directory) while [ 1 ] do - TEST="$(~/software/Ethereum/cpp-ethereum/build/test/createRandomTest)" + TEST="$(docker run --rm cpp)" # echo "$TEST" # test pyethereum @@ -13,7 +13,7 @@ do #RESULT_PYTHON=$? # test go - OUTPUT_GO="$(ethtest "$TEST")" + OUTPUT_GO="$(docker run --rm go "$TEST")" RESULT_GO=$? # test cpp-jit From 6bb10ccc3b0b396d3f1a09e7c4c9653c177ea58d Mon Sep 17 00:00:00 2001 From: sveneh Date: Wed, 14 Jan 2015 18:06:28 +0100 Subject: [PATCH 4/4] fixed testrunner --- ansible/roles/testrunner/tasks/main.yml | 10 ++++++++++ ansible/test-files/testrunner.sh | 1 + 2 files changed, 11 insertions(+) mode change 100644 => 100755 ansible/test-files/testrunner.sh diff --git a/ansible/roles/testrunner/tasks/main.yml b/ansible/roles/testrunner/tasks/main.yml index 54f7fc5fbb..dd71e79b7e 100644 --- a/ansible/roles/testrunner/tasks/main.yml +++ b/ansible/roles/testrunner/tasks/main.yml @@ -1,6 +1,16 @@ --- +- name: update C++ client + docker_image: + path: git/ansible/test-files/docker-cpp + name: cpp + state: build + - name: update Go client docker_image: path: git/ansible/test-files/docker-go name: go state: build + +- name: Run infinite tests (press ^C to stop) + sudo: true + shell: git/ansible/test-files/testrunner.sh diff --git a/ansible/test-files/testrunner.sh b/ansible/test-files/testrunner.sh old mode 100644 new mode 100755 index dabea7fb38..2c9608dd47 --- a/ansible/test-files/testrunner.sh +++ b/ansible/test-files/testrunner.sh @@ -52,4 +52,5 @@ fi # echo "$TEST" > FailedTest.json # mv FailedTest.json $(date -d "today" +"%Y%m%d%H%M")CPPJIT.json #fi +done