From dcf6fdb3c5b24bc3709650f111790f744076db56 Mon Sep 17 00:00:00 2001
From: mechanik20051988 <mechanik20.05.1988@gmail.com>
Date: Thu, 25 Mar 2021 11:44:28 +0300
Subject: [PATCH] tests: add ability to run box/engine tests with different
 allocators

The ability to select an allocator for memtx has been added to
tarantool. To test a new type of allocator, all tests must also
be run with it. Implemented new option, which allows to set allocator
for memtx. If you wan't to choose allocator type for tests, run test-run.py
with --memtx-allocator="small" or --memtx-allocator="system". Allocator type
is passed via MEMTX_ALLOCATOR environment variable to the test.
---
 .../memtx_allocator_based_on_malloc.yml       | 52 +++++++++++++++++++
 test/box/admin.result                         |  2 +-
 test/box/backup_test.lua                      |  6 ++-
 test/box/box.lua                              |  3 +-
 test/box/cfg.result                           |  4 +-
 test/box/gh-5422-broken_snapshot.lua          |  7 +--
 test/box/on_schema_init.lua                   |  3 +-
 test/box/tx_man.lua                           |  1 +
 test/engine/box.lua                           |  1 +
 9 files changed, 70 insertions(+), 9 deletions(-)
 create mode 100644 .github/workflows/memtx_allocator_based_on_malloc.yml

diff --git a/.github/workflows/memtx_allocator_based_on_malloc.yml b/.github/workflows/memtx_allocator_based_on_malloc.yml
new file mode 100644
index 0000000000..ff0bfb4502
--- /dev/null
+++ b/.github/workflows/memtx_allocator_based_on_malloc.yml
@@ -0,0 +1,52 @@
+name: memtx_allocator_based_on_malloc
+
+on:
+  push:
+  pull_request:
+  repository_dispatch:
+    types: [backend_automation]
+  workflow_dispatch:
+
+env:
+  CI_MAKE: make -f .travis.mk
+  TEST_RUN_EXTRA_PARAMS: --memtx-allocator=system
+
+jobs:
+  memtx_allocator_based_on_malloc:
+    # We want to run on external PRs, but not on our own internal PRs
+    # as they'll be run by the push to the branch.
+    if: ( github.event_name == 'push' ||
+        github.event.pull_request.head.repo.full_name != github.repository ) &&
+        ! endsWith(github.ref, '-notest')
+
+    runs-on: ubuntu-20.04
+
+    strategy:
+      fail-fast: false
+
+    # image built by .gitlab.mk instructions and targets from .travis.mk
+    container:
+      image: docker.io/tarantool/testing:debian-stretch
+      # Our testing expects that the init process (PID 1) will
+      # reap orphan processes. At least the following test leans
+      # on it: app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua.
+      options: '--init'
+
+    steps:
+      - uses: actions/checkout@v1
+      - uses: ./.github/actions/environment
+      - name: test
+        run: ${CI_MAKE} test_debian_no_deps
+      - name: call action to send Telegram message on failure
+        env:
+          TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_CORE_TOKEN }}
+          TELEGRAM_TO: ${{ secrets.TELEGRAM_CORE_TO }}
+        uses: ./.github/actions/send-telegram-notify
+        if: failure()
+      - name: artifacts
+        uses: actions/upload-artifact@v2
+        if: failure()
+        with:
+          name: memtx_allocator_based_on_malloc
+          retention-days: 21
+          path: test/var/artifacts
diff --git a/test/box/admin.result b/test/box/admin.result
index d852685de1..f3be0869bb 100644
--- a/test/box/admin.result
+++ b/test/box/admin.result
@@ -64,7 +64,7 @@ cfg_filter(box.cfg)
   - - log_level
     - 5
   - - memtx_allocator
-    - small
+    - <hidden>
   - - memtx_dir
     - <hidden>
   - - memtx_max_tuple_size
diff --git a/test/box/backup_test.lua b/test/box/backup_test.lua
index e725ae33f6..3b85e5ce2b 100644
--- a/test/box/backup_test.lua
+++ b/test/box/backup_test.lua
@@ -1,4 +1,8 @@
 #!/usr/bin/env tarantool
 
-box.cfg{listen = os.getenv("LISTEN")}
+box.cfg({
+    listen          = os.getenv("LISTEN"),
+    memtx_allocator = os.getenv("MEMTX_ALLOCATOR")
+})
+
 require('console').listen(os.getenv('ADMIN'))
diff --git a/test/box/box.lua b/test/box/box.lua
index 567583533d..6a3a393745 100644
--- a/test/box/box.lua
+++ b/test/box/box.lua
@@ -7,6 +7,7 @@ box.cfg{
     listen              = os.getenv("LISTEN"),
     memtx_memory        = 107374182,
     pid_file            = "tarantool.pid",
+    memtx_allocator     = os.getenv("MEMTX_ALLOCATOR")
 }
 
 require('console').listen(os.getenv('ADMIN'))
@@ -15,7 +16,7 @@ local _hide = {
     pid_file=1, log=1, listen=1, vinyl_dir=1,
     memtx_dir=1, wal_dir=1,
     memtx_max_tuple_size=1, memtx_min_tuple_size=1,
-    replication_sync_timeout=1
+    replication_sync_timeout=1, memtx_allocator=1
 }
 
 function cfg_filter(data)
diff --git a/test/box/cfg.result b/test/box/cfg.result
index ef24028b93..d2f2a8ddeb 100644
--- a/test/box/cfg.result
+++ b/test/box/cfg.result
@@ -52,7 +52,7 @@ cfg_filter(box.cfg)
  |   - - log_level
  |     - 5
  |   - - memtx_allocator
- |     - small
+ |     - <hidden>
  |   - - memtx_dir
  |     - <hidden>
  |   - - memtx_max_tuple_size
@@ -177,7 +177,7 @@ cfg_filter(box.cfg)
  |   - - log_level
  |     - 5
  |   - - memtx_allocator
- |     - small
+ |     - <hidden>
  |   - - memtx_dir
  |     - <hidden>
  |   - - memtx_max_tuple_size
diff --git a/test/box/gh-5422-broken_snapshot.lua b/test/box/gh-5422-broken_snapshot.lua
index 7fee178ff4..834ab38ca3 100644
--- a/test/box/gh-5422-broken_snapshot.lua
+++ b/test/box/gh-5422-broken_snapshot.lua
@@ -3,7 +3,8 @@
 require('console').listen(os.getenv('ADMIN'))
 
 box.cfg({
-    listen = os.getenv("LISTEN"),
-    force_recovery = true,
-    read_only = false,
+    listen          = os.getenv("LISTEN"),
+    force_recovery  = true,
+    read_only       = false,
+    memtx_allocator = os.getenv("MEMTX_ALLOCATOR")
 })
diff --git a/test/box/on_schema_init.lua b/test/box/on_schema_init.lua
index a10687a091..b7c7cb75e1 100644
--- a/test/box/on_schema_init.lua
+++ b/test/box/on_schema_init.lua
@@ -21,7 +21,8 @@ end
 box.ctl.on_schema_init(on_init_trig)
 
 box.cfg{
-    listen = os.getenv("LISTEN")
+    listen          = os.getenv("LISTEN"),
+    memtx_allocator = os.getenv("MEMTX_ALLOCATOR")
 }
 
 require('console').listen(os.getenv('ADMIN'))
diff --git a/test/box/tx_man.lua b/test/box/tx_man.lua
index addcd11f33..22e57fc96c 100644
--- a/test/box/tx_man.lua
+++ b/test/box/tx_man.lua
@@ -5,6 +5,7 @@ box.cfg{
     memtx_memory           = 107374182,
     pid_file               = "tarantool.pid",
     memtx_use_mvcc_engine  = true,
+    memtx_allocator        = os.getenv("MEMTX_ALLOCATOR")
 }
 
 require('console').listen(os.getenv('ADMIN'))
diff --git a/test/engine/box.lua b/test/engine/box.lua
index 8558c9ac0a..744a50b3ed 100644
--- a/test/engine/box.lua
+++ b/test/engine/box.lua
@@ -12,6 +12,7 @@ box.cfg{
     vinyl_page_size     = 1024,
     memtx_max_tuple_size = 1024 * 1024 * 100,
     vinyl_max_tuple_size = 1024 * 1024 * 100,
+    memtx_allocator      = os.getenv("MEMTX_ALLOCATOR")
 }
 
 require('console').listen(os.getenv('ADMIN'))
-- 
GitLab