Skip to content
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

DNM: Testing stuff #229

Draft
wants to merge 82 commits into
base: python-3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
1e50722
feat: enable lab-controller build for Python 3
StykMartin Jan 19, 2024
0f652a5
fix(async): rename module to avoid use of reserved keyword
StykMartin Jan 19, 2024
fd6c096
fix(test): use range instead of xrange
StykMartin Jan 19, 2024
ea94507
fix(test): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
f643bcb
fix(watchdog): use six to provide xmlrpc client
StykMartin Jan 19, 2024
5cca033
fix(watchdog): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
5f279cd
chore(watchdog): format code and sort imports
StykMartin Jan 19, 2024
a1234e4
chore(utils): format code and sort imports
StykMartin Jan 19, 2024
7ce4f30
fix(transfer): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
e02c044
chore(transfer): format code and sort imports
StykMartin Jan 19, 2024
994106f
fix(transfer): handle SSL error on Python 6
StykMartin Jan 19, 2024
8000fbd
chore(test): format code and sort imports
StykMartin Jan 19, 2024
fe30827
fix(test): use proper octal format
StykMartin Jan 19, 2024
08c91a8
fix(pxemenu): use xmlrpc client and urllib from six
StykMartin Jan 19, 2024
a1a47d8
chore(pxemenu): format code and sort imports
StykMartin Jan 19, 2024
2f46bb2
fix(proxy): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
6c634b6
fix(proxy): use xmlrpc move from six
StykMartin Jan 19, 2024
0451052
chore(proxy): format code and sort imports
StykMartin Jan 19, 2024
8c32952
fix(provision): use xmlrpc move from six
StykMartin Jan 19, 2024
144fab2
fix(provision): use unicode from six
StykMartin Jan 19, 2024
6f60aff
fix(provision): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
343d697
fix(provision): handle iterators and dict with six
StykMartin Jan 19, 2024
aae7f44
chore(provision): format code and sort imports
StykMartin Jan 19, 2024
7538883
fix(netboot): import StringIO from six
StykMartin Jan 19, 2024
1294424
fix(netboot): use urllib from six
StykMartin Jan 19, 2024
6a1f546
fix(netboot): use file mode compatible with six
StykMartin Jan 19, 2024
be6f42f
chore(netboot): format code and sort imports
StykMartin Jan 19, 2024
fe1d421
fix(proxy-main): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
4bf3541
fix(proxy-main): make xmlrpc imports compatible
StykMartin Jan 19, 2024
19b03a3
chore(proxy-main): format code and sort imports
StykMartin Jan 19, 2024
85caf1a
fix(log-storage): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
8362934
fix(log-storage): use proper octal format
StykMartin Jan 19, 2024
be6e3a0
chore(log-storage): format code and sort imports
StykMartin Jan 19, 2024
8bd4f9f
fix(pxemenu): use xmlrpc client and urllib from six
StykMartin Jan 19, 2024
294f890
chore(expire-distros): format code and sort imports
StykMartin Jan 19, 2024
206e2a3
fix(distro-import): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
b5858e8
fix(distro-import): call fn print
StykMartin Jan 19, 2024
d897c03
fix(pxemenu): use xmlrpc client,urllib, and configparser from six
StykMartin Jan 19, 2024
30dc91d
fix(distro-import): use anonymous fn instead string::strip
StykMartin Jan 19, 2024
ebfedd0
chore(distro-import): format code and sort imports
StykMartin Jan 19, 2024
2ad1760
fix(distro-import): use is to compare None
StykMartin Jan 19, 2024
1230d6b
fix(distro-import): simplify comparison
StykMartin Jan 19, 2024
0acf0e1
chore(config): format code and sort imports
StykMartin Jan 19, 2024
6d9da57
fix(concurrency): update exception syntax for Python 3 compatibility
StykMartin Jan 19, 2024
c21b481
chore(concurrency): format code and sort imports
StykMartin Jan 19, 2024
a108752
chore(clear-netboot): format code and sort imports
StykMartin Jan 19, 2024
6a5961d
tests: use pytest w/ python3
StykMartin Jan 19, 2024
f973aa7
fix(proxy): use absolute import to import utils
StykMartin Jan 19, 2024
d324d66
ci: run unit tests during pull requests
StykMartin Jan 19, 2024
7ae2c28
fix(provision): use datetime fn instead on using custom
StykMartin Jan 19, 2024
aa4a321
fix(common-helpers): always encode unicode to str
StykMartin Jan 19, 2024
8b21692
fix(spec): add werkzeug to builddeps
StykMartin Jan 19, 2024
713637c
fix(test): use file mode compatible with python six
StykMartin Jan 19, 2024
b71474f
fix(test): always write bytes to test images
StykMartin Jan 19, 2024
aa37a6e
fix(test): drop deprecated fn names
StykMartin Jan 19, 2024
cc4b76b
fix(concurrency): wait till fileno is ready
StykMartin Jan 21, 2024
9544854
fix(concurrency): decode bytes
StykMartin Jan 21, 2024
3dc411f
test: extend test suite to validate concurrency
StykMartin Jan 21, 2024
4122acb
fix(proxy-main): use pywsgi instead of deprecated wsgi
StykMartin Jan 21, 2024
ed6108f
test: refactor _assert_process_group_is_removed to use psutil
StykMartin Jan 21, 2024
ad5bd18
ci: run init inside the container that forwards signals
StykMartin Jan 21, 2024
408850e
ci: define timeout for unit and integration tests
StykMartin Jan 21, 2024
cc8bb90
ci: run unit test on CentOS 9 Stream
StykMartin Jan 21, 2024
63d1303
ci: show python environment
StykMartin Jan 21, 2024
923852a
chore: remove init.d configuration
StykMartin Jan 21, 2024
82a75fd
Make source code cloneable on Windows
JohnVillalovos Dec 4, 2021
9780b33
chore: remove unused check_output
StykMartin Jan 21, 2024
779280a
fix(proxy): explicitly convert ascii_control_chars to list for Py3 co…
StykMartin Jan 21, 2024
c789a60
fix(proxy): use raw string notation for ANSI escape code regex
StykMartin Jan 21, 2024
7c95b27
fix: use warning instead of deprecated warn in logger
StykMartin Jan 21, 2024
1788dc0
chore: noqa for broad exceptions in main loops
StykMartin Jan 21, 2024
ae0687c
refactor(watchdog): remove shadowing for variable greenlet
StykMartin Jan 21, 2024
d98afc0
fix(watchdog): handle missing 'Running' task in recipe abort process
StykMartin Jan 21, 2024
80a2611
refactor(utils): remove unused code
StykMartin Jan 21, 2024
4e60b9f
refactor(test): rename 'id' to 'entity_id' to avoid shadowing built-i…
StykMartin Jan 21, 2024
66b2776
refactor(proxy): always close hub
StykMartin Jan 21, 2024
b914ca8
docs: generate man page for beaker-import
StykMartin Jan 21, 2024
06ca231
ci: execute unit tests on fedora
StykMartin Jan 21, 2024
52b15bd
build: manage logrotate and log dir for py3 targets
StykMartin Jan 21, 2024
aa77288
refactor: use absolute import for utility bkr utility library
StykMartin Jan 21, 2024
4fa92c5
fix(provision): encode power env fields on python 2
StykMartin Jan 21, 2024
34d1482
chore(ci): use `vault.centos.org` for CentOS 7/8 & other fixes
JohnVillalovos Aug 3, 2024
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
6 changes: 6 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Publish

# If a pull-request is pushed then cancel all previously running jobs related
# to that pull-request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

on:
push:
tags:
Expand Down
111 changes: 111 additions & 0 deletions .github/workflows/review-checks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Review-checks

# If a pull-request is pushed then cancel all previously running jobs related
# to that pull-request
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

on: [pull_request]

jobs:
Expand All @@ -10,6 +16,12 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: Fixup CentOS repo files
run: |
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo

- name: Install utils
run: |
yum install -y git wget ca-certificates
Expand All @@ -30,10 +42,14 @@ jobs:

integration-tests:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
MYSQL_USER: beaker
MYSQL_PASSWORD: beaker
MYSQL_ROOT_PASSWORD: toor
# https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
strategy:
fail-fast: false
matrix:
Expand All @@ -51,6 +67,12 @@ jobs:
ports:
- 3306
steps:
- name: Fixup CentOS repo files
run: |
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo

# We have to install git 2.18+ to perform checkout via git
# This is possible only via IUS repositories
- name: Install git to allow checkout
Expand Down Expand Up @@ -111,3 +133,92 @@ jobs:
# Disable Selenium tests until we have plan for selenium driver + firefox
rm -rf src/bkr/inttest/server/selenium
./run-tests.sh -v ${{ matrix.test-target }}

unit-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
container:
image: ${{ matrix.os-target.name }}
options: --init
strategy:
fail-fast: false
matrix:
test-target:
- Common
- Client
- LabController
os-target:
- name: centos:7
- name: quay.io/centos/centos:stream8
additional_repo: "powertools"
- name: quay.io/centos/centos:stream9
additional_repo: "crb"
# After fixing the names of unit test functions, migrate to the latest
- name: fedora:38
env:
# https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION: node16
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- name: Fixup CentOS repo files
run: |
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
if: matrix.os-target.name == 'centos:7' || matrix.os-target.name == 'quay.io/centos/centos:stream8'

- name: Set BKR_PY3 environment variable
run: echo "BKR_PY3=1" >> $GITHUB_ENV
if: matrix.os-target.name != 'centos:7'

- name: Install DNF and plugins
run: yum install -y dnf 'dnf-command(builddep)' 'dnf-command(config-manager)'

- name: Enable additional repositories
run: |
IFS=', ' read -r -a repos <<< "${{ matrix.os-target.additional_repo }}"
for repo in "${repos[@]}"; do
dnf config-manager --set-enabled $repo
done

# We have to install git 2.18+ to perform checkout via git
# This is possible only via IUS repositories
- name: Install git to allow checkout
run: |
yum install https://repo.ius.io/ius-release-el7.rpm epel-release -y
yum install git236-core -y
if: matrix.os-target.name == 'centos:7'

# Do not upgrade to @v4 as node 20 is incompatible with CentOS 7
- name: Checkout
uses: actions/checkout@v3

# Remove custom git from the IUS repository - git will be reinstalled later as it is needed by beaker itself.
- name: Remove git236 and YUM repositories
run: yum remove git236-core ius-release epel-release -y
if: matrix.os-target.name == 'centos:7'

- name: Add Beaker Server YUM repository
if: matrix.os-target.name == 'centos:7'
run: |
curl -o /etc/yum.repos.d/beaker-server.repo https://beaker-project.org/yum/beaker-server-RedHatEnterpriseLinux.repo

- name: Use EPEL
if: matrix.os-target.name != 'centos:7' && !startsWith(matrix.os-target.name, 'fedora:')
run: |
dnf install -y epel-release

# Build dependencies must be sufficient, the same is done during RPM build
- name: Install Beaker dependency from specfile
run: |
dnf builddep -y *.spec

- name: Show Python Environment
if: matrix.os-target.name != 'centos:7'
run: |
python3 -m pip freeze

- name: Run unit tests
run: |
pushd ${{ matrix.test-target }}
./run-tests.sh
18 changes: 16 additions & 2 deletions Common/bkr/common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import os
import fcntl
import errno

import six
from six.moves import queue

log = getLogger(__name__)
Expand Down Expand Up @@ -100,12 +102,20 @@ def run(self):
self.finished.clear()


class SensitiveUnicode(unicode):
class SensitiveUnicode(six.text_type):
"""The intent of this class is to standardize the behavior of Unicode strings across Python 2 and 3,
while treating the contents of the string as sensitive.

In Python 2, it encodes the unicode string to bytes (str), wrapped in SensitiveStr.
In Python 3, it preserves the unicode representation (str) by overriding the default 'encode' behavior.
"""
def __repr__(self):
return '<repr blocked>'

def encode(self, *args, **kwargs):
return SensitiveStr(super(SensitiveUnicode, self).encode(*args, **kwargs))
if six.PY2:
return SensitiveStr(super(SensitiveUnicode, self).encode(*args, **kwargs))
return self


class SensitiveStr(str):
Expand Down Expand Up @@ -235,6 +245,10 @@ def siphon(src, dest):
chunk = src.read(4096)
if not chunk:
break

if six.PY3 and isinstance(chunk, bytes):
chunk = chunk.decode('utf-8')

dest.write(chunk)


Expand Down
14 changes: 11 additions & 3 deletions LabController/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

BKR_PY3 ?= 0
COMMAND := python2

ifeq ($(BKR_PY3),1)
COMMAND := python3
endif


.PHONY: build
build:
python2 setup.py build
$(COMMAND) setup.py build

.PHONY: install
install: build
python2 setup.py install -O1 --skip-build --root $(DESTDIR)
$(COMMAND) setup.py install -O1 --skip-build --root $(DESTDIR)

.PHONY: clean
clean:
python2 setup.py clean
$(COMMAND) setup.py clean
rm -rf build

.PHONY: check
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
105 changes: 0 additions & 105 deletions LabController/init.d/beaker-provision

This file was deleted.

Loading
Loading