Skip to content

Commit

Permalink
test: try fix generate keys script
Browse files Browse the repository at this point in the history
  • Loading branch information
dmyger committed Dec 27, 2024
1 parent 1ffdb70 commit 84a305e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 55 deletions.
1 change: 1 addition & 0 deletions .github/actions/prepare-ce-test-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ runs:
- name: Install test requirements
run: |
sudo apt -y install gdb
pip3 install -r test/requirements.txt
shell: bash
11 changes: 0 additions & 11 deletions .github/actions/static-code-check/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ description: "Performs static code checks."
runs:
using: "composite"
steps:
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install tests requirements
run: |
pip3 install -r test/requirements.txt
shell: bash

- name: Log versions
run: |
go version
Expand Down Expand Up @@ -41,4 +31,3 @@ runs:
- name: Python Linter
run: python3 -m flake8 test
shell: bash

30 changes: 15 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ env:
# Note: Use exactly match version of tool, to avoid unexpected issues with test on CI.
GO_VERSION: '1.22.10'
PYTHON_VERSION: '3.10'
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true

jobs:
tests-ce:
Expand All @@ -24,7 +26,8 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
tarantool-version: ["1.10", "2.10", "3.0"]
# tarantool-version: ["1.10", "2.10", "3.0"]
tarantool-version: ["3.0"]
fail-fast: false
steps:
- uses: actions/checkout@v4
Expand All @@ -37,18 +40,20 @@ jobs:
with:
tarantool-version: '${{ matrix.tarantool-version }}'

- name: Static code check
uses: ./.github/actions/static-code-check
# - name: Static code check
# uses: ./.github/actions/static-code-check

- name: Unit tests
run: mage unit
# - name: Unit tests
# run: mage unit

# This server starts and listen on 8084 port that is used for tests.
- name: Stop Mono server
run: sudo systemctl kill mono-xsp4 || true
# # This server starts and listen on 8084 port that is used for tests.
# - name: Stop Mono server
# run: sudo systemctl kill mono-xsp4 || true

- name: Integration tests
run: mage integration
run: |
pip3 install -r test/requirements.txt
python -m pytest -v -ss test/integration/aeon/test_aeon.py
tests-ce-linux-arm64:
if: false
Expand Down Expand Up @@ -92,12 +97,7 @@ jobs:
#
# We need to use `pull_request_target` because it has access to base
# repository secrets unlike `pull_request`.
if: |
(github.event_name == 'push') ||
(github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.owner.login != 'tarantool' &&
!contains(github.event.pull_request.labels.*.name, 'full-ci') &&
github.event.label.name == 'ee-ci')
if: false
runs-on: ubuntu-22.04
strategy:
matrix:
Expand Down
15 changes: 11 additions & 4 deletions cli/console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,21 @@ func NewConsole(opts ConsoleOpts) (Console, error) {
return c, nil
}

func (c *Console) runOnPipe() {
log.Debugf("Processing piped input")
func (c *Console) runOnPipe() error {
pipe := bufio.NewScanner(os.Stdin)
log.Infof("Processing piped input")
for pipe.Scan() {
line := pipe.Text()
c.execute(line)
}

err := pipe.Err()
if err == nil {
log.Info("EOF on pipe")
} else {
log.Warnf("Error on pipe %v", err)
}
return err
}

// Run starts console.
Expand All @@ -79,8 +87,7 @@ func (c *Console) Run() error {
return errors.New("can't run on stopped console")
}
if !term.IsTerminal(syscall.Stdin) {
c.runOnPipe()
return nil
return c.runOnPipe()
}

log.Infof("Connected to %s\n", c.title())
Expand Down
4 changes: 3 additions & 1 deletion cli/console/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ func DefaultHistoryFile() (History, error) {
}

func (h *History) load() error {
if !util.IsRegularFile(h.filepath) {
return nil
}
rawLines, err := util.GetLastNLines(h.filepath, h.maxCommands)
if err != nil {
return err
}

h.parseCells(rawLines)
return nil

}

func (h *History) parseCells(lines []string) {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/aeon/generate-keys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ EOF
### Server .key&.crt and ca.crt required for Server-Side TLS mode.

# 1. Generate CA's private key and self-signed certificate
openssl req -new -x509 -days 1 -noenc -keyout ca.key -out ca.crt -subj "${CA_SUBJ}" -quiet
openssl req -new -x509 -days 1 -noenc -keyout ca.key -out ca.crt -subj "${CA_SUBJ}"

# 2. Generate web server's private key and certificate signing request (CSR)
openssl req -new -noenc -keyout server.key -out server.csr -subj "${CA_SUBJ}" -quiet
openssl req -new -noenc -keyout server.key -out server.csr -subj "${CA_SUBJ}"

# 3. Use CA's private key to sign web server's CSR and get back the signed certificate
openssl x509 -req -in server.csr -days 1 -CA ca.crt -CAkey ca.key -CAcreateserial \
Expand All @@ -30,7 +30,7 @@ openssl x509 -req -in server.csr -days 1 -CA ca.crt -CAkey ca.key -CAcreateseria
### Client .key & .crt required for Mutual TSL mode.

# 4. Generate client's private key and certificate signing request (CSR)
openssl req -new -noenc -keyout client.key -out client.csr -subj "$CA_SUBJ" -quiet
openssl req -new -noenc -keyout client.key -out client.csr -subj "$CA_SUBJ"

# 5. Use CA's private key to sign client's CSR and get back the signed certificate
openssl x509 -req -in client.csr -days 1 -CA ca.crt -CAkey ca.key -CAcreateserial \
Expand Down
45 changes: 24 additions & 21 deletions test/integration/aeon/test_aeon.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
#!/usr/bin/env python3
from subprocess import PIPE, STDOUT, Popen, run
from subprocess import PIPE, STDOUT, run

import pytest

from utils import wait_for_lines_in_output

AeonConnectCommand = ("aeon", "connect")


def check_tt_aeon_response(output: str):
expected = ["Aeon responses at", "Processing piped input", "EOF on pipe"]
logs = output.split("\n")
for line in logs:
print(line)
for e in expected:
if e in line:
expected.remove(e)
break
if len(expected) == 0:
return

assert False, f"Not found all expected Log records: {expected}"


@pytest.mark.parametrize(
"args",
[
Expand All @@ -32,19 +45,14 @@ def test_cli_plain_arguments_success(tt_cmd, aeon_plain, certificates, args):
cmd.append(f"unix://{aeon_plain}")

print(f"Run: {' '.join(cmd)}")
tt = Popen(
tt = run(
cmd,
stdin=PIPE,
stderr=PIPE,
capture_output=True,
input="",
text=True,
encoding="utf-8",
)
wait_for_lines_in_output(tt.stderr, ["Aeon responses at"])

# Terminate tt with "^D" input, as (EOF) signal.
tt.stdin.close()
tt.wait(timeout=2)
assert tt.poll() is not None
check_tt_aeon_response(tt.stderr)
assert tt.returncode == 0


Expand All @@ -62,19 +70,14 @@ def test_cli_ssl_arguments_success(tt_cmd, aeon_ssl, certificates):
cmd.append("localhost:50051")

print(f"Run: {' '.join(cmd)}")
tt = Popen(
tt = run(
cmd,
stdin=PIPE,
stderr=PIPE,
capture_output=True,
input="",
text=True,
encoding="utf-8",
)
wait_for_lines_in_output(tt.stderr, ["Aeon responses at"])

# Terminate tt with "^D" input, as (EOF) signal.
tt.stdin.close()
tt.wait(timeout=2)
assert tt.poll() is not None
check_tt_aeon_response(tt.stderr)
assert tt.returncode == 0


Expand Down

0 comments on commit 84a305e

Please sign in to comment.