This repository has been archived by the owner on May 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
- Loading branch information
Hunor Csomortáni
committed
Mar 1, 2019
1 parent
57f83bd
commit cbeacfa
Showing
11 changed files
with
533 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export OMPS_INT_TEST_OMPS_URL='https://omps.example.com/v1' | ||
export OMPS_INT_TEST_OMPS_ORG='community-operators' | ||
export OMPS_INT_TEST_QUAY_URL='https://quay.io/api/v1' | ||
export OMPS_INT_TEST_QUAY_USER='bob' | ||
export OMPS_INT_TEST_QUAY_PASSWD='<cli password>' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,6 @@ venv.bak/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# direnv | ||
.envrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Integration Tests for OMPS | ||
|
||
This directory stores integration tests for OMPS, one sub-directory for each | ||
feature. | ||
|
||
Fixtures can be found in `conftest.py`. Utility functions and classes in | ||
`utils.py`. | ||
|
||
|
||
## Configuration | ||
|
||
Configuring the OMPS and Quay instances used by the tests can be done using | ||
a bunch of `OMPS_INT_TEST_*` prefixed environment variables. | ||
|
||
`OMPS_INT_TEST_OMPS_URL`: URL of the OMPS API to be tested. | ||
For example: `https://omps.example.com/v1`. | ||
|
||
`OMPS_INT_TEST_OMPS_ORG`: Organization configured in the OMPS instance tested. | ||
For example: 'community-operators'. | ||
|
||
`OMPS_INT_TEST_QUAY_URL`: URL of the QUAY API to be used during testing. | ||
For example: `https://quay.io/api/v1`. | ||
|
||
`OMPS_INT_TEST_QUAY_USER`: User to authenticate with Quay. | ||
|
||
`OMPS_INT_TEST_QUAY_PASSWD`: Password to authenticate with Quay. | ||
|
||
All the variables above could be set using [direnv](https://direnv.net/), when | ||
one navigates to the OMPS repo. See `.envrc.example` for a starting point. | ||
|
||
|
||
## Running the tests | ||
|
||
Tests can be triggered from the OMPS repo root with: | ||
|
||
```bash | ||
tox -e integration | ||
``` | ||
|
||
Note, that the `integration` environment is not part of the default `tox` | ||
envlist. | ||
|
||
`REQUESTS_CA_BUNDLE` is set in `tox.ini` for the `integration` environment in | ||
order to make custom certificates available in the virtual environment | ||
created. One might want to tweak or delete this value, depending on the OMPS | ||
instance being tested. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Copyright (C) 2019 Red Hat, Inc | ||
# see the LICENSE file for license | ||
# | ||
|
||
import os | ||
import pytest | ||
from .utils import OMPS, QuayAppRegistry | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def omps(): | ||
"""OMPS used for testing. | ||
Args: None. | ||
Returns: An instance of OMPS. | ||
Raises: None. | ||
""" | ||
api_url = os.getenv('OMPS_INT_TEST_OMPS_URL') | ||
organization = os.getenv('OMPS_INT_TEST_OMPS_ORG') | ||
|
||
return OMPS(api_url, organization) | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def quay_app_registry(): | ||
"""Quay App Registry used for testing. | ||
Args: None. | ||
Yields: An instance of QuayAppRegistry. | ||
Raises: None. | ||
""" | ||
app_registry = QuayAppRegistry(os.getenv('OMPS_INT_TEST_QUAY_URL')) | ||
username = os.getenv('OMPS_INT_TEST_QUAY_USER') | ||
password = os.getenv('OMPS_INT_TEST_QUAY_PASSWD') | ||
app_registry.login(username, password) | ||
|
||
yield app_registry | ||
|
||
organization = os.getenv('OMPS_INT_TEST_OMPS_ORG') | ||
app_registry.clean_up(organization, 'int-test') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: catalogsourceconfigs.marketplace.redhat.com | ||
annotations: | ||
displayName: Catalog Source Config | ||
description: Represents a CatalogSourceConfig. | ||
spec: | ||
group: marketplace.redhat.com | ||
names: | ||
kind: CatalogSourceConfig | ||
listKind: CatalogSourceConfigList | ||
plural: catalogsourceconfigs | ||
singular: catalogsourceconfig | ||
shortNames: | ||
- csc | ||
scope: Namespaced | ||
version: v1alpha1 | ||
additionalPrinterColumns: | ||
- name: TargetNamespace | ||
type: string | ||
description: The namespace where the operators will be enabled | ||
JSONPath: .spec.targetNamespace | ||
- name: Packages | ||
type: string | ||
description: List of operator(s) which will be enabled in the target namespace | ||
JSONPath: .spec.packages | ||
- name: Status | ||
type: string | ||
description: Current status of the CatalogSourceConfig | ||
JSONPath: .status.currentPhase.phase.name | ||
- name: Message | ||
type: string | ||
description: Message associated with the current status | ||
JSONPath: .status.currentPhase.phase.message | ||
- name: Age | ||
type: date | ||
JSONPath: .metadata.creationTimestamp | ||
validation: | ||
openAPIV3Schema: | ||
properties: | ||
spec: | ||
type: object | ||
description: Spec for a CatalogSourceConfig | ||
required: | ||
- targetNamespace | ||
- packages | ||
properties: | ||
targetNamespace: | ||
type: string | ||
description: The namespace where the operators will be enabled | ||
packages: | ||
type: string | ||
description: Comma separated list of operator(s) without spaces which will be enabled in the target namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#! validate-crd: deploy/chart/templates/0000_30_02-clusterserviceversion.crd.yaml | ||
#! parse-kind: ClusterServiceVersion | ||
apiVersion: operators.coreos.com/v1alpha1 | ||
kind: ClusterServiceVersion | ||
metadata: | ||
name: marketplace-operator.v0.0.1 | ||
namespace: placeholder | ||
spec: | ||
displayName: marketplace-operator | ||
description: Short description. | ||
keywords: ['marketplace', 'catalog', 'olm', 'admin'] | ||
version: 0.0.1 | ||
maturity: alpha | ||
maintainers: | ||
- name: AOS Marketplace Team | ||
email: aos-marketplace@redhat.com | ||
provider: | ||
name: Red Hat | ||
labels: | ||
name: marketplace-operator | ||
selector: | ||
matchLabels: | ||
name: marketplace-operator | ||
links: | ||
- name: Markplace Operator Source Code | ||
url: https://github.com/operator-framework/operator-marketplace | ||
installModes: | ||
- supported: true | ||
type: OwnNamespace | ||
- supported: true | ||
type: SingleNamespace | ||
- supported: false | ||
type: MultiNamespace | ||
- supported: true | ||
type: AllNamespaces | ||
install: | ||
strategy: deployment | ||
spec: | ||
clusterPermissions: | ||
- serviceAccountName: marketplace-operator | ||
rules: | ||
- apiGroups: | ||
- marketplace.redhat.com | ||
resources: | ||
- "*" | ||
verbs: | ||
- "*" | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- services | ||
- configmaps | ||
verbs: | ||
- "*" | ||
- apiGroups: | ||
- operators.coreos.com | ||
resources: | ||
- catalogsources | ||
verbs: | ||
- "*" | ||
deployments: | ||
- name: marketplace-operator | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: marketplace-operator | ||
template: | ||
metadata: | ||
name: marketplace-operator | ||
labels: | ||
name: marketplace-operator | ||
spec: | ||
serviceAccountName: marketplace-operator | ||
containers: | ||
- name: marketplace-operator | ||
image: quay.io/openshift/origin-operator-marketplace:latest | ||
ports: | ||
- containerPort: 60000 | ||
name: metrics | ||
- containerPort: 8080 | ||
name: healthz | ||
command: | ||
- marketplace-operator | ||
imagePullPolicy: Always | ||
livenessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8080 | ||
readinessProbe: | ||
httpGet: | ||
path: /healthz | ||
port: 8080 | ||
env: | ||
- name: WATCH_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: OPERATOR_NAME | ||
value: "marketplace-operator" | ||
customresourcedefinitions: | ||
owned: | ||
- name: catalogsourceconfigs.marketplace.redhat.com | ||
version: v1alpha1 | ||
kind: CatalogSourceConfig | ||
displayName: Catalog Source Config | ||
description: Represents a CatalogSourceConfig object which is used to configure a CatalogSource. | ||
specDescriptors: | ||
- description: The namespace where the operators will be enabled. | ||
displayName: Target Namespace | ||
path: targetNamespace | ||
- description: List of operator(s) which will be enabled in the target namespace | ||
displayName: Packages | ||
path: packages | ||
statusDescriptors: | ||
- description: Current status of the CatalogSourceConfig | ||
displayName: Current Phase Name | ||
path: currentPhase.phase.name | ||
- description: Message associated with the current status | ||
displayName: Current Phase Message | ||
path: currentPhase.phase.message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#! package-manifest: deploy/chart/catalog_resources/rh-operators/marketplace.v0.0.1.clusterserviceversion.yaml | ||
packageName: marketplace | ||
channels: | ||
- name: alpha | ||
currentCSV: marketplace-operator.v0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Copyright (C) 2019 Red Hat, Inc | ||
# see the LICENSE file for license | ||
# | ||
|
||
import shutil | ||
|
||
|
||
def test_initial_upload(omps, quay_app_registry, tmp_path): | ||
""" | ||
When uploading an archive to a repository which does not exist or it's empty, | ||
And no version is specified during the upload | ||
Then a new release is created with version 1.0.0 | ||
""" | ||
|
||
# Make sure there is no 'int-test' operator in the namespace, | ||
# or it is empty. | ||
assert not quay_app_registry.get_releases(omps.organization, 'int-test') | ||
|
||
archive = shutil.make_archive(tmp_path / 'archive', 'zip', | ||
'tests/integration/push_archive/artifacts/') | ||
response = omps.upload('int-test', archive) | ||
|
||
assert response['organization'] == omps.organization | ||
assert response['repo'] == 'int-test' | ||
assert response['version'] == '1.0.0' | ||
|
||
releases = quay_app_registry.get_releases(omps.organization, 'int-test') | ||
assert releases | ||
assert len(releases) == 1 | ||
assert releases[0]['release'] == '1.0.0' |
Oops, something went wrong.