Skip to content

Commit

Permalink
test: add build tests with no tarantool installed
Browse files Browse the repository at this point in the history
build & dist directories are ignored by pytest, so build directory
is renamed to ttbuild. Added new tt build tests.

Closes tarantool#409
  • Loading branch information
psergee authored and LeonidVas committed Apr 12, 2023
1 parent 8b7b97b commit 5407061
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 4 deletions.
9 changes: 8 additions & 1 deletion .github/actions/prepare-ce-test-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ inputs:
tarantool-version:
required: true
type: string
skip-tarantool-install:
description: Whether to skip tarantool installation
type: boolean
required: false
default: false

runs:
using: "composite"
Expand All @@ -31,13 +36,15 @@ runs:
lua5.1 luarocks lcov \
ruby-dev liblz4-dev autoconf \
automake \
libtool
libtool python3-pytest python3-psutil pip
sudo luarocks install luacheck 0.26.1
sudo gem install coveralls-lcov
sudo pip3 install tarantool
shell: bash

- name: Install Tarantool
uses: tarantool/setup-tarantool@v1
if: ${{ inputs.skip-tarantool-install == 'false' }}
with:
tarantool-version: '${{ inputs.tarantool-version }}'

Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,29 @@ jobs:
TT_EE_USERNAME: '${{ secrets.TT_EE_USERNAME }}'
TT_EE_PASSWORD: '${{ secrets.TT_EE_PASSWORD }}'
run: mage integrationee

# Integration tests on the system without Tarantool installed.
full-ci-ce-no-tarantool:
if: |
(github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.action == 'labeled' &&
github.event.label.name == 'full-ci') ||
(github.event_name == 'pull_request' &&
github.event.action == 'synchronize' &&
contains(github.event.pull_request.labels.*.name, 'full-ci'))
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
submodules: recursive

- name: Prepare CE env
uses: ./.github/actions/prepare-ce-test-env
with:
tarantool-version: '2.10.6'
skip-tarantool-install: true

- name: Integration tests
run: mage integrationnotarantool
14 changes: 11 additions & 3 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ func UnitFull() error {
func Integration() error {
fmt.Println("Running integration tests...")

return sh.RunV(pythonExecutableName, "-m", "pytest", "-m", "not slow", "-m", "not slow_ee",
"test/integration")
return sh.RunV(pythonExecutableName, "-m", "pytest", "-m", "not slow and not slow_ee "+
"and not notarantool", "test/integration")
}

// Run full set of integration tests.
func IntegrationFull() error {
fmt.Println("Running all integration tests...")

return sh.RunV(pythonExecutableName, "-m", "pytest", "-m", "not slow_ee",
return sh.RunV(pythonExecutableName, "-m", "pytest", "-m", "not slow_ee and not notarantool",
"test/integration")
}

Expand All @@ -290,6 +290,14 @@ func IntegrationEE() error {
return sh.RunV(pythonExecutableName, "-m", "pytest", "test/integration/ee")
}

// Run integration tests without system-wide installed Tarantool.
func IntegrationNoTarantool() error {
fmt.Println("Running integration tests without Tarantool...")

return sh.RunV(pythonExecutableName, "-m", "pytest", "-m", "notarantool",
"test/integration")
}

// Run codespell checks.
func Codespell() error {
fmt.Println("Running codespell tests...")
Expand Down
28 changes: 28 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,31 @@ def tt_cmd(session_tmpdir):
def tmpdir_with_cfg(tmpdir):
create_tt_config(tmpdir, "")
return tmpdir


@pytest.fixture(scope="session")
def tmpdir_with_tarantool(tt_cmd, request):
tmpdir = get_tmpdir(request)
init_cmd = [tt_cmd, "init"]
tt_process = subprocess.Popen(
init_cmd,
cwd=tmpdir,
stderr=subprocess.STDOUT,
stdout=subprocess.DEVNULL,
text=True
)
tt_process.wait()
assert tt_process.returncode == 0

init_cmd = [tt_cmd, "install", "tarantool"]
tt_process = subprocess.Popen(
init_cmd,
cwd=tmpdir,
stderr=subprocess.STDOUT,
stdout=subprocess.DEVNULL,
text=True
)
tt_process.wait()
assert tt_process.returncode == 0

return tmpdir
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import subprocess
import tempfile

import pytest


def test_build_no_options(tt_cmd, tmpdir):
app_dir = shutil.copytree(os.path.join(os.path.dirname(__file__), "apps/app1"),
Expand Down Expand Up @@ -225,3 +227,37 @@ def test_build_app_by_name(tt_cmd, tmpdir):
build_output = tt_process.stdout.readlines()
assert "Application was successfully built" in build_output[len(build_output)-1]
assert os.path.exists(os.path.join(app_dir, ".rocks"))


@pytest.mark.notarantool
@pytest.mark.skipif(shutil.which("tarantool") is not None, reason="tarantool found in PATH")
def test_build_app_local_tarantool(tt_cmd, tmpdir_with_tarantool):
build_cmd = [tt_cmd, "create", "cartridge", "--name", "app1", "--non-interactive"]
tt_process = subprocess.Popen(
build_cmd,
cwd=tmpdir_with_tarantool,
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
text=True
)
tt_process.wait()
assert tt_process.returncode == 0

app_dir = os.path.join(tmpdir_with_tarantool, "app1")

assert os.path.exists(app_dir)

build_cmd = [tt_cmd, "build", "app1"]
tt_process = subprocess.Popen(
build_cmd,
cwd=tmpdir_with_tarantool,
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
text=True
)
tt_process.wait()
assert tt_process.returncode == 0

build_output = tt_process.stdout.readlines()
assert "Application was successfully built" in build_output[len(build_output)-1]
assert os.path.exists(os.path.join(app_dir, ".rocks"))
1 change: 1 addition & 0 deletions test/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
markers =
slow: marks tests as slow (deselect with '-m "not slow"')
slow_ee: marks ee tests as slow (deselect with '-m "not slow_ee"')
notarantool: marks tests that must be invoked without pre-installed tarantool (deselect with '-m "not notarantool"')

0 comments on commit 5407061

Please sign in to comment.