Skip to content

Run localtests via docker#858

Closed
ajm188 wants to merge 7 commits intogithub:masterfrom
ajm188:am_itest
Closed

Run localtests via docker#858
ajm188 wants to merge 7 commits intogithub:masterfrom
ajm188:am_itest

Conversation

@ajm188
Copy link
Contributor

@ajm188 ajm188 commented Jul 6, 2020

Related issue: #857

Description

This PR adds support for running localtests via docker.

It adds:

  • Dockerfile.itest -- set up with dbdeployer and ready to run tests
  • script/itest -- wrapper that builds gh-ost from source, builds the itest container and runs it
  • itest.sh -- thing that actually runs the tests, expects to only be run in the itest container

Testing

Example output: https://gist.github.com/ajm188/c83312ef82f06d51ca1f182c22b45d28

@ajm188 ajm188 changed the title Am itest Run localtests via docker Jul 6, 2020
Copy link
Contributor

@shlomi-noach shlomi-noach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for working on this! I did leave a few (non trivial) requests for changes. TL;DR remove code duplication, use gh-ost-ci-env repo, remove assumptions about binary being up to date.

RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates \
mysql-server-${MYSQL_VERSION_APT} \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need mysql-server? We are using dbdeployer-based server, right?

wget \
&& apt-get autoremove

RUN wget https://github.com/datacharmer/dbdeployer/releases/download/v${DBDEPLOYER_VERSION}/dbdeployer-${DBDEPLOYER_VERSION}.linux.tar.gz \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be willing to use https://github.com/github/gh-ost-ci-env for:

  • getting dbdeployer
  • getting the various MySQL server versions?

This way both this docker image and the migration tests CI job will use the exact same dbdeployer+mysql versions. Please see how https://github.com/github/gh-ost/blob/master/.github/workflows/replica-tests.yml pulls the binaries.

fi

echo "Creating replication sandbox"
dbdeployer deploy replication $MYSQL_VERSION \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets up one master, two replicas (the default for dbdeployer replication setup). Let's save time and memory and set up a single replica, instead. Again, see https://github.com/github/gh-ost/blob/master/script/cibuild-gh-ost-replica-tests:

gh-ost-ci-env/bin/linux/dbdeployer deploy replication "$mysql_version" --nodes 2 --sandbox-binary ${PWD}/sandbox/binary --sandbox-home ${PWD}/sandboxes ${gtid} --my-cnf-options log_slave_updates --my-cnf-options log_bin --my-cnf-options binlog_format=ROW --sandbox-directory rsandbox

@@ -0,0 +1,219 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a lot of duplication from https://github.com/github/gh-ost/blob/master/script/cibuild-gh-ost-replica-tests

Can we instead just call https://github.com/github/gh-ost/blob/master/script/cibuild-gh-ost-replica-tests? Or refactor into a more generic script? There's otherwise too much duplication; the entire test logic is rewritten here; I'd like to see both Docker and the GitHub CI use the same code.

packages_path="${2:-/tmp/gh-ost-release}"
docker_target="gh-ost-packaging"
docker build . -f Dockerfile.packaging -t "${docker_target}" && docker run --rm -it -v "${packages_path}:/tmp/pkg" "${docker_target}:latest" bash -c 'find /tmp/gh-ost-release/ -maxdepth 1 -type f | xargs cp -t /tmp/pkg'
docker build . -f Dockerfile.packaging -t "${docker_target}" && docker run --rm -it --mount type=bind,source="${packages_path}",target=/tmp/pkg "${docker_target}:latest" bash -c 'find /tmp/gh-ost-release/ -maxdepth 1 -type f | xargs cp -t /tmp/pkg'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please explain this change?

#
# Wrapper for running integration tests in docker.

./script/dock pkg $(pwd)/bin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to assume that the gh-ost binary in $(pwd)/bin is up to date and built from the current branch/changes. This may not be the case.

@ajm188
Copy link
Contributor Author

ajm188 commented Jul 21, 2020

I haven't forgotten about this! I should have time later this week.

@meiji163
Copy link
Contributor

meiji163 commented Apr 9, 2025

Closing because dbdeployer is deprecated (#1529)

@meiji163 meiji163 closed this Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants