Skip to content

ci: Add testing on macOS #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 184 additions & 5 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

steps:
- name: Clone the connector
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup tt
run: |
Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
run: echo "/opt/tarantool/bin" >> $GITHUB_PATH

- name: Setup golang for the connector and tests
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.golang }}

Expand Down Expand Up @@ -167,14 +167,14 @@ jobs:
- name: Clone the connector
# `ref` as merge request is needed for pull_request_target because this
# target runs in the context of the base commit of the pull request.
uses: actions/checkout@v2
uses: actions/checkout@v3
if: github.event_name == 'pull_request_target'
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge

- name: Clone the connector
if: github.event_name != 'pull_request_target'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Tarantool ${{ matrix.sdk-version }}
run: |
Expand All @@ -184,7 +184,7 @@ jobs:
rm -f ${ARCHIVE_NAME}

- name: Setup golang for the connector and tests
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.13

Expand Down Expand Up @@ -240,3 +240,182 @@ jobs:

- name: Check workability of benchmark tests
run: make bench-deps bench DURATION=1x COUNT=1

testing_mac_os:
# 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.
#
# The main trick is described here:
# https://github.com/Dart-Code/Dart-Code/pull/2375
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository) ||
(github.event_name == 'workflow_dispatch')

strategy:
fail-fast: false
matrix:
golang:
- 1.13
runs-on:
- macos-11
- macos-12
tarantool:
- brew
- 1.10.14

env:
# Make sense only for non-brew jobs.
#
# Set as absolute paths to avoid any possible confusion
# after changing a current directory.
T_VERSION: ${{ matrix.tarantool }}
T_SRCDIR: ${{ format('{0}/tarantool-{1}', github.workspace, matrix.tarantool) }}
T_TARDIR: ${{ format('{0}/tarantool-{1}-build', github.workspace, matrix.tarantool) }}
SRCDIR: ${{ format('{0}/{1}', github.workspace, github.repository) }}

runs-on: ${{ matrix.runs-on }}
steps:
- name: Clone the connector
uses: actions/checkout@v3
with:
path: ${{ env.SRCDIR }}

- name: Restore cache of tarantool ${{ env.T_VERSION }}
uses: actions/cache@v3
id: cache
with:
path: ${{ env.T_TARDIR }}
key: ${{ matrix.runs-on }}-${{ matrix.tarantool }}
if: matrix.tarantool != 'brew'

- name: Install latest tarantool from brew
run: brew install tarantool
if: matrix.tarantool == 'brew'

- name: Install tarantool build dependencies
run: brew install autoconf automake libtool openssl@1.1
if: matrix.tarantool != 'brew' && steps.cache.outputs.cache-hit != 'true'

- name: Clone tarantool ${{ env.T_VERSION }}
uses: actions/checkout@v3
with:
repository: tarantool/tarantool
ref: ${{ env.T_VERSION }}
path: ${{ env.T_TARDIR }}
submodules: true
# fetch-depth is 1 by default and it is okay for
# building from a tag. However we have master in
# the version list.
fetch-depth: 0
if: matrix.tarantool != 'brew' && steps.cache.outputs.cache-hit != 'true'

- name: Build tarantool ${{ env.T_VERSION }} from sources
run: |
cd "${T_TARDIR}"
# Set RelWithDebInfo just to disable -Werror.
#
# There are tarantool releases on which AppleClang
# complains about the problem that was fixed later in
# https://github.com/tarantool/tarantool/commit/7e8688ff8885cc7813d12225e03694eb8886de29
#
# Set OpenSSL root directory for linking tarantool with OpenSSL of version 1.1
# This is related to #49. There are too much deprecations which affect the build and tests.
# Must be revisited after fixing https://github.com/tarantool/tarantool/issues/6477
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_DIST=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1 -DOPENSSL_LIBRARIES=/usr/local/opt/openssl@1.1/lib
# {{{ Workaround Mac OS build failure (gh-6076)
#
# https://github.com/tarantool/tarantool/issues/6076
#
# In brief: when "src/lib/small" is in include paths,
# `#include <version>` from inside Mac OS SDK headers
# attempts to include "src/lib/small/VERSION" as a
# header file that leads to a syntax error.
#
# It was fixed in the following commits:
#
# * 1.10.10-24-g7bce4abd1
# * 2.7.2-44-gbb1d32903
# * 2.8.1-56-ga6c29c5af
# * 2.9.0-84-gc5ae543f3
#
# However applying the workaround for all versions looks
# harmless.
#
# Added -f just in case: I guess we'll drop this useless
# obsoleted VERSION file from the git repository sooner
# or later.
rm -f src/lib/small/VERSION
# The same as above, but for the VERSION file generated
# by tarantool's CMake script.
rm VERSION
# }}} Workaround Mac OS build failure (gh-6076)
# Continue the build.
make -j$(sysctl -n hw.logicalcpu)
make install
if: matrix.tarantool != 'brew' && steps.cache.outputs.cache-hit != 'true'

- name: Install tarantool
run: |
cd "${T_TARDIR}"
make install
if: matrix.tarantool != 'brew' && steps.cache.outputs.cache-hit == 'true'

- name: Verify tarantool version
run: |
# Workaround https://github.com/tarantool/tarantool/issues/4983
# Workaround https://github.com/tarantool/tarantool/issues/5040
tarantool -e "require('fiber').sleep(0) assert(_TARANTOOL:startswith('${T_VERSION}'), _TARANTOOL) os.exit()"
if: matrix.tarantool != 'brew' && matrix.tarantool != 'master'

- name: Setup golang for the connector and tests
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.golang }}

# Workaround for Mac OS 12 testrace failure
# https://github.com/golang/go/issues/49138
- name: disable MallocNanoZone for macos-12
run: echo "MallocNanoZone=0" >> $GITHUB_ENV
if: matrix.runs-on == 'macos-12'

- name: Install test dependencies
run: |
brew install luarocks
cd "${SRCDIR}"
make deps

- name: Run regression tests
run: |
cd "${SRCDIR}"
make test
make testrace

- name: Run regression tests with call_17
run: |
cd "${SRCDIR}"
make test TAGS="go_tarantool_call_17"
make testrace TAGS="go_tarantool_call_17"

- name: Run regression tests with msgpack.v5
run: |
cd "${SRCDIR}"
make test TAGS="go_tarantool_msgpack_v5"
make testrace TAGS="go_tarantool_msgpack_v5"

- name: Run regression tests with msgpack.v5 and call_17
run: |
cd "${SRCDIR}"
make test TAGS="go_tarantool_msgpack_v5,go_tarantool_call_17"
make testrace TAGS="go_tarantool_msgpack_v5,go_tarantool_call_17"

- name: Run fuzzing tests
if: ${{ matrix.fuzzing }}
run: |
cd "${SRCDIR}"
make fuzzing TAGS="go_tarantool_decimal_fuzzing"

- name: Check workability of benchmark tests
run: |
cd "${SRCDIR}"
make bench-deps bench DURATION=1x COUNT=1
8 changes: 6 additions & 2 deletions connection_pool/connection_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2164,7 +2164,11 @@ func TestConnectionPool_NewWatcher_update(t *testing.T) {
err := test_helpers.SetClusterRO(servers, opts, roles)
require.Nilf(t, err, "fail to set roles for cluster")

pool, err := connection_pool.Connect(servers, opts)
poolOpts := connection_pool.OptsPool{
CheckTimeout: 500 * time.Millisecond,
}
pool, err := connection_pool.ConnectWithOpts(servers, opts, poolOpts)

require.Nilf(t, err, "failed to connect")
require.NotNilf(t, pool, "conn is nil after Connect")
defer pool.Close()
Expand Down Expand Up @@ -2192,7 +2196,7 @@ func TestConnectionPool_NewWatcher_update(t *testing.T) {
} else {
testMap[addr] = 1
}
case <-time.After(time.Second):
case <-time.After(poolOpts.CheckTimeout * 2):
t.Errorf("Failed to get a watch init event.")
break
}
Expand Down
47 changes: 33 additions & 14 deletions multi/multi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,49 @@ func TestConnSuccessfully(t *testing.T) {
}

func TestReconnect(t *testing.T) {
multiConn, _ := Connect([]string{server1, server2}, connOpts)
sleep := 100 * time.Millisecond
sleepCnt := 50
servers := []string{server1, server2}
multiConn, _ := Connect(servers, connOpts)
if multiConn == nil {
t.Errorf("conn is nil after Connect")
return
}
timer := time.NewTimer(300 * time.Millisecond)
<-timer.C
defer multiConn.Close()
test_helpers.StopTarantoolWithCleanup(instances[0])

conn, _ := multiConn.getConnectionFromPool(server1)
conn.Close()
for i := 0; i < sleepCnt; i++ {
_, ok := multiConn.getConnectionFromPool(servers[0])
if !ok {
break
}
time.Sleep(sleep)
}

_, ok := multiConn.getConnectionFromPool(servers[0])
if ok {
t.Fatalf("failed to close conn")
}

if multiConn.getCurrentConnection().Addr() == server1 {
if multiConn.getCurrentConnection().Addr() == servers[0] {
t.Errorf("conn has incorrect addr: %s after disconnect server1", multiConn.getCurrentConnection().Addr())
}
if !multiConn.ConnectedNow() {
t.Errorf("incorrect multiConn status after reconnecting")

err := test_helpers.RestartTarantool(&instances[0])
if err != nil {
t.Fatalf("failed to restart Tarantool: %s", err)
}

timer = time.NewTimer(100 * time.Millisecond)
<-timer.C
conn, _ = multiConn.getConnectionFromPool(server1)
if !conn.ConnectedNow() {
t.Errorf("incorrect conn status after reconnecting")
for i := 0; i < sleepCnt; i++ {
_, ok := multiConn.getConnectionFromPool(servers[0])
if ok {
break
}
time.Sleep(sleep)
}

_, ok = multiConn.getConnectionFromPool(servers[0])
if !ok {
t.Fatalf("incorrect conn status after reconnecting")
}
}

Expand Down
17 changes: 14 additions & 3 deletions queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ func TestTtlQueue(t *testing.T) {
}
}

time.Sleep(5 * time.Second)
time.Sleep(10 * time.Second)

//Take
task, err = q.TakeTimeout(2 * time.Second)
Expand Down Expand Up @@ -791,21 +791,32 @@ func TestUtube_Put(t *testing.T) {
close(errChan)
}()

time.Sleep(100 * time.Millisecond)
time.Sleep(500 * time.Millisecond)
// the queue should be blocked for ~2 seconds
start := time.Now()
t2, err := q.TakeTimeout(2 * time.Second)
if err != nil {
<-errChan
t.Fatalf("Failed to take task from utube: %s", err)
}

if t2 == nil {
<-errChan
t.Fatalf("Got nil task")
}

if err := t2.Ack(); err != nil {
<-errChan
t.Fatalf("Failed to ack task: %s", err)
}
end := time.Now()
if _, ok := <-errChan; ok {
t.Fatalf("One of tasks failed")
}
if math.Abs(float64(end.Sub(start)-2*time.Second)) > float64(200*time.Millisecond) {

timeSpent := math.Abs(float64(end.Sub(start) - 2*time.Second))

if timeSpent > float64(700*time.Millisecond) {
t.Fatalf("Blocking time is less than expected: actual = %.2fs, expected = 1s", end.Sub(start).Seconds())
}
}
Expand Down