Skip to content

Commit

Permalink
feat: Supports Centos on CI (#1772)
Browse files Browse the repository at this point in the history
* support centos on ci

* add unit test on centos

* find path

* fix PythonE2E on centos
  • Loading branch information
Mixficsol authored Jul 21, 2023
1 parent 387d99a commit 2597ac3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 42 deletions.
55 changes: 34 additions & 21 deletions .github/workflows/pika.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
BUILD_TYPE: RelWithDebInfo

jobs:
build:
build_on_ubuntu:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
Expand Down Expand Up @@ -86,49 +86,62 @@ jobs:
run: |
yum install -y wget git autoconf centos-release-scl
yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++ devtoolset-10-make devtoolset-10-bin-util
yum install -y llvm-toolset-7
yum install -y llvm-toolset-7-clang
yum install -y llvm-toolset-7 llvm-toolset-7-clang tcl unzip which python3
python3 -m pip install --upgrade pip
python3 -m pip install redis
source /opt/rh/devtoolset-10/enable
gcc --version
make --version
python3 --version
- name: Install cmake
run: |
wget https:/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.sh
bash ./cmake-3.26.4-linux-x86_64.sh --skip-license --prefix=/usr
cmake --version
- name: checkout
working-directory: ${{github.workspace}}
run: |
echo Fetching $GITHUB_REPOSITORY@$GITHUB_SHA
git init
git fetch --depth 1 https:/$GITHUB_REPOSITORY $GITHUB_SHA
git checkout $GITHUB_SHA
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: |
source /opt/rh/devtoolset-10/enable
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_PIKA_TOOLS=ON
cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DUSE_PIKA_TOOLS=ON
- name: Build
# Build your program with the given configuration
run: |
cd ${{github.workspace}}
source /opt/rh/devtoolset-10/enable
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
cmake --build build --config ${{env.BUILD_TYPE}}
- name: Test
# Execute tests defined by the CMake configuration.
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: |
cd ${{github.workspace}}/build
source /opt/rh/devtoolset-10/enable
ctest -C ${{env.BUILD_TYPE}}
- name: Unit Test
run: |
chmod +x pikatests.sh
sh pikatests.sh all
# master on port 9221, slave on port 9231, all with 2 db
- name: Start pika master and slave
run: |
cd build
chmod +x ../tests/integration/start_master_and_slave.sh
sh ../tests/integration/start_master_and_slave.sh
- name: Run Python E2E Tests
run: |
python3 tests/integration/pika_replication_test.py
python3 tests/unit/Blpop_Brpop_test.py
build_on_macos:
runs-on: macos-latest

Expand Down Expand Up @@ -161,11 +174,11 @@ jobs:
cmake -B ${{github.workspace}}/build -S . -DCMAKE_C_COMPILER=/usr/local/opt/gcc@10/bin/gcc-10 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}/build
run: |
export CC=/usr/local/opt/gcc@10/bin/gcc-10
ctest -C ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}/build
run: |
export CC=/usr/local/opt/gcc@10/bin/gcc-10
ctest -C ${{env.BUILD_TYPE}}
- name: Unit Test
working-directory: ${{github.workspace}}
Expand All @@ -176,7 +189,7 @@ jobs:
- name: Start pika master and slave
working-directory: ${{github.workspace}}/build
run: |
cd ${{github.workspace}}/build
cd ${{github.workspace}}/build
chmod +x ../tests/integration/start_master_and_slave.sh
../tests/integration/start_master_and_slave.sh
Expand Down
26 changes: 13 additions & 13 deletions tests/integration/pika_replication_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_del_replication():

master.close()
slave.close()
print("Del multiple keys replication OK []")
print("Del multiple keys replication OK [Passed]")


def test_msetnx_replication():
Expand Down Expand Up @@ -180,7 +180,7 @@ def random_mset_thread(keys_):
m_v = master.get(key)
s_v = slave.get(key)
assert m_v == s_v, f'Expected: master_v == slave_v, but got slave_v:{s_v}, master_v:{m_v}, using key:{key}'
print("test_msetnx_replication OK []")
print("test_msetnx_replication OK [Passed]")


def test_mset_replication():
Expand Down Expand Up @@ -245,7 +245,7 @@ def random_mset_thread(keys_):
m_v = master.get(key)
s_v = slave.get(key)
assert m_v == s_v, f'Expected: master_v == slave_v, but got slave_v:{s_v}, master_v:{m_v}, using key:{key}'
print("test_mset_replication OK []")
print("test_mset_replication OK [Passed]")


def test_smove_replication():
Expand Down Expand Up @@ -296,7 +296,7 @@ def random_smove_thread():

assert m_source_set == s_source_set, f'Expected: source_set on master == source_set on slave, but got source_set on slave:{s_source_set}, source_set on master:{m_source_set}'
assert m_dest_set == s_dest_set, f'Expected: dest_set on master == dest_set on slave, but got dest_set on slave:{s_dest_set}, dest_set on master:{m_dest_set}'
print("start test_smove_replication OK []")
print("start test_smove_replication OK [Passed]")


def test_rpoplpush_replication():
Expand Down Expand Up @@ -378,7 +378,7 @@ def rpoplpush_thread1():
# print(slave.lindex('blist', i))
assert master.lindex('blist', i) == slave.lindex('blist', i), \
f"Expected:master.lindex('blist', i) == slave.linex('blist', i), but got False when i = {i}"
print("test_rpoplpush_replication OK []")
print("test_rpoplpush_replication OK [Passed]")


def test_sdiffstore_replication():
Expand Down Expand Up @@ -443,7 +443,7 @@ def random_sdiffstore_thread():
assert m_set1 == s_set1, f'Expected: set1 on master == set1 on slave, but got set1 on slave:{s_set1}, set1 on master:{m_set1}'
assert m_set2 == s_set2, f'Expected: set2 on master == set2 on slave, but got set2 on slave:{s_set2}, set2 on master:{m_set2}'
assert m_dest_set == s_dest_set, f'Expected: dest_set on master == dest_set on slave, but got dest_set on slave:{s_dest_set}, dest_set on master:{m_dest_set}'
print("test_sdiffstore_replication OK []")
print("test_sdiffstore_replication OK [Passed]")


def test_sinterstore_replication():
Expand Down Expand Up @@ -505,7 +505,7 @@ def random_sinterstore_thread():
s_dest_set = slave.smembers('dest_set')

assert m_dest_set == s_dest_set, f'Expected: dest_set on master == dest_set on slave, but got dest_set on slave:{s_dest_set}, dest_set on master:{m_dest_set}'
print("test_sinterstore_replication OK []")
print("test_sinterstore_replication OK [Passed]")


def test_zunionstore_replication():
Expand Down Expand Up @@ -559,7 +559,7 @@ def random_zunionstore_thread():
s_zset_out = slave.zrange('zset_out', 0, -1, withscores=True)

assert m_zset_out == s_zset_out, f'Expected: zset_out on master == zset_out on slave, but got zset_out on slave:{s_zset_out}, zset_out on master:{m_zset_out}'
print("test_zunionstore_replication OK []")
print("test_zunionstore_replication OK [Passed]")


def test_zinterstore_replication():
Expand Down Expand Up @@ -621,7 +621,7 @@ def random_zinterstore_thread():

assert m_zset_out == s_zset_out, f'Expected: zset_out on master == zset_out on slave, but got zset_out on slave:{s_zset_out}, zset_out on master:{m_zset_out}'

print("test_zinterstore_replication OK []")
print("test_zinterstore_replication OK [Passed]")


def test_sunionstore_replication():
Expand Down Expand Up @@ -676,7 +676,7 @@ def random_sunionstore_thread():
s_set_out = slave.smembers('set_out')

assert m_set_out == s_set_out, f'Expected: set_out on master == set_out on slave, but got set_out on slave:{s_set_out}, set_out on master:{m_set_out}'
print("test_sunionstore_replication OK []")
print("test_sunionstore_replication OK [Passed]")


def test_bitop_replication():
Expand Down Expand Up @@ -729,7 +729,7 @@ def random_bitop_thread():

assert m_key_out_count1 == s_key_out_count1, f'Expected: bitcount of bitkey_out1 on master == bitcount of bitkey_out1 on slave, but got bitcount of bitkey_out1 on slave:{s_key_out_count1}, bitcount of bitkey_out1 on master:{m_key_out_count1}'
assert m_key_out_count2 == s_key_out_count2, f'Expected: bitcount of bitkey_out2 on master == bitcount of bitkey_out2 on slave, but got bitcount of bitkey_out2 on slave:{s_key_out_count2}, bitcount of bitkey_out1 on master:{m_key_out_count2}'
print("test_bitop_replication OK []")
print("test_bitop_replication OK [Passed]")


def test_pfmerge_replication():
Expand Down Expand Up @@ -779,7 +779,7 @@ def random_pfmerge_thread():
s_hll_out = slave.pfcount('hll_out')

assert m_hll_out == s_hll_out, f'Expected: hll_out on master == hll_out on slave, but got hll_out on slave:{s_hll_out}, hll_out on master:{m_hll_out}'
print("test_pfmerge_replication OK []")
print("test_pfmerge_replication OK [Passed]")

def test_migrateslot_replication():
print("start test_migrateslot_replication")
Expand Down Expand Up @@ -887,7 +887,7 @@ def test_migrateslot_replication():

i_keys = master.keys("_internal:slotkey:4migrate*")
master.delete(*i_keys)
print("test_migrateslot_replication OK []")
print("test_migrateslot_replication OK [Passed]")

master_ip = '127.0.0.1'
master_port = '9221'
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/Blpop_Brpop_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_single_existing_list(db_):
assert result[0] == b'blist' and result[1] == b'b', f"Expected (b'blist1', b'b'), but got {result}"

pika.close()
print("test_single_existing_list Passed [], db:db%d" % (db_))
print("test_single_existing_list Passed [Passed], db:db%d" % (db_))


# 解阻塞测试(超时自动解阻塞,lpush解阻塞,rpush解阻塞,rpoplpush解阻塞)
Expand Down Expand Up @@ -213,7 +213,7 @@ def brpop_thread51():
assert blocked == False, f"Expected False but got {blocked}"
thread.join()
pika.close()
print("test_blpop_brpop_unblock_lrpush_rpoplpush Passed [], db:db%d" % (db_))
print("test_blpop_brpop_unblock_lrpush_rpoplpush Passed [Passed], db:db%d" % (db_))


def test_concurrency_block_unblock(db_):
Expand Down Expand Up @@ -350,7 +350,7 @@ def rpush_thread(list_, value_):
t.join()
pika.delete('blist0', 'blist1', 'blist2', 'blist3')

print("test_concurrency_block_unblock Passed [], db:db%d" % (db_))
print("test_concurrency_block_unblock Passed [Passed], db:db%d" % (db_))
pika.close()


Expand Down Expand Up @@ -396,7 +396,7 @@ def test_multiple_existing_lists(db_):
assert result[0] == b'blist1' and result[1] == b'large', f"Expected (b'blist1', b'large'), but got {result}"

pika.close()
print("test_multiple_existing_lists Passed [], db:db%d" % (db_))
print("test_multiple_existing_lists Passed [Passed], db:db%d" % (db_))


def test_blpop_brpop_same_key_multiple_times(db_):
Expand Down Expand Up @@ -488,7 +488,7 @@ def brpop_thread2():
assert result[0] == b'list2' and result[1] == b'd', f"Expected (b'list2', b'd'), but got {result}"

pika.close()
print("test_blpop_brpop_same_key_multiple_times Passed [], db:db%d" % (db_))
print("test_blpop_brpop_same_key_multiple_times Passed [Passed], db:db%d" % (db_))


# 目标list被一条push增加了多个value,先完成多个value的入列再pop
Expand Down Expand Up @@ -542,7 +542,7 @@ def brpop_thread():
thread.join()
# 检查blist的第一个元素
assert pika.lindex('blist', 0) == b'foo', "Expected 'foo'"
print("test_blpop_brpop_variadic_lpush Passed [], db:db%d" % (db_))
print("test_blpop_brpop_variadic_lpush Passed [Passed], db:db%d" % (db_))


# 先被阻塞的先服务/阻塞最久的优先级最高
Expand Down Expand Up @@ -587,7 +587,7 @@ def brpop_thread(expect):
t4.join()

pika.close()
print("test_serve_priority Passed [], db:db%d" % (db_))
print("test_serve_priority Passed [Passed], db:db%d" % (db_))


# 主从复制测试
Expand Down Expand Up @@ -813,7 +813,7 @@ def rpush_thread(list_, value_, value2_, value3_, value4_, value5_):

master.close()
slave.close()
print("test_master_slave_replication Passed [], db:db%d" % (db_))
print("test_master_slave_replication Passed [Passed], db:db%d" % (db_))

def test_with_db(db_id):
test_master_slave_replication(db_id)
Expand Down

0 comments on commit 2597ac3

Please sign in to comment.