Use tmt and osci to gate
Add bash completion test
This commit is contained in:
parent
0aa4c6f013
commit
96e568ae44
1
.fmf/version
Normal file
1
.fmf/version
Normal file
@ -0,0 +1 @@
|
||||
1
|
||||
@ -3,4 +3,4 @@ product_versions:
|
||||
- rhel-9
|
||||
decision_context: osci_compose_gate
|
||||
rules:
|
||||
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional}
|
||||
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}
|
||||
|
||||
81
plan.fmf
Normal file
81
plan.fmf
Normal file
@ -0,0 +1,81 @@
|
||||
execute:
|
||||
how: tmt
|
||||
|
||||
discover:
|
||||
- name: tests_python
|
||||
how: shell
|
||||
url: https://gitlab.com/redhat/centos-stream/tests/python.git
|
||||
tests:
|
||||
- name: smoke39
|
||||
path: /smoke
|
||||
test: VERSION=3.9 ./venv.sh
|
||||
- name: smoke39_virtualenv
|
||||
path: /smoke
|
||||
test: VERSION=3.9 METHOD=virtualenv ./venv.sh
|
||||
- name: smoke312
|
||||
path: /smoke
|
||||
test: VERSION=3.12 ./venv.sh
|
||||
- name: smoke312_virtualenv
|
||||
path: /smoke
|
||||
test: VERSION=3.12 METHOD=virtualenv ./venv.sh
|
||||
- name: smoke314
|
||||
path: /smoke
|
||||
test: VERSION=3.14 ./venv.sh
|
||||
- name: smoke314_virtualenv
|
||||
path: /smoke
|
||||
test: VERSION=3.14 METHOD=virtualenv ./venv.sh
|
||||
|
||||
- name: rpms_pyproject-rpm-macros
|
||||
how: shell
|
||||
url: https://gitlab.com/redhat/centos-stream/rpms/pyproject-rpm-macros.git
|
||||
ref: c9s
|
||||
tests:
|
||||
- name: pyproject_pytest
|
||||
path: /tests
|
||||
test: ./mocktest.sh python-pytest
|
||||
- name: pyproject_entrypoints
|
||||
path: /tests
|
||||
test: ./mocktest.sh python-entrypoints
|
||||
- name: pyproject_pluggy
|
||||
path: /tests
|
||||
test: ./mocktest.sh python-pluggy
|
||||
|
||||
- name: same_repo
|
||||
how: shell
|
||||
dist-git-source: true
|
||||
dist-git-download-only: true
|
||||
tests:
|
||||
- name: pip_install_upgrade
|
||||
path: /tests/pip_install_upgrade/
|
||||
test: ./runtest.sh
|
||||
- name: bash_completion
|
||||
path: /tests/bash_completion
|
||||
test: ./pip_completion_full_test.sh
|
||||
prepare:
|
||||
- name: Enable CRB
|
||||
how: feature
|
||||
crb: enabled
|
||||
- name: Enable EPEL
|
||||
how: feature
|
||||
epel: enabled
|
||||
- name: Install dependencies
|
||||
how: install
|
||||
package:
|
||||
- gcc
|
||||
- virtualenv
|
||||
- python3.9-devel
|
||||
- python3.12-devel
|
||||
- python3.14-devel
|
||||
- python3-tox
|
||||
- mock
|
||||
- rpmdevtools
|
||||
- rpm-build
|
||||
- grep
|
||||
- util-linux
|
||||
- shadow-utils
|
||||
- expect
|
||||
- dnf
|
||||
- name: Update packages
|
||||
how: shell
|
||||
script: dnf upgrade -y
|
||||
|
||||
35
tests/bash_completion/main.fmf
Normal file
35
tests/bash_completion/main.fmf
Normal file
@ -0,0 +1,35 @@
|
||||
summary: PIP bash completion functionality smoke test
|
||||
description: |
|
||||
Comprehensive test for pip bash completion functionality on Fedora/RHEL systems.
|
||||
|
||||
The test performs the following steps:
|
||||
1. Finds the bash completion script in the given (e.g. python3-pip) RPM package
|
||||
2. Discovers all pip executables in the package (e.g. /usr/bin/pip and /usr/bin/pip3.14)
|
||||
3. Sources the completion script and verifies completion for all executables is registered
|
||||
4. Runs functional TAB completion tests using expect (for regular and POSIX mode of Bash)
|
||||
5. Validates that completion works for basic pip commands
|
||||
|
||||
This is a smoke test to ensure pip bash completion is properly
|
||||
installed and functional after package installation.
|
||||
|
||||
component:
|
||||
- python3-pip
|
||||
|
||||
test: ./pip_completion_full_test.sh
|
||||
|
||||
framework: shell
|
||||
|
||||
duration: 5m
|
||||
tier: 1
|
||||
|
||||
|
||||
require:
|
||||
- python3-pip
|
||||
- bash-completion
|
||||
- expect
|
||||
- rpm
|
||||
- bash
|
||||
|
||||
|
||||
environment:
|
||||
PACKAGE: python3-pip
|
||||
88
tests/bash_completion/pip_completion_full_test.sh
Executable file
88
tests/bash_completion/pip_completion_full_test.sh
Executable file
@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Comprehensive PIP bash completion test for RHEL
|
||||
# Finds completion scripts from RPM, tests all pip binaries, and runs functional tests
|
||||
|
||||
PACKAGE="${PACKAGE:-python3-pip}"
|
||||
|
||||
|
||||
# Step 1: Find bash completion scripts in python3-pip RPM package
|
||||
echo "Step 1: Finding bash completion scripts in $PACKAGE RPM package..."
|
||||
|
||||
COMPLETION_FILE=$(rpm -ql $PACKAGE 2>/dev/null | grep -E "/usr/share/bash-completion/completions/" || true)
|
||||
|
||||
if [[ -z "$COMPLETION_FILE" ]]; then
|
||||
echo "✗ No bash completion files found in $PACKAGE package"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if there's exactly one completion file
|
||||
COMPLETION_FILE_COUNT=$(echo "$COMPLETION_FILE" | wc -l)
|
||||
|
||||
if [[ $COMPLETION_FILE_COUNT -gt 1 ]]; then
|
||||
echo "✗ Multiple bash completion files found in $PACKAGE package:"
|
||||
echo "$COMPLETION_FILE" | sed 's/^/ - /'
|
||||
echo "Expected exactly one completion file, found $COMPLETION_FILE_COUNT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
echo "✓ Found completion file from $PACKAGE package:"
|
||||
echo "$COMPLETION_FILE" | sed 's/^/ - /'
|
||||
|
||||
# Step 2: Find all pip binaries
|
||||
echo
|
||||
echo "Step 2: Finding all pip binaries..."
|
||||
PIP_BINARIES=()
|
||||
PIP_FILES=$(rpm -ql $PACKAGE | grep /bin/p)
|
||||
for pip_file in $PIP_FILES; do
|
||||
if [[ -x "$pip_file" ]]; then
|
||||
pip_cmd=$(basename "$pip_file")
|
||||
PIP_BINARIES+=("$pip_cmd")
|
||||
echo "✓ Found: $pip_cmd -> $pip_file"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#PIP_BINARIES[@]} -eq 0 ]]; then
|
||||
echo "✗ No pip binaries found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Total pip binaries found: ${#PIP_BINARIES[@]}"
|
||||
|
||||
# Step 3: Source completion scripts and test each binary
|
||||
echo
|
||||
echo "Step 3: Testing completion for each pip binary..."
|
||||
|
||||
for AS_POSIX in 0 1; do
|
||||
if [[ $AS_POSIX -eq 1 ]]; then
|
||||
echo "Testing in POSIX mode"
|
||||
POSIX="--posix"
|
||||
else
|
||||
echo "Testing in non-POSIX mode"
|
||||
POSIX=""
|
||||
fi
|
||||
|
||||
echo "Sourcing: $COMPLETION_FILE"
|
||||
if bash --norc $POSIX -c "source $COMPLETION_FILE" ; then
|
||||
echo "✓ Successfully sourced $COMPLETION_FILE"
|
||||
else
|
||||
echo "! Warning: Failed to source $COMPLETION_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export AS_POSIX
|
||||
for pip_exec in "${PIP_BINARIES[@]}"; do
|
||||
echo "Running expect test with $COMPLETION_FILE and $pip_exec..."
|
||||
if ./test_pip_completion.exp "$COMPLETION_FILE" "$pip_exec"; then
|
||||
echo "✓ Functional test passed"
|
||||
else
|
||||
echo "✗ Functional test failed"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
done
|
||||
|
||||
|
||||
echo "✓ All tests completed successfully!"
|
||||
117
tests/bash_completion/test_pip_completion.exp
Executable file
117
tests/bash_completion/test_pip_completion.exp
Executable file
@ -0,0 +1,117 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
# PIP bash completion smoke test using expect
|
||||
# Tests actual TAB completion functionality
|
||||
# Usage: test_pip_completion.exp [completion_file] [pip_binary]
|
||||
|
||||
set timeout 5
|
||||
|
||||
|
||||
set completion_file [lindex $argv 0]
|
||||
set pip_exec [lindex $argv 1]
|
||||
|
||||
|
||||
puts "=== PIP Bash Completion Test (using expect) ==="
|
||||
puts "Testing completion file: $completion_file"
|
||||
puts "Testing pip binary: $pip_exec"
|
||||
|
||||
# Check if completion file exists first
|
||||
if {![file exists $completion_file]} {
|
||||
puts "✗ Completion file not found: $completion_file"
|
||||
exit 1
|
||||
}
|
||||
puts "✓ Completion file found: $completion_file"
|
||||
|
||||
# Start bash shell
|
||||
if {[info exists env(AS_POSIX)] && $env(AS_POSIX) == "1"} {
|
||||
spawn bash --norc --posix
|
||||
} else {
|
||||
spawn bash --norc
|
||||
}
|
||||
expect "$ "
|
||||
|
||||
# Source the completion file
|
||||
send "source $completion_file\r"
|
||||
expect "$ "
|
||||
puts "Attempted to source completion file"
|
||||
|
||||
# Test 1: Basic pip command completion
|
||||
puts "\nTest 1: Testing '$pip_exec ' + TAB completion..."
|
||||
send "$pip_exec "
|
||||
sleep 0.1
|
||||
# Send TAB TAB using hex codes
|
||||
send "\x09\x09"
|
||||
expect {
|
||||
-re "(install|uninstall|list|show)" {
|
||||
puts "✓ Basic pip commands found in completion"
|
||||
expect "$ "
|
||||
}
|
||||
-re "Display all" {
|
||||
puts "✓ Completion showing options menu"
|
||||
send "n\r"
|
||||
expect "$ "
|
||||
}
|
||||
timeout {
|
||||
puts "✗ Timeout waiting for completion - test failed"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Clear the line and ensure clean prompt
|
||||
send "\x03"
|
||||
expect "$ "
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
# Test 2: Test partial command completion (simpler test)
|
||||
puts "\nTest 2: Testing '$pip_exec insta' + TAB completion..."
|
||||
send "$pip_exec insta"
|
||||
sleep 0.1
|
||||
# Single TAB for completion
|
||||
send "\x09"
|
||||
expect {
|
||||
-re "install" {
|
||||
puts "✓ Partial command completion works (insta -> install)"
|
||||
expect "$ "
|
||||
}
|
||||
timeout {
|
||||
puts "✗ Timeout on partial completion test - test failed"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Clear the line and ensure clean prompt
|
||||
send "\x03"
|
||||
expect "$ "
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
# Test 3: Test help completion
|
||||
puts "\nTest 3: Testing '$pip_exec --' + TAB completion..."
|
||||
send "$pip_exec --"
|
||||
sleep 0.1
|
||||
send "\x09\x09"
|
||||
expect {
|
||||
-re "(--help|--version)" {
|
||||
puts "✓ Command options found in completion"
|
||||
expect "$ "
|
||||
}
|
||||
timeout {
|
||||
puts "✗ Timeout on options completion test - test failed"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Final cleanup - make sure we're at clean prompt
|
||||
send "\x03"
|
||||
expect "$ "
|
||||
send "\r"
|
||||
expect "$ "
|
||||
|
||||
# Exit bash cleanly
|
||||
send "exit\r"
|
||||
expect eof
|
||||
|
||||
puts "\n=== Completion Test Complete ==="
|
||||
puts "PIP bash completion functionality tested!"
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
roles:
|
||||
- role: standard-test-basic
|
||||
tags:
|
||||
- classic
|
||||
repositories:
|
||||
- repo: "https://gitlab.com/redhat/centos-stream/tests/python.git"
|
||||
dest: "python"
|
||||
- repo: "https://gitlab.com/redhat/centos-stream/rpms/pyproject-rpm-macros.git"
|
||||
dest: "pyproject-rpm-macros"
|
||||
version: "c9s"
|
||||
tests:
|
||||
- smoke39:
|
||||
dir: python/smoke
|
||||
run: VERSION=3.9 ./venv.sh
|
||||
- smoke39_virtualenv:
|
||||
dir: python/smoke
|
||||
run: VERSION=3.9 METHOD=virtualenv ./venv.sh
|
||||
- pyproject_pytest:
|
||||
dir: pyproject-rpm-macros/tests
|
||||
run: ./mocktest.sh python-pytest
|
||||
- pyproject_entrypoints:
|
||||
dir: pyproject-rpm-macros/tests
|
||||
run: ./mocktest.sh python-entrypoints
|
||||
- pyproject_pluggy:
|
||||
dir: pyproject-rpm-macros/tests
|
||||
run: ./mocktest.sh python-pluggy
|
||||
- pip_install_upgrade
|
||||
required_packages:
|
||||
- 'https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm'
|
||||
- 'https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-9.noarch.rpm'
|
||||
- gcc
|
||||
- virtualenv
|
||||
- python3.9
|
||||
- python3-devel
|
||||
- tox
|
||||
- mock
|
||||
- rpmdevtools
|
||||
- rpm-build
|
||||
- grep
|
||||
- util-linux
|
||||
- shadow-utils
|
||||
Loading…
Reference in New Issue
Block a user