Skip to content

Commit 019aeac

Browse files
authored
Fix CI and test using Ubuntu 24.04 and Python 3.12 (#187)
* Install setuptools * Use Ubuntu 24.04 and Python 3.12 * Handle tilde sign in Ceph version Ceph versions on Ubuntu can have a tilde sign in the version like 19.2.0~git20240301.4c76c50 because they've built it before it was released with their own versioning, packaging cannot handle that. * Set job timeout to 30 minutes So we don't wait for 6 hours for a hanging job. * Skip Ceph when rados bindings is not available The rados python bindings (the python3-rados distro package) is only available for the python version that the distro ships.
1 parent f6d6f19 commit 019aeac

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

.github/workflows/pifpaf.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ env:
1212
jobs:
1313
test:
1414
runs-on: ubuntu-latest
15+
timeout-minutes: 30
1516
strategy:
1617
matrix:
1718
env:
18-
- py310
19+
- py39
20+
- py311
21+
- py312
1922
- pep8
2023
- build
2124
steps:
2225
- uses: actions/checkout@v4
23-
- run: sudo chown -R 1000:1000 $GITHUB_WORKSPACE
26+
- run: sudo chown -R 1010:1010 $GITHUB_WORKSPACE
2427
- uses: docker/build-push-action@v5
2528
with:
2629
context: .

Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:24.04
22
ENV DEBIAN_FRONTEND=noninteractive
33
ENV TZ=Etc/UTC
44

@@ -11,7 +11,7 @@ RUN apt-get update -y && apt-get install -qy gnupg software-properties-common
1111
RUN add-apt-repository -y ppa:deadsnakes/ppa
1212
RUN apt-get -qq update -y \
1313
&& apt-get install -y mysql-server redis-server zookeeper nodejs npm ceph librados-dev \
14-
python3 python3-dev python3-pip python3.9 python3.9-dev \
14+
python3 python3-dev python3-pip python3-virtualenv python3.9 python3.9-dev python3.9-distutils python3.11 python3.11-dev \
1515
gcc liberasurecode-dev liberasurecode1 postgresql libpq-dev python3-rados git wget memcached \
1616
&& rm -rf /var/lib/apt/lists/*
1717

@@ -30,10 +30,12 @@ RUN wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd
3030
&& ln -s /opt/etcd-v${ETCD_VERSION}-linux-amd64/etcd /usr/local/bin/etcd \
3131
&& ln -s /opt/etcd-v${ETCD_VERSION}-linux-amd64/etcdctl /usr/local/bin/etcdctl
3232

33-
RUN pip install -U tox
34-
35-
RUN useradd -ms /bin/bash pifpaf
33+
RUN groupadd --gid 1010 pifpaf
34+
RUN useradd --uid 1010 --gid 1010 -ms /bin/bash pifpaf
3635
USER pifpaf
3736
RUN mkdir /home/pifpaf/tmpxattr
3837
ENV TMP_FOR_XATTR=/home/pifpaf/tmpxattr
38+
RUN python3 -m virtualenv /home/pifpaf/venv
39+
ENV PATH="/home/pifpaf/venv/bin:$PATH"
40+
RUN pip install tox
3941
WORKDIR /home/pifpaf/pifpaf

pifpaf/drivers/ceph.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,12 @@ def _setUp(self):
5151

5252
_, version = self._exec(["ceph", "--version"], stdout=True)
5353
version = version.decode("ascii").split()[2]
54+
# NOTE(tobias-urdin): Ceph versions on Ubuntu can have a
55+
# tilde sign in the version like 19.2.0~git20240301.4c76c50
56+
# because they've built it before it was released with their
57+
# own versioning, packaging cannot handle that.
58+
version = str(version).split("~")[0]
5459
version = packaging.version.Version(version)
55-
5660
if version < packaging.version.Version("12.0.0"):
5761
extra = """
5862
mon_osd_nearfull_ratio = 1

pifpaf/tests/test_drivers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
"unkillable.py")
6969

7070

71+
# NOTE(tobias-urdin): The rados python bindings is only installed
72+
# for the python version that the distro ships.
73+
def _has_rados():
74+
try:
75+
import rados # noqa
76+
return True
77+
except ImportError:
78+
return False
79+
80+
7181
class TestDrivers(testtools.TestCase):
7282
def setUp(self):
7383
super(TestDrivers, self).setUp()
@@ -441,6 +451,7 @@ def test_gnocchi_with_existing_s3rver(self):
441451
r = requests.get("http://localhost:%d/" % port)
442452
self.assertEqual(200, r.status_code)
443453

454+
@testtools.skipUnless(_has_rados(), "Rados not found")
444455
@testtools.skipUnless(shutil.which("gnocchi-api"),
445456
"Gnocchi not found")
446457
@testtools.skipUnless(shutil.which("ceph-mon"),
@@ -502,6 +513,7 @@ def test_keystone(self):
502513
r = requests.get(os.getenv("PIFPAF_KEYSTONE_HTTP_URL"))
503514
self.assertEqual(300, r.status_code)
504515

516+
@testtools.skipUnless(_has_rados(), "Rados not found")
505517
@testtools.skipUnless(shutil.which("ceph-mon"),
506518
"Ceph Monitor not found")
507519
@testtools.skipUnless(shutil.which("ceph-osd"),

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ deps = .[test,ceph,gnocchi]
1818
passenv = TMPDIR_FOR_XATTR
1919
setenv =
2020
PYTHONPATH={envsitepackagesdir}:/usr/lib/python3/dist-packages/
21+
VIRTUALENV_SETUPTOOLS=bundle
2122
commands = stestr run {posargs}
2223

2324
[testenv:venv]

0 commit comments

Comments
 (0)