Skip to content

Latest commit

 

History

History
123 lines (89 loc) · 4.12 KB

DEVELOP.md

File metadata and controls

123 lines (89 loc) · 4.12 KB

How to develop MOCO

Running tests

MOCO has the following 4 kinds of tests:

  1. Tests that do not depend on MySQL or Kubernetes
  2. pkg/dbop and pkg/bkop tests that depend on MySQL version
  3. Tests that depend on Kubernetes and therefore run by controller-runtime's envtest
  4. End-to-end tests

To run these tests, use the following make targets respectively:

  1. make test
  2. make test-dbop test-bkop
  3. make envtest
  4. Read e2e/README.md

MOCO supports multiple MySQL versions. The three MySQL versions always used by CI are Cybozu internal use version, the latest, and one version before the latest. Other supported MySQL versions will be tested only in Weekly.

Generated files

Some files in the repository are auto-generated.

  • docs/crd_*.md are generated by make apidoc.
  • Some files under config are generated by make manifests.
  • api/**/*.deepcopy.go are generated by make generate.

CI checks and fails if they need to be rebuilt.

Testing with unreleased moco-agent

MOCO depends on moco-agent that is released from a different repository. The dependency is therefore managed in go.mod file.

To run e2e tests with an unreleased moco-agent, follow the instructions in e2e/README.md.

In case you need to use the new API set of unreleased moco-agent, use replace directive in go.mod to reference the local source code.

Updating MySQL binaries in moco-backup

Edit the following lines in Dockerfile:

# The tag should be the latest one
FROM ghcr.io/cybozu-go/moco/mysql:8.0.34.1 as mysql

# See the below description for how to get the version string.
ARG MYSQLSH_VERSION=8.0.34-1

The MySQL shell debian package can be found in https://dev.mysql.com/downloads/shell/ .

  1. Choose "Ubuntu Linux"
  2. Choose mysql-shell_*ubuntu*_amd64.deb (not a dbgsym image) and click "Download" button.
  3. Copy the URL from the link whose text reads No thanks, just start my download..
  4. Update MYSQLSH_VERSION in Dockerfile.

Updating tools used for tests

Edit Makefile and e2e/Makefile. Tool versions are defined at the top of them.

Adding or dropping supported software versions

Edit matrix strategies in .github/workflows/ci.yaml. Also, don't forget to update README.md.

MySQL versions appear twice:

  dbtest:
    name: Integration tests with MySQL
    strategy:
      matrix:
        mysql-version: ["8.0.18", "8.0.25", "8.0.26", "8.0.27", "8.0.28", "8.0.30", "8.0.31", "8.0.32", "8.0.33", "8.0.34"]
...
  # Matrix tests for the latest MySQL version on different Kubernetes versions.
  e2e:
    name: Supported Kubernetes versions End-to-End Tests
    strategy:
      matrix:
        mysql-version: ["8.0.34"]
        k8s-version: ["1.19.11", "1.20.7", "1.21.1"]
...
  # Matrix tests for different MySQL versions on the latest supported Kubernetes version.
  e2e-mysql:
    name: Supported MySQL versions End-to-End Tests
    strategy:
      matrix:
        mysql-version: ["8.0.18", "8.0.25", "8.0.26", "8.0.27", "8.0.28", "8.0.30", "8.0.31", "8.0.32", "8.0.33", "8.0.34"]
        k8s-version: ["1.21.1"]

Updating moco-agent

Run go get github.com/cybozu-go/moco-agent@latest.

Updating fluent-bit

Edit FluentBitImage in version.go.

Updating mysqld_exporter

Edit ExporterImage in version.go.