diff --git a/README.md b/README.md index d1da32460..8bdfd882b 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,8 @@ To run full set of tests: mage testfull ``` +To run integration test in containersed environment see `/test/docker/README.md`. + ### Commit changes The project uses [pre-commit](https://pre-commit.com/) to check code before committing. diff --git a/TEMP_run_local_tests.md b/TEMP_run_local_tests.md new file mode 100644 index 000000000..f101f4f5e --- /dev/null +++ b/TEMP_run_local_tests.md @@ -0,0 +1,13 @@ +# build image +sudo docker build -t tt_test . +# run +docker network create --ipv6 --subnet fd01::/64 my-ipv6-network +sudo docker run -it --security-opt seccomp=unconfined --network my-ipv6-network --name tt_test_run tt_test /bin/bash + + +container cmd: +mage integration + +# delete tmp +sudo docker rm tt_test_run +sudo docker rmi tt_test \ No newline at end of file diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile new file mode 100644 index 000000000..489d45d14 --- /dev/null +++ b/test/docker/Dockerfile @@ -0,0 +1,7 @@ +FROM tt_integration_test_base +COPY . /tt + +WORKDIR /tt +RUN git submodule update --init --recursive +ENV PATH="${PATH}:/root/go/bin:/go/bin:/tt" +RUN mage build diff --git a/test/docker/Dockerfile_base b/test/docker/Dockerfile_base new file mode 100644 index 000000000..ef7d30abb --- /dev/null +++ b/test/docker/Dockerfile_base @@ -0,0 +1,60 @@ +FROM ubuntu:22.04 +# default tarantool version +ARG TARANTOOL_VERSION=3.0.2 + +# versions of test environment +ENV GO_VERSION=1.25.7 +ENV ETCD_VERSION=v3.5.9 +ENV GOLANGCI_LINT_VERSION=v1.63.4 +ENV TARANTOOL_VERSION=${TARANTOOL_VERSION} +ENV GO_OS=linux +ENV GO_ARCH=amd64 + +ARG DEBIAN_FRONTEND=noninteractive +ENV TZ=Etc/UTC + +# setup Python +RUN apt update \ + && apt install -y software-properties-common curl tar \ + && add-apt-repository ppa:deadsnakes/ppa -y \ + && apt update + +RUN apt install -y python3.10 python3.10-dev python3.10-distutils python3.10-venv +RUN curl -O https://bootstrap.pypa.io/get-pip.py && python3.10 get-pip.py + +# setup Go +RUN curl -fsSL https://go.dev/dl/go${GO_VERSION}.${GO_OS}-${GO_ARCH}.tar.gz -o go.tar.gz && \ + tar -C /usr/local -xzf go.tar.gz && \ + rm go.tar.gz + +ENV PATH="/usr/local/go/bin:${PATH}" +# setup test environment +RUN curl -L https://my.tech.vk.com/download/tarantool/3/installer.sh | bash \ + && apt-get -y install tarantool=${TARANTOOL_VERSION}-1 \ + && apt-get -y install tarantool-dev=${TARANTOOL_VERSION}-1 + +RUN curl -L -O --retry 5 --retry-delay 5 --fail https://github.com/etcd-io/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz \ + && tar xzvf etcd-${ETCD_VERSION}-linux-amd64.tar.gz \ + && mv etcd-${ETCD_VERSION}-linux-amd64/etcd* /usr/local/bin/ +# install tt build requirements +RUN apt -y update \ + && apt -y install git gcc make cmake unzip zip rsync gdb libssl-dev bash-completion \ + && apt-get --allow-releaseinfo-change update \ + && apt-get -y -f install \ + build-essential ninja-build \ + lua5.1 luarocks lcov \ + ruby-dev liblz4-dev autoconf \ + automake libtool zsh fish \ + && luarocks install luacheck 0.26.1 \ + && gem install coveralls-lcov \ + && pip3 install tarantool + +# setup test environment +RUN go install github.com/magefile/mage@latest \ + && go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} +# Stop Mono server +RUN systemctl kill mono-xsp4 || true + +COPY ./test/requirements.txt /tt/test/requirements.txt +WORKDIR /tt +RUN pip3 install -r /tt/test/requirements.txt diff --git a/test/docker/README.md b/test/docker/README.md new file mode 100644 index 000000000..4382f5354 --- /dev/null +++ b/test/docker/README.md @@ -0,0 +1,9 @@ +# Running integration tests in a containerized environment + +The final image `tt_integration_test` includes all the necessary components to run the test. At the moment, only `mage integration` is functional. +1. Create a base image that contains all necessary infrastructure (Tarantool, Etcd, etc.). `docker build -f ./test/docker/Dockerfile_base -t tt_integration_test_base .` The default Tarantool version is 3.0.2. If you need a different version, use the `--build-arg` flag to specify the desired version. Example: `docker build --build-arg TARANTOOL_VERSION=3.8.0 -f ./test/docker/Dockerfile_base -t tt_integration_test_base .`. +2. Create an image that contains the current state of TT source files. This image is used for testing. Example: `docker build -f ./test/docker/Dockerfile -t tt_integration_test .`. +3. Create a subnet for the tests, as the tests require IPv6. Example: `sudo docker build -f ./test/docker/Dockerfile -t tt_integration_test .`. +4. Launch the test container with the following command: `docker run -it --security-opt seccomp=unconfined --network my-ipv6-network --name tt_test_run tt_integration_test /bin/bash`. +The `seccomp=unconfined` option is used to execute the unshare system call in the tests. +5) Run the `mage integration` test in container terminal. \ No newline at end of file