From patchwork Thu Dec 1 19:24:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1711126 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNQxM0c1Tz23nB for ; Fri, 2 Dec 2022 06:24:21 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 45EF260FA9; Thu, 1 Dec 2022 19:24:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 45EF260FA9 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aSuZ0zAZEAGu; Thu, 1 Dec 2022 19:24:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5FE9060E3C; Thu, 1 Dec 2022 19:24:17 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5FE9060E3C Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 313A5C0032; Thu, 1 Dec 2022 19:24:17 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 70EC1C002D for ; Thu, 1 Dec 2022 19:24:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 56C6D418C8 for ; Thu, 1 Dec 2022 19:24:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 56C6D418C8 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2oOTtgBV-6km for ; Thu, 1 Dec 2022 19:24:15 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9D0F0418BD Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by smtp4.osuosl.org (Postfix) with ESMTPS id 9D0F0418BD for ; Thu, 1 Dec 2022 19:24:14 +0000 (UTC) Received: (Authenticated sender: numans@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id F379720002; Thu, 1 Dec 2022 19:24:11 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Thu, 1 Dec 2022 14:24:04 -0500 Message-Id: <20221201192404.1918390-1-numans@ovn.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221201191238.1916669-1-numans@ovn.org> References: <20221201191238.1916669-1-numans@ovn.org> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn 1/2] CI: Add a couple of jobs using ovn-fake-multinode. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique This patch adds a couple of jobs using ovn-fake-multinode. It first builds 2 ovn-fake-multinode container images - one with OVN 22.03 - one with present main. The first job deploys ovn-fake-multinode with the main OVN and runs simple tests provided by ovn-fake-multinode [1]. The second job deploys ovn-fake-multinode setup with the central image using OVN 22.03 and chassis image using main OVN. This job tests the scenario - ovn-northd and OVN dbs are running the most recent LTS. - ovn-controller is running the latest commit from the branch. [1] - https://github.com/ovn-org/ovn-fake-multinode/blob/main/.ci/test_basic.sh Signed-off-by: Numan Siddique --- .../workflows/ovn-fake-multinode-tests.yml | 151 ++++++++++++++++++ Makefile.am | 1 + 2 files changed, 152 insertions(+) create mode 100644 .github/workflows/ovn-fake-multinode-tests.yml diff --git a/.github/workflows/ovn-fake-multinode-tests.yml b/.github/workflows/ovn-fake-multinode-tests.yml new file mode 100644 index 000000000..3727b9835 --- /dev/null +++ b/.github/workflows/ovn-fake-multinode-tests.yml @@ -0,0 +1,151 @@ +name: System tests using ovn-fake-multinode + +on: + push: + pull_request: + schedule: + # Run Sunday at midnight + - cron: '0 0 * * 0' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} + cancel-in-progress: true + +jobs: + build: + env: + RUNC_CMD: podman + OS_IMAGE: "fedora:36" + # https://github.com/actions/runner-images/issues/6282 + XDG_RUNTIME_DIR: '' + + name: Build ovn-fake-multinode image + runs-on: ubuntu-20.04 + steps: + - name: Check out ovn-fake-multi-node + uses: actions/checkout@v3 + with: + repository: 'ovn-org/ovn-fake-multinode' + path: 'ovn-fake-multinode' + ref: 'v0.1' + + - name: Check out ovn + uses: actions/checkout@v3 + with: + path: 'ovn-fake-multinode/ovn' + submodules: recursive + + - name: Check out ovs master + uses: actions/checkout@v3 + with: + path: 'ovn-fake-multinode/ovs' + repository: 'openvswitch/ovs' + ref: 'master' + + - name: Install dependencies + run: | + sudo apt update + sudo apt-get install -y podman + + - name: Build ovn-fake-multi-node main image + run: | + set -x + cd ovn-fake-multinode + sudo -E ./ovn_cluster.sh build + mkdir -p /tmp/_output + sudo podman save ovn/ovn-multi-node:latest > /tmp/_output/ovn_main_image.tar + + - name: Build ovn-fake-multi-node 22.03 image + run: | + set -x + cd ovn-fake-multinode/ovn + git fetch origin + git checkout -b branch-22.03 origin/branch-22.03 + git status + cd .. + sudo -E ./ovn_cluster.sh build + mkdir -p /tmp/_output + sudo podman tag ovn/ovn-multi-node:latest ovn/ovn-multi-node:22.03 + sudo podman save ovn/ovn-multi-node:22.03 > /tmp/_output/ovn_22_03_image.tar + + - uses: actions/upload-artifact@v3 + with: + name: test-main-image + path: /tmp/_output/ovn_main_image.tar + + - uses: actions/upload-artifact@v3 + with: + name: test-22-03-image + path: /tmp/_output/ovn_22_03_image.tar + + multinode-tests: + runs-on: ubuntu-20.04 + timeout-minutes: 120 + env: + RUNC_CMD: podman + OS_IMAGE: "fedora:36" + CENTRAL_IMAGE: ${{ matrix.cfg.central_image }} + ENABLE_SSL: no + # https://github.com/actions/runner-images/issues/6282 + XDG_RUNTIME_DIR: '' + + name: multinode tests ${{ join(matrix.cfg.*, ' ') }} + needs: [build] + strategy: + fail-fast: false + matrix: + cfg: + - { central_image: "ovn/ovn-multi-node:latest" } + - { central_image: "ovn/ovn-multi-node:22.03" } + + steps: + + - name: Free up disk space + run: sudo eatmydata apt-get remove --auto-remove -y aspnetcore-* dotnet-* libmono-* mono-* msbuild php-* php7* ghc-* zulu-* + + - uses: actions/download-artifact@v3 + with: + name: test-main-image + + - uses: actions/download-artifact@v3 + with: + name: test-22-03-image + + - name: Load podman image + run: | + sudo podman load --input ovn_main_image.tar + sudo podman load --input ovn_22_03_image.tar + + - name: Check out ovn-fake-multi-node + uses: actions/checkout@v3 + with: + repository: 'ovn-org/ovn-fake-multinode' + path: 'ovn-fake-multinode' + ref: 'v0.1' + + - name: Install dependencies + run: | + sudo apt update + sudo apt-get install -y podman openvswitch-switch + sudo systemctl start openvswitch-switch + sudo ovs-vsctl show + + - name: Start basic cluster + run: | + pwd + ls -l + cd ovn-fake-multinode + sudo -E ./ovn_cluster.sh start + sudo podman exec -it ovn-central ovn-nbctl show + sudo podman exec -it ovn-central ovn-appctl -t ovn-northd version + sudo podman exec -it ovn-chassis-1 ovn-appctl -t ovn-controller version + + - name: Run basic test script + run: | + cd ovn-fake-multinode + sudo ./.ci/test_basic.sh + + - name: Stop cluster + run: | + cd ovn-fake-multinode + sudo -E ./ovn_cluster.sh stop diff --git a/Makefile.am b/Makefile.am index 3b0df8393..6c3baa21c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -93,6 +93,7 @@ EXTRA_DIST = \ .ci/ovn-kubernetes/Dockerfile \ .github/workflows/test.yml \ .github/workflows/ovn-kubernetes.yml \ + .github/workflows/ovn-fake-multinode-tests.yml \ boot.sh \ $(MAN_FRAGMENTS) \ $(MAN_ROOTS) \ From patchwork Thu Dec 1 19:13:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1711125 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NNQhs5Wgvz23nC for ; Fri, 2 Dec 2022 06:13:33 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 52B3480C53; Thu, 1 Dec 2022 19:13:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 52B3480C53 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MRwpa3bnNfCw; Thu, 1 Dec 2022 19:13:29 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 74E07820EB; Thu, 1 Dec 2022 19:13:28 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 74E07820EB Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4A0F0C0032; Thu, 1 Dec 2022 19:13:28 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7CF00C002D for ; Thu, 1 Dec 2022 19:13:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 581C7820E7 for ; Thu, 1 Dec 2022 19:13:26 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 581C7820E7 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VNnrpOxiTIwF for ; Thu, 1 Dec 2022 19:13:23 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A19F8820E6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.osuosl.org (Postfix) with ESMTPS id A19F8820E6 for ; Thu, 1 Dec 2022 19:13:22 +0000 (UTC) Received: (Authenticated sender: numans@ovn.org) by mail.gandi.net (Postfix) with ESMTPSA id 9CB8E60002; Thu, 1 Dec 2022 19:13:18 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Thu, 1 Dec 2022 14:13:14 -0500 Message-Id: <20221201191314.1916813-1-numans@ovn.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221201191238.1916669-1-numans@ovn.org> References: <20221201191238.1916669-1-numans@ovn.org> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn 2/2] Add fake multinode system tests. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique This patch adds a simple system test using ovn-fake-multinode setup. The tests can be run as - 'make check-multinode' Before running these tests, user should deploy fake_multinode setup by running 'ovn_cluster.sh start'. This test suite is also triggered for the newly added fake multinode CI job. The fake multinode system tests suite can be enhanced further for new features and to cover multi node scenarios. Signed-off-by: Numan Siddique --- .../workflows/ovn-fake-multinode-tests.yml | 57 ++++++ tests/automake.mk | 28 ++- tests/multinode-macros.at | 189 ++++++++++++++++++ tests/multinode-testsuite.at | 27 +++ tests/multinode.at | 74 +++++++ 5 files changed, 374 insertions(+), 1 deletion(-) create mode 100644 tests/multinode-macros.at create mode 100644 tests/multinode-testsuite.at create mode 100644 tests/multinode.at diff --git a/.github/workflows/ovn-fake-multinode-tests.yml b/.github/workflows/ovn-fake-multinode-tests.yml index 3727b9835..c24eb2965 100644 --- a/.github/workflows/ovn-fake-multinode-tests.yml +++ b/.github/workflows/ovn-fake-multinode-tests.yml @@ -86,6 +86,12 @@ jobs: OS_IMAGE: "fedora:36" CENTRAL_IMAGE: ${{ matrix.cfg.central_image }} ENABLE_SSL: no + CC: gcc + OPTS: "--disable-ssl" + dependencies: | + automake libtool gcc bc libjemalloc2 libjemalloc-dev \ + libssl-dev llvm-dev libelf-dev libnuma-dev libpcap-dev \ + selinux-policy-dev ncat python3-scapy isc-dhcp-server # https://github.com/actions/runner-images/issues/6282 XDG_RUNTIME_DIR: '' @@ -145,6 +151,57 @@ jobs: cd ovn-fake-multinode sudo ./.ci/test_basic.sh + - name: install required dependencies + run: sudo apt install -y ${{ env.dependencies }} + + - name: install libunbound libunwind + run: sudo apt install -y libunbound-dev libunwind-dev + + - name: update PATH + run: | + echo "$HOME/bin" >> $GITHUB_PATH + echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: set up python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Check out ovn + uses: actions/checkout@v3 + with: + path: 'ovn' + submodules: recursive + + - name: Build OVN and trigger fake-multinode system tests + run: | + set -x + cd ovn + ./.ci/linux-prepare.sh + ./.ci/linux-build.sh + sudo make check-multinode + + - name: copy logs on failure + if: failure() || cancelled() + run: | + # upload-artifact@v3 throws exceptions if it tries to upload socket + # files and we could have some socket files in testsuite.dir. + # Also, upload-artifact@v3 doesn't work well enough with wildcards. + # So, we're just archiving everything here to avoid any issues. + mkdir logs + cp ovn/config.log ./logs/ + # multinode tests are run as root, need to adjust permissions. + sudo chmod -R +r ovn/tests/multinode-testsuite.dir.* || true + cp -r ovn/tests/multinode-testsuite.dir.* ./logs/ || true + tar -czvf logs.tgz logs/ + + - name: upload logs on failure + if: failure() || cancelled() + uses: actions/upload-artifact@v3 + with: + name: logs-linux-${{ join(matrix.cfg.*, '-') }} + path: logs.tgz + - name: Stop cluster run: | cd ovn-fake-multinode diff --git a/tests/automake.mk b/tests/automake.mk index dce9c9108..88cda5f20 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -5,10 +5,12 @@ EXTRA_DIST += \ $(SYSTEM_KMOD_TESTSUITE_AT) \ $(SYSTEM_USERSPACE_TESTSUITE_AT) \ $(PERF_TESTSUITE_AT) \ + $(MULTINODE_TESTSUITE_AT) \ $(TESTSUITE) \ $(SYSTEM_KMOD_TESTSUITE) \ $(SYSTEM_USERSPACE_TESTSUITE) \ $(PERF_TESTSUITE) \ + $(MULTINODE_TESTSUITE) \ tests/atlocal.in \ $(srcdir)/package.m4 \ $(srcdir)/tests/testsuite \ @@ -61,6 +63,11 @@ PERF_TESTSUITE_AT = \ tests/perf-testsuite.at \ tests/perf-northd.at +MULTINODE_TESTSUITE_AT = \ + tests/multinode-testsuite.at \ + tests/multinode-macros.at \ + tests/multinode.at + check_SCRIPTS += tests/atlocal TESTSUITE = $(srcdir)/tests/testsuite @@ -72,7 +79,9 @@ PERF_TESTSUITE = $(srcdir)/tests/perf-testsuite PERF_TESTSUITE_DIR = $(abs_top_builddir)/tests/perf-testsuite.dir PERF_TESTSUITE_RESULTS = $(PERF_TESTSUITE_DIR)/results DISTCLEANFILES += tests/atconfig tests/atlocal - +MULTINODE_TESTSUITE = $(srcdir)/tests/multinode-testsuite +MULTINODE_TESTSUITE_DIR = $(abs_top_builddir)/tests/multinode-testsuite.dir +MULTINODE_TESTSUITE_RESULTS = $(MULTINODE_TESTSUITE_DIR)/results AUTOTEST_PATH = $(ovs_builddir)/utilities:$(ovs_builddir)/vswitchd:$(ovs_builddir)/ovsdb:$(ovs_builddir)/vtep:tests:$(PTHREAD_WIN32_DIR_DLL):$(SSL_DIR):controller-vtep:northd:utilities:controller:ic export ovs_srcdir @@ -82,6 +91,7 @@ check-local: "$$@" $(TESTSUITEFLAGS) || \ (test -z "$$(find $(TESTSUITE_DIR) -name 'sanitizers.*')" && \ test X'$(RECHECK)' = Xyes && "$$@" --recheck) + # Python Coverage support. # Requires coverage.py http://nedbatchelder.com/code/coverage/. @@ -197,6 +207,18 @@ check-perf: all @echo @echo "Results can be found in $(PERF_TESTSUITE_RESULTS)" +check-multinode: all + @mkdir -p $(MULTINODE_TESTSUITE_DIR) + @echo > $(MULTINODE_TESTSUITE_RESULTS) + set $(SHELL) '$(MULTINODE_TESTSUITE)' -C tests AUTOTEST_PATH='$(AUTOTEST_PATH)'; \ + "$$@" $(TESTSUITEFLAGS) -j1 || (test X'$(RECHECK)' = Xyes && "$$@" --recheck) + @echo + @echo '## -------------------- ##' + @echo '## Multinode test Results ##' + @echo '## -------------------- ##' + @cat $(MULTINODE_TESTSUITE_RESULTS) + @echo + @echo "Results can be found in $(MULTINODE_TESTSUITE_RESULTS)" AUTOTEST = $(AUTOM4TE) --language=autotest @@ -223,6 +245,10 @@ $(PERF_TESTSUITE): package.m4 $(PERF_TESTSUITE_AT) $(COMMON_MACROS_AT) $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at $(AM_V_at)mv $@.tmp $@ +$(MULTINODE_TESTSUITE): package.m4 $(MULTINODE_TESTSUITE_AT) $(COMMON_MACROS_AT) + $(AM_V_GEN)$(AUTOTEST) -I '$(srcdir)' -o $@.tmp $@.at + $(AM_V_at)mv $@.tmp $@ + # The `:;' works around a Bash 3.2 bug when the output is not writeable. $(srcdir)/package.m4: $(top_srcdir)/configure.ac $(AM_V_GEN):;{ \ diff --git a/tests/multinode-macros.at b/tests/multinode-macros.at new file mode 100644 index 000000000..88a3816eb --- /dev/null +++ b/tests/multinode-macros.at @@ -0,0 +1,189 @@ +# +# + +# M_NS_EXEC([fake_node], [namespace], [command]) +# +# Execute 'command' in 'namespace' +m4_define([M_NS_EXEC], + [podman exec $1 ip netns exec $2 $3]) + +# M_NS_CHECK_EXEC(fake_node], [namespace], [command], other_params...) +# +# Wrapper for AT_CHECK that executes 'command' inside 'fake_node''s namespace'. +# 'other_params' as passed as they are to AT_CHECK. +m4_define([M_NS_CHECK_EXEC], + [ AT_CHECK([M_NS_EXEC([$1], [$2], [$3])], m4_shift(m4_shift(m4_shift($@)))) ] +) + +OVS_START_SHELL_HELPERS + +m_as() { + c=$1 + shift + podman exec $c "$@" +} + +m_central_as () { + podman exec ovn-central "$@" +} + +check_fake_multinode_setup() { + check m_as ovn-central ovn-nbctl --wait=hv sync + AT_CHECK([m_as ovn-chassis-1 ovn-appctl -t ovn-controller version], [0], [ignore]) + AT_CHECK([m_as ovn-chassis-2 ovn-appctl -t ovn-controller version], [0], [ignore]) + AT_CHECK([m_as ovn-gw-1 ovn-appctl -t ovn-controller version], [0], [ignore]) +} + +cleanup_multinode_resources() { + m_as ovn-central rm -f /etc/ovn/ovnnb_db.db + m_as ovn-central /usr/share/ovn/scripts/ovn-ctl restart_northd + check m_as ovn-central ovn-nbctl --wait=hv sync + for c in ovn-chassis-1 ovn-chassis-2 ovn-gw-1 + do + m_as $c ovs-vsctl del-br br-int + m_as $c ip --all netns delete + done +} + +multinode_nbctl () { + m_as ovn-central ovn-nbctl "$@" +} + +# count_rows TABLE [CONDITION...] +# +# Prints the number of rows in TABLE (that satisfy CONDITION). +# Uses the southbound db by default; set DB=nb for the northbound database. +m_count_rows() { + local db=$(parse_db $1) table=$(parse_table $1); shift + m_central_as ovn-${db}ctl --format=table --no-headings find $table "$@" | wc -l +} + +# check_row_count [DATABASE:]TABLE COUNT [CONDITION...] +# +# Checks that TABLE contains COUNT rows (that satisfy CONDITION). +# The default DATABASE is "sb". +m_check_row_count() { + local db=$(parse_db $1) table=$(parse_table $1); shift + local count=$1; shift + local found=$(m_count_rows $c $db:$table "$@") + echo + echo "Checking for $count rows in $db $table${1+ with $*}... found $found" + if test "$count" != "$found"; then + m_central_as ovn-${db}ctl list $table + AT_FAIL_IF([:]) + fi +} + +# wait_row_count [DATABASE:]TABLE COUNT [CONDITION...] +# +# Waits until TABLE contains COUNT rows (that satisfy CONDITION). +# The default DATABASE is "sb". +m_wait_row_count() { + local db=$(parse_db $1) table=$(parse_table $1); shift + local count=$1; shift + local a=$1 b=$2 c=$3 d=$4 e=$5 + echo "Waiting until $count rows in $db $table${1+ with $*}..." + OVS_WAIT_UNTIL([test $count = $(m_count_rows $db:$table $a $b $c $d $e)],[ + echo "$db table $table has the following rows. $(m_count_rows $db:$table $a $b $c $d $e) rows match instead of expected $count:" + m_central_as ovn-${db}ctl list $table]) +} + +# multinode_wait_column EXPECTED [DATABASE:]TABLE [COLUMN [CONDITION...]] +# +# Wait until all of the values of COLUMN in the rows of TABLE (that +# satisfy CONDITION) equal EXPECTED (ignoring order). +# +# The default DATABASE is "sb". +# +# COLUMN defaults to _uuid if unspecified. +m_wait_column() { + local expected=$(for d in $1; do echo $d; done | sort) + local db=$(parse_db $2) table=$(parse_table $2) column=${3-_uuid}; shift; shift; shift + local a=$1 b=$2 c=$3 d=$4 e=$5 + + echo + echo "Waiting until $column in $db $table${1+ with $*} is $expected..." + OVS_WAIT_UNTIL([ + found=$(m_central_as ovn-${db}ctl --bare --columns $column find $table $a $b $c $d $e) + found=$(for d in $found; do echo $d; done | sort) + test "$expected" = "$found" + ], [ + echo "$column in $db table $table has value $found, from the following rows:" + m_central_as ovn-${db}ctl list $table]) +} + +# fetch_column [DATABASE:]TABLE COLUMN [CONDITION...] +# +# Fetches and prints all the values of COLUMN in the rows of TABLE +# (that satisfy CONDITION), sorting the results lexicographically. +# The default DATABASE is "sb". +m_fetch_column() { + local db=$(parse_db $1) table=$(parse_table $1) column=${2-_uuid}; shift; shift + # Using "echo" removes spaces and newlines. + echo $(m_central_as ovn-${db}ctl --bare --columns $column find $table "$@" | sort) +} + +# check_column EXPECTED [DATABASE:]TABLE COLUMN [CONDITION...] +# +# Fetches all of the values of COLUMN in the rows of TABLE (that +# satisfy CONDITION), and compares them against EXPECTED (ignoring +# order). +# +# The default DATABASE is "sb". +m_check_column() { + local expected=$1 db=$(parse_db $2) table=$(parse_table $2) column=${3-_uuid}; shift; shift; shift + local found=$(m_central_as ovn-${db}ctl --bare --columns $column find $table "$@") + + # Sort the expected and found values. + local found=$(for d in $found; do echo $d; done | sort) + local expected=$(for d in $expected; do echo $d; done | sort) + + echo + echo "Checking values in $db $table${1+ with $*} against $expected... found $found" + if test "$found" != "$expected"; then + m_central_as ovn-${db}ctl list $table + AT_FAIL_IF([:]) + fi +} + +# wait_column EXPECTED [DATABASE:]TABLE [COLUMN [CONDITION...]] +# +# Wait until all of the values of COLUMN in the rows of TABLE (that +# satisfy CONDITION) equal EXPECTED (ignoring order). +# +# The default DATABASE is "sb". +# +# COLUMN defaults to _uuid if unspecified. +m_wait_column() { + local expected=$(for d in $1; do echo $d; done | sort) + local db=$(parse_db $2) table=$(parse_table $2) column=${3-_uuid}; shift; shift; shift + local a=$1 b=$2 c=$3 d=$4 e=$5 + + echo + echo "Waiting until $column in $db $table${1+ with $*} is $expected..." + OVS_WAIT_UNTIL([ + found=$(m_central_as ovn-${db}ctl --bare --columns $column find $table $a $b $c $d $e) + found=$(for d in $found; do echo $d; done | sort) + test "$expected" = "$found" + ], [ + echo "$column in $db table $table has value $found, from the following rows:" + m_central_as ovn-${db}ctl list $table]) +} + +# wait_for_ports_up [PORT...] +# +# With arguments, waits for specified Logical_Switch_Ports to come up. +# Without arguments, waits for all "plain" and router +# Logical_Switch_Ports to come up. +m_wait_for_ports_up() { + if test $# = 0; then + m_wait_row_count nb:Logical_Switch_Port 0 up!=true type='""' + m_wait_row_count nb:Logical_Switch_Port 0 up!=true type=router + else + for port; do + m_wait_row_count nb:Logical_Switch_Port 1 up=true name=$port + done + fi +} + +OVS_END_SHELL_HELPERS diff --git a/tests/multinode-testsuite.at b/tests/multinode-testsuite.at new file mode 100644 index 000000000..ea10b0276 --- /dev/null +++ b/tests/multinode-testsuite.at @@ -0,0 +1,27 @@ +AT_INIT + +AT_COPYRIGHT([Copyright (c) 2022 Red Hat, + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at: + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License.]) + +m4_ifdef([AT_COLOR_TESTS], [AT_COLOR_TESTS]) +AT_ARG_OPTION([rebuild], [Do not use cached versions of databases]) + +m4_include([tests/ovs-macros.at]) +m4_include([tests/ovsdb-macros.at]) +m4_include([tests/ofproto-macros.at]) +m4_include([tests/ovn-macros.at]) +m4_include([tests/system-common-macros.at]) +m4_include([tests/multinode-macros.at]) + +m4_include([tests/multinode.at]) diff --git a/tests/multinode.at b/tests/multinode.at new file mode 100644 index 000000000..754e488d6 --- /dev/null +++ b/tests/multinode.at @@ -0,0 +1,74 @@ +AT_BANNER([ovn multinode system tests using ovn-fake-multinode]) + +AT_SETUP([ovn multinode basic test]) + +# Check that ovn-fake-multinode setup is up and running +check_fake_multinode_setup + +# Delete the multinode NB and OVS resources before starting the test. +cleanup_multinode_resources + +# Test East-West switching +check multinode_nbctl ls-add sw0 +check multinode_nbctl lsp-add sw0 sw0-port1 +check multinode_nbctl lsp-set-addresses sw0-port1 "50:54:00:00:00:03 10.0.0.3 1000::3" +check multinode_nbctl lsp-add sw0 sw0-port2 +check multinode_nbctl lsp-set-addresses sw0-port2 "50:54:00:00:00:04 10.0.0.4 1000::4" + +m_as ovn-chassis-1 /data/create_fake_vm.sh sw0-port1 sw0p1 50:54:00:00:00:03 10.0.0.3 24 10.0.0.1 1000::3/64 1000::a +m_as ovn-chassis-2 /data/create_fake_vm.sh sw0-port2 sw0p2 50:54:00:00:00:04 10.0.0.4 24 10.0.0.1 1000::4/64 1000::a + +m_wait_for_ports_up + +M_NS_CHECK_EXEC([ovn-chassis-1], [sw0p1], [ping -q -c 3 -i 0.3 -w 2 10.0.0.4 | FORMAT_PING], \ +[0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +# Add ACLs to drop all traffic +check multinode_nbctl pg-add pg0 sw0-port1 sw0-port2 +check multinode_nbctl acl-add pg0 to-lport 1001 "outport == @pg0 && ip4" drop +check multinode_nbctl --wait=hv sync + +M_NS_CHECK_EXEC([ovn-chassis-1], [sw0p1], [ping -q -c 3 -i 0.3 -w 2 10.0.0.4], \ +[1], [ignore]) + +# Add ACLs to allow icmp traffic +check multinode_nbctl acl-add pg0 to-lport 1002 "outport == @pg0 && ip4 && icmp" allow-related +check multinode_nbctl --wait=hv sync + +M_NS_CHECK_EXEC([ovn-chassis-1], [sw0p1], [ping -q -c 3 -i 0.3 -w 2 10.0.0.4 | FORMAT_PING], \ +[0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + + +# Create the second logical switch with one port +check multinode_nbctl ls-add sw1 +check multinode_nbctl lsp-add sw1 sw1-port1 +check multinode_nbctl lsp-set-addresses sw1-port1 "40:54:00:00:00:03 20.0.0.3 2000::3" + +# Create a logical router and attach both logical switches +check multinode_nbctl lr-add lr0 +check multinode_nbctl lrp-add lr0 lr0-sw0 00:00:00:00:ff:01 10.0.0.1/24 1000::a/64 +check multinode_nbctl lsp-add sw0 sw0-lr0 +check multinode_nbctl lsp-set-type sw0-lr0 router +check multinode_nbctl lsp-set-addresses sw0-lr0 router +check multinode_nbctl lsp-set-options sw0-lr0 router-port=lr0-sw0 + +check multinode_nbctl lrp-add lr0 lr0-sw1 00:00:00:00:ff:02 20.0.0.1/24 2000::a/64 +check multinode_nbctl lsp-add sw1 sw1-lr0 +check multinode_nbctl lsp-set-type sw1-lr0 router +check multinode_nbctl lsp-set-addresses sw1-lr0 router +check multinode_nbctl lsp-set-options sw1-lr0 router-port=lr0-sw1 + +m_as ovn-chassis-2 /data/create_fake_vm.sh sw1-port1 sw1p1 40:54:00:00:00:03 20.0.0.3 24 20.0.0.1 2000::4/64 1000::a + +m_wait_for_ports_up sw1-port1 + +M_NS_CHECK_EXEC([ovn-chassis-1], [sw0p1], [ping -q -c 3 -i 0.3 -w 2 20.0.0.3 | FORMAT_PING], \ +[0], [dnl +3 packets transmitted, 3 received, 0% packet loss, time 0ms +]) + +AT_CLEANUP