Switch to Fedora 33 and Python 3.9

This commit is contained in:
Lumir Balhar 2020-10-12 11:54:07 +02:00
commit 61373b3322
19 changed files with 690 additions and 221 deletions

View file

@ -1,10 +1,10 @@
# This image provides a Python 3.8 environment you can use to run your Python
# This image provides a Python 3.9 environment you can use to run your Python
# applications.
FROM registry.fedoraproject.org/f32/s2i-base:latest
FROM registry.fedoraproject.org/f33/s2i-base:latest
EXPOSE 8080
ENV PYTHON_VERSION=3.8 \
ENV PYTHON_VERSION=3.9 \
PATH=$HOME/.local/bin/:$PATH \
PYTHONUNBUFFERED=1 \
PYTHONIOENCODING=UTF-8 \
@ -29,13 +29,13 @@ on most platforms."
LABEL summary="$SUMMARY" \
description="$DESCRIPTION" \
io.k8s.description="$DESCRIPTION" \
io.k8s.display-name="Python 3.8" \
io.k8s.display-name="Python 3.9" \
io.openshift.expose-services="8080:http" \
io.openshift.tags="builder,python,python38,python-38,rh-python38" \
io.openshift.tags="builder,python,python39,python-39,rh-python39" \
com.redhat.component="$NAME" \
name="$FGC/$NAME" \
version="$VERSION" \
usage="s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.8/test/setup-test-app/ $FGC/$NAME python-sample-app" \
usage="s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.9/test/setup-test-app/ $FGC/$NAME python-sample-app" \
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
RUN INSTALL_PKGS="python3 python3-devel python3-setuptools python3-pip nss_wrapper \
@ -57,7 +57,7 @@ COPY ./root/ /
# - In order to drop the root user, we have to make some directories world
# writable as OpenShift default security model is to run the container
# under random UID.
RUN python3.8 -m venv ${APP_ROOT} && \
RUN python3.9 -m venv ${APP_ROOT} && \
chown -R 1001:0 ${APP_ROOT} && \
fix-permissions ${APP_ROOT} -P

View file

@ -1,7 +1,7 @@
Python 3.8 container image
Python 3.9 container image
===================
This container image includes Python 3.8 as a [S2I](https://github.com/openshift/source-to-image) base image for your Python 3.8 applications.
This container image includes Python 3.9 as a [S2I](https://github.com/openshift/source-to-image) base image for your Python 3.9 applications.
Users can choose between RHEL and CentOS based builder images.
The RHEL images are available in the [Red Hat Container Catalog](https://access.redhat.com/containers/),
the CentOS images are available on [Docker Hub](https://hub.docker.com/r/centos/),
@ -14,8 +14,8 @@ Note: while the examples in this README are calling `podman`, you can replace an
Description
-----------
Python 3.8 available as container is a base platform for
building and running various Python 3.8 applications and frameworks.
Python 3.9 available as container is a base platform for
building and running various Python 3.9 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
@ -32,18 +32,18 @@ the nodejs itself is included just to make the npm work.
Usage
---------------------
For this, we will assume that you are using the supported image, available via `python:3.8` imagestream tag in Openshift.
Building a simple [python-sample-app](https://github.com/sclorg/s2i-python-container/tree/master/3.8/test/setup-test-app) application
For this, we will assume that you are using the supported image, available via `python:3.9` imagestream tag in Openshift.
Building a simple [python-sample-app](https://github.com/sclorg/s2i-python-container/tree/master/3.9/test/setup-test-app) application
in Openshift can be achieved with the following step:
```
oc new-app python:3.8~https://github.com/sclorg/s2i-python-container.git --context-dir=3.8/test/setup-test-app/
oc new-app python:3.9~https://github.com/sclorg/s2i-python-container.git --context-dir=3.9/test/setup-test-app/
```
The same application can also be built using the standalone [S2I](https://github.com/openshift/source-to-image) application on systems that have it available:
```
$ s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.8/test/setup-test-app/ <image_name> python-sample-app
$ s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.9/test/setup-test-app/ <image_name> python-sample-app
```
Where `<image_name>` is the s2i-python image you [downloaded from RHEL, Centos or Fedora registry](../README.md#Download) or [built](../README.md#Build) from these sources. For example ubi8/python-36, centos/python-36-centos7 or f31/python3.
@ -86,7 +86,7 @@ file inside your source code repository.
If using `setup.py` for installing the application, the `MODULE_NAME` part
can be read from there. For an example, see
[setup-test-app](https://github.com/sclorg/s2i-python-container/tree/master/3.8/test/setup-test-app).
[setup-test-app](https://github.com/sclorg/s2i-python-container/tree/master/3.9/test/setup-test-app).
* **APP_HOME**

View file

@ -4,6 +4,6 @@
unset BASH_ENV PROMPT_COMMAND ENV
if head "/etc/redhat-release" | grep -q "^CentOS Linux release 7" || \
head "/etc/redhat-release" | grep -q "^Red Hat Enterprise Linux\( Server\)\? release 7"; then
source scl_source enable httpd24 $NODEJS_SCL rh-python38
source scl_source enable httpd24 $NODEJS_SCL rh-python39
fi
source /opt/app-root/bin/activate

View file

@ -11,7 +11,7 @@ function should_collectstatic() {
function virtualenv_bin() {
# New versions of Python (>3.6) should use venv module
# from stdlib instead of virtualenv package
python3.8 -m venv $1
python3.9 -m venv $1
}
# Install pipenv or micropipenv to the separate virtualenv to isolate it

View file

@ -5,12 +5,12 @@ NAMESPACE=centos
[[ $DISTRO =~ rhel* ]] && NAMESPACE=rhscl
cat <<EOF
This is a S2I python-3.8 ${DISTRO} base image:
This is a S2I python-3.9 ${DISTRO} base image:
To use it, install S2I: https://github.com/openshift/source-to-image
Sample invocation:
s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.8/test/setup-test-app/ ${NAMESPACE}/python-38-${DISTRO}7 python-sample-app
s2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.9/test/setup-test-app/ ${NAMESPACE}/python-39-${DISTRO}7 python-sample-app
You can then run the resulting image via:

69
test/check_imagestreams.py Executable file
View file

@ -0,0 +1,69 @@
#!/bin/env python3
import sys
import json
import logging
from pathlib import Path
from typing import Dict
IMAGESTREAMS_DIR: str = "imagestreams"
class ImageStreamChecker(object):
version: str = ""
results: Dict = {}
def __init__(self, version: str):
self.version = version
def load_json_file(self, filename: Path):
with open(str(filename)) as f:
return json.load(f)
def check_version(self, json_dict: Dict):
res = []
for tags in json_dict["spec"]["tags"]:
# The name can be"<stream>" or "<stream>-elX" or "<stream>-ubiX"
if (tags["name"] == self.version or
tags["name"].startswith(self.version + '-')):
res.append(tags)
return res
def check_latest_tag(self, json_dict: Dict):
latest_tag_correct: bool = False
for tags in json_dict["spec"]["tags"]:
if tags["name"] != "latest":
continue
# The latest can link to either "<stream>" or "<stream>-elX" or "<stream>-ubiX"
if tags["from"]["name"] == self.version or tags["from"]["name"].startswith(self.version + '-'):
latest_tag_correct = True
return latest_tag_correct
def check_imagestreams(self):
p = Path(".")
json_files = p.glob(f"{IMAGESTREAMS_DIR}/*.json")
if not json_files:
print(f"No json files present in {IMAGESTREAMS_DIR}.")
return 0
for f in json_files:
print(f"Checking file {str(f)}.")
json_dict = self.load_json_file(f)
if not (self.check_version(json_dict) and self.check_latest_tag(json_dict)):
print(f"The latest version is not present in {str(f)} or in latest tag.")
self.results[f] = False
if self.results:
return 1
print("Imagestreams contains the latest version.")
return 0
if __name__ == "__main__":
if len(sys.argv) != 2:
logging.fatal("%s: %s", sys.argv[0], "VERSION as an argument was not provided")
sys.exit(1)
print(f"Version to check is {sys.argv[1]}.")
isc = ImageStreamChecker(version=sys.argv[1])
sys.exit(isc.check_imagestreams())

View file

@ -0,0 +1,153 @@
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "python",
"annotations": {
"openshift.io/display-name": "Python"
}
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": {
"openshift.io/display-name": "Python (Latest)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python applications on UBI. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of Python available on OpenShift, including major version updates.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "ImageStreamTag",
"name": "3.8-ubi8"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.8-ubi8",
"annotations": {
"openshift.io/display-name": "Python 3.8 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.8 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:3.8,python",
"version": "3.8",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.access.redhat.com/ubi8/python-38:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.8-ubi7",
"annotations": {
"openshift.io/display-name": "Python 3.8 (UBI 7)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.8 applications on UBI 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:3.8,python",
"version": "3.8",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.access.redhat.com/ubi7/python-38:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.6-ubi8",
"annotations": {
"openshift.io/display-name": "Python 3.6 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.6 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.6/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:3.6,python",
"version": "3.6",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.access.redhat.com/ubi8/python-36:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "2.7-ubi8",
"annotations": {
"openshift.io/display-name": "Python 2.7 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 2.7 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/2.7/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:2.7,python",
"version": "2.7",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.access.redhat.com/ubi8/python-27:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "2.7-ubi7",
"annotations": {
"openshift.io/display-name": "Python 2.7 (UBI 7)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 2.7 applications on UBI 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/2.7/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:2.7,python",
"version": "2.7",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.access.redhat.com/ubi7/python-27:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "2.7",
"annotations": {
"openshift.io/display-name": "Python 2.7",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 2.7 applications on CentOS 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/2.7/README.md.",
"iconClass": "icon-python",
"tags": "builder,python,hidden",
"supports":"python:2.7,python",
"version": "2.7",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "docker.io/centos/python-27-centos7:latest"
},
"referencePolicy": {
"type": "Local"
}
}
]
}
}

View file

@ -14,7 +14,7 @@
"annotations": {
"openshift.io/display-name": "Python (Latest)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of Python available on OpenShift, including major version updates.",
"description": "Build and run Python applications on UBI. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of Python available on OpenShift, including major version updates.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python",
@ -22,16 +22,16 @@
},
"from": {
"kind": "ImageStreamTag",
"name": "3.8"
"name": "3.8-ubi8"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.8",
"name": "3.8-ubi8",
"annotations": {
"openshift.io/display-name": "Python 3.8",
"openshift.io/display-name": "Python 3.8 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.8 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.",
"iconClass": "icon-python",
@ -49,9 +49,9 @@
}
},
{
"name": "3.6",
"name": "3.6-ubi8",
"annotations": {
"openshift.io/display-name": "Python 3.6",
"openshift.io/display-name": "Python 3.6 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.6 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.6/README.md.",
"iconClass": "icon-python",
@ -69,9 +69,9 @@
}
},
{
"name": "2.7",
"name": "2.7-ubi8",
"annotations": {
"openshift.io/display-name": "Python 2.7",
"openshift.io/display-name": "Python 2.7 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 2.7 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/2.7/README.md.",
"iconClass": "icon-python",

View file

@ -0,0 +1,173 @@
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "python",
"annotations": {
"openshift.io/display-name": "Python"
}
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": {
"openshift.io/display-name": "Python (Latest)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python applications on UBI. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of Python available on OpenShift, including major version updates.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "ImageStreamTag",
"name": "3.8-ubi8"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.8-ubi8",
"annotations": {
"openshift.io/display-name": "Python 3.8 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.8 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:3.8,python",
"version": "3.8",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/ubi8/python-38:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.8-ubi7",
"annotations": {
"openshift.io/display-name": "Python 3.8 (UBI 7)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.8 applications on UBI 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:3.8,python",
"version": "3.8",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/ubi7/python-38:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.8",
"annotations": {
"openshift.io/display-name": "Python 3.8",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.8 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.",
"iconClass": "icon-python",
"tags": "builder,python,hidden",
"supports":"python:3.8,python",
"version": "3.8",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/rhscl/python-38-rhel7:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.6-ubi8",
"annotations": {
"openshift.io/display-name": "Python 3.6 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.6 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.6/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:3.6,python",
"version": "3.6",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/ubi8/python-36:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "2.7-ubi8",
"annotations": {
"openshift.io/display-name": "Python 2.7 (UBI 8)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 2.7 applications on UBI 8. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/2.7/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:2.7,python",
"version": "2.7",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/ubi8/python-27:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "2.7-ubi7",
"annotations": {
"openshift.io/display-name": "Python 2.7 (UBI 7)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 2.7 applications on UBI 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/2.7/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:2.7,python",
"version": "2.7",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/ubi7/python-27:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "2.7",
"annotations": {
"openshift.io/display-name": "Python 2.7",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 2.7 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/2.7/README.md.",
"iconClass": "icon-python",
"tags": "builder,python,hidden",
"supports":"python:2.7,python",
"version": "2.7",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/rhscl/python-27-rhel7:latest"
},
"referencePolicy": {
"type": "Local"
}
}
]
}
}

View file

@ -1,93 +0,0 @@
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "python",
"annotations": {
"openshift.io/display-name": "Python"
}
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": {
"openshift.io/display-name": "Python (Latest)",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.\n\nWARNING: By selecting this tag, your application will automatically update to use the latest version of Python available on OpenShift, including major version updates.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "ImageStreamTag",
"name": "3.8"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.8",
"annotations": {
"openshift.io/display-name": "Python 3.8",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.8 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.8/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:3.8,python",
"version": "3.8",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/rhscl/python-38-rhel7:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "3.6",
"annotations": {
"openshift.io/display-name": "Python 3.6",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 3.6 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/3.6/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:3.6,python",
"version": "3.6",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/rhscl/python-36-rhel7:latest"
},
"referencePolicy": {
"type": "Local"
}
},
{
"name": "2.7",
"annotations": {
"openshift.io/display-name": "Python 2.7",
"openshift.io/provider-display-name": "Red Hat, Inc.",
"description": "Build and run Python 2.7 applications on RHEL 7. For more information about using this builder image, including OpenShift considerations, see https://github.com/sclorg/s2i-python-container/blob/master/2.7/README.md.",
"iconClass": "icon-python",
"tags": "builder,python",
"supports":"python:2.7,python",
"version": "2.7",
"sampleRepo": "https://github.com/sclorg/django-ex.git"
},
"from": {
"kind": "DockerImage",
"name": "registry.redhat.io/rhscl/python-27-rhel7:latest"
},
"referencePolicy": {
"type": "Local"
}
}
]
}
}

View file

@ -11,4 +11,4 @@ requests = "==2.20.0"
pytest = ">=2.8.0"
[requires]
python_version = "3.8"
python_version = "3.9"

View file

@ -1,11 +1,11 @@
{
"_meta": {
"hash": {
"sha256": "f1d3ff05e8c9143e751780c871a656ef8794c15cf6e8ef08cfa211ad25a24320"
"sha256": "9d47e9d2d35583e081cf783e9421e75fafb102d07969ad6f74546f48db3a8101"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
"python_version": "3.9"
},
"sources": [
{
@ -18,10 +18,10 @@
"default": {
"certifi": {
"hashes": [
"sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3",
"sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"
"sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3",
"sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"
],
"version": "==2019.11.28"
"version": "==2020.6.20"
},
"chardet": {
"hashes": [
@ -39,6 +39,7 @@
"sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626",
"sha256:cd4a810dd51bf497552cf3f863b575dabd73d6ad6a91075b65936b151cbf4f9c"
],
"markers": "python_version >= '3.4'",
"version": "==20.0.4"
},
"idna": {
@ -56,78 +57,89 @@
"index": "pypi",
"version": "==2.20.0"
},
"testapp": {
"editable": true,
"path": "."
},
"urllib3": {
"hashes": [
"sha256:2393a695cd12afedd0dcb26fe5d50d0cf248e5a66f75dbd89a3d4eb333a61af4",
"sha256:a637e5fae88995b256e3409dc4d52c2e2e0ba32c42a6365fee8bbd2238de3cfb"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' and python_version < '4'",
"version": "==1.24.3"
}
},
"develop": {
"attrs": {
"hashes": [
"sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
"sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"
"sha256:26b54ddbbb9ee1d34d5d3668dd37d6cf74990ab23c828c2888dccdceee395594",
"sha256:fce7fc47dfc976152e82d53ff92fa0407700c21acd20886a13777a0d20e655dc"
],
"version": "==19.3.0"
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.2.0"
},
"more-itertools": {
"iniconfig": {
"hashes": [
"sha256:b84b238cce0d9adad5ed87e745778d20a3f8487d0f0cb8b8a586816c7496458d",
"sha256:c833ef592a0324bcc6a60e48440da07645063c453880c9477ceb22490aec1564"
"sha256:80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437",
"sha256:e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69"
],
"version": "==8.0.2"
"version": "==1.0.1"
},
"packaging": {
"hashes": [
"sha256:28b924174df7a2fa32c1953825ff29c61e2f5e082343165438812f00d3a7fc47",
"sha256:d9551545c6d761f3def1677baf08ab2a3ca17c56879e70fecba2fc4dde4ed108"
"sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8",
"sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"
],
"version": "==19.2"
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.4"
},
"pluggy": {
"hashes": [
"sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0",
"sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.13.1"
},
"py": {
"hashes": [
"sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa",
"sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"
"sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2",
"sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"
],
"version": "==1.8.0"
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.9.0"
},
"pyparsing": {
"hashes": [
"sha256:20f995ecd72f2a1f4bf6b072b63b22e2eb457836601e76d6e5dfcd75436acc1f",
"sha256:4ca62001be367f01bd3e92ecbb79070272a9d4964dce6a48a82ff0b8bc7e683a"
"sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
"sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
],
"version": "==2.4.5"
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.4.7"
},
"pytest": {
"hashes": [
"sha256:63344a2e3bce2e4d522fd62b4fdebb647c019f1f9e4ca075debbd13219db4418",
"sha256:f67403f33b2b1d25a6756184077394167fe5e2f9d8bdaab30707d19ccec35427"
"sha256:7a8190790c17d79a11f847fba0b004ee9a8122582ebff4729a082c109e81a4c9",
"sha256:8f593023c1a0f916110285b6efd7f99db07d59546e3d8c36fc60e2ab05d3be92"
],
"index": "pypi",
"version": "==5.3.1"
"version": "==6.1.1"
},
"six": {
"hashes": [
"sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd",
"sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66"
"sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
"sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
],
"version": "==1.13.0"
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.15.0"
},
"wcwidth": {
"toml": {
"hashes": [
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
"sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c"
"sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f",
"sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88"
],
"version": "==0.1.7"
"version": "==0.10.1"
}
}
}

View file

@ -13,7 +13,7 @@ packages=("pip" "setuptools" "wheel")
for pkg in ${packages[@]}; do
# grep returns exit code 1 if the output contains only one line starting
# with "Requirement already …" which means that the package is updated
python -m pip install -U --no-python-version-warning $pkg 2>&1 | grep -v "^Requirement already up-to-date: "
python -m pip install -U --no-deps --no-python-version-warning $pkg 2>&1 | grep -v "^Requirement already up-to-date: "
if [ $? -eq 0 ]; then
echo "ERROR: Failed to upgrade '$pkg' to the latest version."
exit 1

View file

@ -11,4 +11,4 @@ requests = "==2.20.0"
pytest = ">=2.8.0"
[requires]
python_version = "3.8"
python_version = "3.9"

View file

@ -1,11 +1,11 @@
{
"_meta": {
"hash": {
"sha256": "f1d3ff05e8c9143e751780c871a656ef8794c15cf6e8ef08cfa211ad25a24320"
"sha256": "9d47e9d2d35583e081cf783e9421e75fafb102d07969ad6f74546f48db3a8101"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.8"
"python_version": "3.9"
},
"sources": [
{
@ -18,10 +18,10 @@
"default": {
"certifi": {
"hashes": [
"sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3",
"sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f"
"sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3",
"sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"
],
"version": "==2019.11.28"
"version": "==2020.6.20"
},
"chardet": {
"hashes": [
@ -39,6 +39,7 @@
"sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626",
"sha256:cd4a810dd51bf497552cf3f863b575dabd73d6ad6a91075b65936b151cbf4f9c"
],
"markers": "python_version >= '3.4'",
"version": "==20.0.4"
},
"idna": {
@ -56,78 +57,89 @@
"index": "pypi",
"version": "==2.20.0"
},
"testapp": {
"editable": true,
"path": "."
},
"urllib3": {
"hashes": [
"sha256:2393a695cd12afedd0dcb26fe5d50d0cf248e5a66f75dbd89a3d4eb333a61af4",
"sha256:a637e5fae88995b256e3409dc4d52c2e2e0ba32c42a6365fee8bbd2238de3cfb"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' and python_version < '4'",
"version": "==1.24.3"
}
},
"develop": {
"attrs": {
"hashes": [
"sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c",
"sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72"
"sha256:26b54ddbbb9ee1d34d5d3668dd37d6cf74990ab23c828c2888dccdceee395594",
"sha256:fce7fc47dfc976152e82d53ff92fa0407700c21acd20886a13777a0d20e655dc"
],
"version": "==19.3.0"
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.2.0"
},
"more-itertools": {
"iniconfig": {
"hashes": [
"sha256:b84b238cce0d9adad5ed87e745778d20a3f8487d0f0cb8b8a586816c7496458d",
"sha256:c833ef592a0324bcc6a60e48440da07645063c453880c9477ceb22490aec1564"
"sha256:80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437",
"sha256:e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69"
],
"version": "==8.0.2"
"version": "==1.0.1"
},
"packaging": {
"hashes": [
"sha256:28b924174df7a2fa32c1953825ff29c61e2f5e082343165438812f00d3a7fc47",
"sha256:d9551545c6d761f3def1677baf08ab2a3ca17c56879e70fecba2fc4dde4ed108"
"sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8",
"sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181"
],
"version": "==19.2"
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==20.4"
},
"pluggy": {
"hashes": [
"sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0",
"sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.13.1"
},
"py": {
"hashes": [
"sha256:64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa",
"sha256:dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"
"sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2",
"sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342"
],
"version": "==1.8.0"
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.9.0"
},
"pyparsing": {
"hashes": [
"sha256:20f995ecd72f2a1f4bf6b072b63b22e2eb457836601e76d6e5dfcd75436acc1f",
"sha256:4ca62001be367f01bd3e92ecbb79070272a9d4964dce6a48a82ff0b8bc7e683a"
"sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
"sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
],
"version": "==2.4.5"
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==2.4.7"
},
"pytest": {
"hashes": [
"sha256:63344a2e3bce2e4d522fd62b4fdebb647c019f1f9e4ca075debbd13219db4418",
"sha256:f67403f33b2b1d25a6756184077394167fe5e2f9d8bdaab30707d19ccec35427"
"sha256:7a8190790c17d79a11f847fba0b004ee9a8122582ebff4729a082c109e81a4c9",
"sha256:8f593023c1a0f916110285b6efd7f99db07d59546e3d8c36fc60e2ab05d3be92"
],
"index": "pypi",
"version": "==5.3.1"
"version": "==6.1.1"
},
"six": {
"hashes": [
"sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd",
"sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66"
"sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
"sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
],
"version": "==1.13.0"
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==1.15.0"
},
"wcwidth": {
"toml": {
"hashes": [
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
"sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c"
"sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f",
"sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88"
],
"version": "==0.1.7"
"version": "==0.10.1"
}
}
}

View file

@ -187,6 +187,16 @@ test_application() {
cleanup_app
}
test_latest_imagestreams() {
local result=1
info "Testing the latest version in imagestreams"
# Switch to root directory of a container
pushd "${test_dir}/../.." >/dev/null || return 1
ct_check_latest_imagestreams
result=$?
popd >/dev/null || return 1
check_result $result
}
# Since we built the candidate image locally, we don't want S2I attempt to pull
# it from Docker hub
@ -224,6 +234,8 @@ for app in ${@:-${WEB_APPS[@]}}; do
# test application with init wrapper
CONTAINER_ARGS="-e ENABLE_INIT_WRAPPER=true" test_application
test_latest_imagestreams
info "All tests for the ${app} finished successfully."
cleanup ${app}
done

View file

@ -145,7 +145,7 @@ function ct_os_get_pod_status() {
# Arguments: pod_prefix - prefix or whole ID of the pod
function ct_os_get_build_pod_status() {
local pod_prefix="${1}" ; shift
local query="custom-columns=NAME:.metadata.name,Ready:status.containerStatuses[0].state.terminated.reason"
local query="custom-columns=NAME:.metadata.name,Ready:status.phase"
oc get pods -o "$query" | grep -e "${pod_prefix}" | grep -E "\-build\s" \
| sort -u | awk '{print $2}' | tail -n 1
}
@ -193,7 +193,7 @@ function ct_os_wait_pod_ready() {
if ct_os_get_all_pods_name | grep -E "${pod_prefix}.*-build"; then
SECONDS=0
echo -n "Waiting for ${pod_prefix} build pod to finish ..."
while ! [ "$(ct_os_get_build_pod_status "${pod_prefix}")" == "Completed" ] ; do
while ! [ "$(ct_os_get_build_pod_status "${pod_prefix}")" == "Succeeded" ] ; do
echo -n "."
[ "${SECONDS}" -gt "${timeout}0" ] && echo " FAIL" && return 1
sleep 3
@ -219,7 +219,7 @@ function ct_os_wait_rc_ready() {
local pod_prefix="${1}" ; shift
local timeout="${1}" ; shift
SECONDS=0
echo -n "Waiting for ${pod_prefix} pod becoming ready ..."
echo -n "Waiting for ${pod_prefix} having desired numbers of replicas ..."
while ! test "$( (oc get --no-headers statefulsets; oc get --no-headers rc) 2>/dev/null \
| grep "^${pod_prefix}" | awk '$2==$3 {print "ready"}')" == "ready" ; do
echo -n "."
@ -413,6 +413,7 @@ function ct_os_install_in_centos() {
bash-completion origin-clients docker origin-clients
}
# ct_os_cluster_up [DIR, IS_PUBLIC, CLUSTER_VERSION]
# --------------------
# Runs the local OpenShift cluster using 'oc cluster up' and logs in as developer.
@ -604,8 +605,7 @@ function ct_os_test_s2i_app_func() {
local check_command=${4}
local oc_args=${5:-}
local image_name_no_namespace=${image_name##*/}
local service_name="${image_name_no_namespace}-testing"
local image_tagged="${image_name_no_namespace}:${VERSION}"
local service_name="${image_name_no_namespace%%:*}-testing"
local namespace
if [ $# -lt 4 ] || [ -z "${1}" ] || [ -z "${2}" ] || [ -z "${3}" ] || [ -z "${4}" ]; then
@ -618,16 +618,20 @@ function ct_os_test_s2i_app_func() {
namespace=${CT_NAMESPACE:-"$(oc project -q)"}
# Create a specific imagestream tag for the image so that oc cannot use anything else
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'true' ] ; then
echo "Importing image ${image_name} as ${namespace}/${image_tagged}"
# Use --reference-policy=local to pull remote image content to the cluster
# Works around the issue of builder pods not having access to registry.redhat.io
oc tag --source=docker "${image_name}" "${namespace}/${image_tagged}" --insecure=true --reference-policy=local
ct_os_wait_stream_ready "${image_tagged}" "${namespace}"
if [ "${CT_EXTERNAL_REGISTRY:-false}" == 'true' ] ; then
ct_os_import_image_ocp4 "${image_name}" "${image_name_no_namespace}"
else
echo "Uploading image ${image_name} as ${image_tagged}"
ct_os_upload_image "${image_name}" "${image_tagged}"
# Create a specific imagestream tag for the image so that oc cannot use anything else
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'true' ] ; then
echo "Importing image ${image_name} as ${namespace}/${image_name_no_namespace}"
# Use --reference-policy=local to pull remote image content to the cluster
# Works around the issue of builder pods not having access to registry.redhat.io
oc tag --source=docker "${image_name}" "${namespace}/${image_name_no_namespace}" --insecure=true --reference-policy=local
ct_os_wait_stream_ready "${image_name_no_namespace}" "${namespace}"
else
echo "Uploading image ${image_name} as ${image_name_no_namespace}"
ct_os_upload_image "${image_name}" "${image_name_no_namespace}"
fi
fi
local app_param="${app}"
@ -638,7 +642,7 @@ function ct_os_test_s2i_app_func() {
fi
# shellcheck disable=SC2086
ct_os_deploy_s2i_image "${image_tagged}" "${app_param}" \
ct_os_deploy_s2i_image "${image_name_no_namespace}" "${app_param}" \
--context-dir="${context_dir}" \
--name "${service_name}" \
${oc_args}
@ -752,27 +756,30 @@ function ct_os_test_template_app_func() {
ct_os_new_project
namespace=${CT_NAMESPACE:-"$(oc project -q)"}
# Create a specific imagestream tag for the image so that oc cannot use anything else
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'true' ] ; then
echo "Importing image ${image_name} as ${image_tagged}"
# Use --reference-policy=local to pull remote image content to the cluster
# Works around the issue of builder pods not having access to registry.redhat.io
oc tag --source=docker "${image_name}" "${namespace}/${image_tagged}" --insecure=true --reference-policy=local
ct_os_wait_stream_ready "${image_tagged}" "${namespace}"
if [ "${CT_EXTERNAL_REGISTRY:-false}" == 'true' ] ; then
ct_os_import_image_ocp4 "${image_name}" "${image_tagged}"
else
echo "Uploading image ${image_name} as ${image_tagged}"
ct_os_upload_image "${image_name}" "${image_tagged}"
if [ "${CT_SKIP_UPLOAD_IMAGE:-false}" == 'true' ] ; then
echo "Importing image ${image_name} as ${image_tagged}"
# Use --reference-policy=local to pull remote image content to the cluster
# Works around the issue of builder pods not having access to registry.redhat.io
oc tag --source=docker "${image_name}" "${namespace}/${image_tagged}" --insecure=true --reference-policy=local
ct_os_wait_stream_ready "${image_tagged}" "${namespace}"
else
echo "Uploading image ${image_name} as ${image_tagged}"
ct_os_upload_image "${image_name}" "${image_tagged}"
# upload also other images, that template might need (list of pairs in the format <image>|<tag>
local image_tag_a
local i_t
for i_t in ${other_images} ; do
echo "${i_t}"
IFS='|' read -ra image_tag_a <<< "${i_t}"
docker pull "${image_tag_a[0]}"
ct_os_upload_image "${image_tag_a[0]}" "${image_tag_a[1]}"
done
# upload also other images, that template might need (list of pairs in the format <image>|<tag>
local image_tag_a
local i_t
for i_t in ${other_images} ; do
echo "${i_t}"
IFS='|' read -ra image_tag_a <<< "${i_t}"
docker pull "${image_tag_a[0]}"
ct_os_upload_image "${image_tag_a[0]}" "${image_tag_a[1]}"
done
fi
fi
# get the template file from remote or local location; if not found, it is

View file

@ -18,7 +18,7 @@ function test_python_imagestream() {
*) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
esac
ct_os_test_image_stream_quickstart "${THISDIR}/imagestreams/python-${OS}.json" \
ct_os_test_image_stream_quickstart "${THISDIR}/imagestreams/python-${OS%[0-9]*}.json" \
'https://raw.githubusercontent.com/sclorg/django-ex/master/openshift/templates/django-postgresql.json' \
"${IMAGE_NAME}" \
'python' \

View file

@ -25,6 +25,7 @@ EXPECTED_EXIT_CODE=0
# Uses: $CID_FILE_DIR - path to directory containing cid_files
# Uses: $EXPECTED_EXIT_CODE - expected container exit code
function ct_cleanup() {
ct_show_resources
for cid_file in "$CID_FILE_DIR"/* ; do
local container
container=$(cat "$cid_file")
@ -584,6 +585,8 @@ ct_get_public_image_name() {
public_image_name=$registry/rhel8/$base_image_name-${version//./}
elif [ "x$os" == "xcentos7" ]; then
public_image_name=$registry/centos/$base_image_name-${version//./}-centos7
elif [ "x$os" == "xcentos8" ]; then
public_image_name=$registry/centos/$base_image_name-${version//./}-centos8
fi
echo "$public_image_name"
@ -773,4 +776,125 @@ ct_check_image_availability() {
fi
}
# ct_check_latest_imagestreams
# -----------------------------
# Check if the latest version present in Makefile in the variable VERSIONS
# is present in all imagestreams.
# Also the latest tag in the imagestreams has to contain the latest version
ct_check_latest_imagestreams() {
local latest_version=
local test_lib_dir=
# We only maintain imagestreams for RHEL and CentOS (Community)
if [[ "$OS" =~ ^fedora.* ]] ; then
echo "Imagestreams for Fedora are not maintained, skipping ct_check_latest_imagestreams"
return 0
fi
# Check only lines which starts with VERSIONS
latest_version=$(grep '^VERSIONS' Makefile | rev | cut -d ' ' -f 1 | rev )
# Fall back to previous version if the latest is excluded for this OS
[ -f "$latest_version/.exclude-$OS" ] && latest_version=$(grep '^VERSIONS' Makefile | rev | cut -d ' ' -f 2 | rev )
# Only test the imagestream once, when the version matches
# ignore the SC warning, $VERSION is always available
# shellcheck disable=SC2153
if [ "$latest_version" == "$VERSION" ]; then
test_lib_dir=$(dirname "$(readlink -f "$0")")
python3 "${test_lib_dir}/check_imagestreams.py" "$latest_version"
else
echo "Image version $VERSION is not latest, skipping ct_check_latest_imagestreams"
fi
}
# ct_show_resources
# ----------------
# Prints the available resources
ct_show_resources()
{
echo "Resources info:"
echo "Memory:"
free -h
echo "Storage:"
df -h
echo "CPU"
lscpu
}
# ct_test_app_dockerfile
# -----------------------------
# Argument: dockerfile - path to a Dockerfile that will be used for building an image
# (must work with an application directory called 'app-src')
# Argument: app_url - git URI with a testing application
# Argument: body_regexp - PCRE regular expression that must match the response body
# Argument: app_dir - name of the application directory that is used in the Dockerfile
# Argument: port - Optional port number (default: 8080)
ct_test_app_dockerfile() {
local dockerfile=$1
local app_url=$2
local expected_text=$3
local app_dir=$4 # this is a directory that must match with the name in the Dockerfile
local port=${5:-8080}
local app_image_name=myapp
local ret
local cname=app_dockerfile
if [ -z "$app_dir" ] ; then
echo "ERROR: Option app_dir not set. Terminating the Dockerfile build."
return 1
fi
if ! [ -r "${dockerfile}" ] || ! [ -s "${dockerfile}" ] ; then
echo "ERROR: Dockerfile ${dockerfile} does not exist or is empty."
echo "Terminating the Dockerfile build."
return 1
fi
CID_FILE_DIR=${CID_FILE_DIR:-$(mktemp -d)}
local dockerfile_abs
dockerfile_abs=$(readlink -f "${dockerfile}")
tmpdir=$(mktemp -d)
pushd "$tmpdir" >/dev/null
cp "${dockerfile_abs}" Dockerfile
# Rewrite the source image to what we test
sed -i -e "s|^FROM.*$|FROM $IMAGE_NAME|" Dockerfile
# a bit more verbose, but should help debugging failures
echo "Using this Dockerfile:"
cat Dockerfile
if ! git clone "${app_url}" "${app_dir}" ; then
echo "ERROR: Git repository ${app_url} cannot be cloned into ${app_dir}."
echo "Terminating the Dockerfile build."
return 1
fi
echo "Building '${app_image_name}' image using docker build"
if ! docker build --no-cache=true -t "${app_image_name}" . ; then
echo "ERROR: The image cannot be built from ${dockerfile} and application ${app_url}."
echo "Terminating the Dockerfile build."
return 1
fi
if ! docker run -d --cidfile="${CID_FILE_DIR}/app_dockerfile" --rm "${app_image_name}" ; then
echo "ERROR: The image ${app_image_name} cannot be run for ${dockerfile} and application ${app_url}."
echo "Terminating the Dockerfile build."
return 1
fi
echo "Waiting for ${app_image_name} to start"
ct_wait_for_cid "${CID_FILE_DIR}/app_dockerfile"
ip="$(ct_get_cip "${cname}")"
ct_test_response "http://$ip:${port}" 200 "${expected_text}"
ret=$?
# cleanup
docker kill "$(ct_get_cid "${cname}")"
sleep 2
docker rmi "${app_image_name}"
popd >/dev/null
rm -rf "${tmpdir}"
rm -f "${CID_FILE_DIR}/${cname}"
return $ret
}
# vim: set tabstop=2:shiftwidth=2:expandtab: