Skip to content

Commit

Permalink
Running tests on minio
Browse files Browse the repository at this point in the history
  • Loading branch information
fao89 committed Mar 5, 2020
1 parent ab11cc6 commit b7c47b1
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 17 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:
- TEST=pulp
- TEST=docs
- TEST=bindings
- TEST=s3
services:
- postgresql
- redis-server
Expand Down
14 changes: 12 additions & 2 deletions .travis/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,22 @@ fi

git clone --depth=1 https://github.com/pulp/pulpcore.git --branch master

cd pulpcore
if [ -n "$PULP_PR_NUMBER" ]; then
cd pulpcore
git fetch --depth=1 origin pull/$PULP_PR_NUMBER/head:$PULP_PR_NUMBER
git checkout $PULP_PR_NUMBER
cd ..
fi
if [[ "$TEST" == 's3' ]]; then
sed -i "s/localhost/$(hostname)/g" ./.travis/s3_settings.py
export MINIO_ACCESS_KEY=AKIAIT2Z5TDYPX3ARJBA
export MINIO_SECRET_KEY=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
docker run -d -p 0.0.0.0:9000:9000 -e MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY -e MINIO_SECRET_KEY=$MINIO_SECRET_KEY minio/minio server /data
wget https://dl.min.io/client/mc/release/linux-amd64/mc
chmod +x mc
sudo mv mc /usr/local/bin
fi

cd ..



Expand Down
19 changes: 9 additions & 10 deletions .travis/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,21 @@ else
sed "s/localhost/$(hostname)/g" ../pulpcore/.travis/pulp-smash-config.json > ~/.config/pulp_smash/settings.json
fi


cat ~/.config/pulp_smash/settings.json | \
jq "setpath([\"custom\",\"fixtures_origin\"]; \"http://$(hostname):8000/fixtures/\")" > temp.json
cat temp.json > ~/.config/pulp_smash/settings.json


if [[ "$TEST" == 'pulp' || "$TEST" == 'performance' ]]; then
# set up pulp-fixtures docker container
docker run -d -p 0.0.0.0:8000:80 quay.io/pulp/pulp-fixtures:latest

if [[ "$TEST" == 'pulp' || "$TEST" == 'performance' || "$TEST" == 's3' ]]; then
# Many tests require pytest/mock, but users do not need them at runtime
# (or to add plugins on top of pulpcore or pulp container images.)
# So install it here, rather than in the image Dockerfile.
$CMD_PREFIX pip3 install pytest mock
# Many functional tests require these
$CMD_PREFIX dnf install -yq lsof which dnf-plugins-core

# set up pulp-fixtures docker container
docker run -d -p 0.0.0.0:8000:80 quay.io/pulp/pulp-fixtures:latest

cat ~/.config/pulp_smash/settings.json | \
jq "setpath([\"custom\",\"fixtures_origin\"]; \"http://$(hostname):8000/fixtures/\")" > temp.json
cat temp.json > ~/.config/pulp_smash/settings.json

fi

if [[ -f $POST_BEFORE_SCRIPT ]]; then
Expand Down
2 changes: 1 addition & 1 deletion .travis/cherrypick.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_merged_commits(pr):
g = Github(GITHUB_TOKEN)
grepo = g.get_repo(REPOSITORY)
(label,) = (l for l in grepo.get_labels() if l.name == PR_LABEL)
issues = grepo.get_issues(labels=[label], state="all")
issues = grepo.get_issues(labels=[label], state="all", sort="updated", direction="asc")

cherrypicks = []

Expand Down
6 changes: 6 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ images:
- pulp_file-${TAG}:
image_name: pulp_file
tag: $TAG
pulpcore: pulpcore
plugins:
- ./pulp_file
VARSYAML
Expand All @@ -69,6 +70,11 @@ images:
- ./pulp_file
VARSYAML
fi

if [ "$TEST" = 's3' ]; then
echo "s3_test: true" >> vars/vars.yaml
fi

ansible-playbook -v build.yaml

cd $TRAVIS_BUILD_DIR/../pulp-operator
Expand Down
5 changes: 4 additions & 1 deletion .travis/publish_client_gem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ if [[ $DESCRIPTION == 'tags/'$REPORTED_VERSION ]]; then
export VERSION=${REPORTED_VERSION}
else
# Daily publishing of development version (ends in ".dev" reported as ".dev0")
[ "${REPORTED_VERSION%.dev*}" != "${REPORTED_VERSION}" ] || exit 1
if [ "${REPORTED_VERSION%.dev*}" == "${REPORTED_VERSION}" ]; then
echo "Refusing to publish bindings. $REPORTED_VERSION does not contain 'dev'."
exit 1
fi
export EPOCH="$(date +%s)"
export VERSION=${REPORTED_VERSION}${EPOCH}
fi
Expand Down
5 changes: 4 additions & 1 deletion .travis/publish_client_pypi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ if [[ $DESCRIPTION == 'tags/'$REPORTED_VERSION ]]; then
export VERSION=${REPORTED_VERSION}
else
# Daily publishing of development version (ends in ".dev" reported as ".dev0")
[ "${REPORTED_VERSION%.dev*}" != "${REPORTED_VERSION}" ] || exit 1
if [ "${REPORTED_VERSION%.dev*}" == "${REPORTED_VERSION}" ]; then
echo "Refusing to publish bindings. $REPORTED_VERSION does not contain 'dev'."
exit 1
fi
export EPOCH="$(date +%s)"
export VERSION=${REPORTED_VERSION}${EPOCH}
fi
Expand Down
7 changes: 7 additions & 0 deletions .travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ export CMD_STDIN_PREFIX="sudo kubectl exec -i $PULP_API_POD --"
cat unittest_requirements.txt | $CMD_STDIN_PREFIX bash -c "cat > /tmp/test_requirements.txt"
$CMD_PREFIX pip3 install -r /tmp/test_requirements.txt

if [[ "$TEST" == 's3' ]]; then
mc config host add s3 http://localhost:9000 AKIAIT2Z5TDYPX3ARJBA fqRvjWaPU5o0fCqQuUWbj9Fainj2pVZtBCiDiieS --api S3v4
mc config host rm local
mc mb s3/pulp3 --region eu-central-1
mc tree s3
fi

# Run unit tests.
$CMD_PREFIX bash -c "PULP_DATABASES__default__USER=postgres django-admin test --noinput /usr/local/lib/python${TRAVIS_PYTHON_VERSION}/site-packages/pulp_file/tests/unit/"

Expand Down
1 change: 1 addition & 0 deletions CHANGES/6155.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Running tests on minio
2 changes: 2 additions & 0 deletions functest_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
django
dynaconf
git+https://github.com/pulp/pulp-smash.git#egg=pulp-smash
pulpcore-client
pulp-file-client
Expand Down
2 changes: 1 addition & 1 deletion pulp_file/tests/functional/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def monitor_task(task_href):
completed = ["completed", "failed", "canceled"]
task = tasks.read(task_href)
while task.state not in completed:
sleep(2)
sleep(1)
task = tasks.read(task_href)

if task.state == "completed":
Expand Down
4 changes: 3 additions & 1 deletion pulp_file/tests/unit/test_core/test_repo_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from unittest.mock import patch

from django.core.files.storage import default_storage as storage
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import TestCase
from pulpcore.plugin.models import Artifact, ContentArtifact, RepositoryVersion
Expand Down Expand Up @@ -36,8 +37,9 @@ def setUp(self):
artifact.save()
self.content = FileContent.objects.create()
self.content.save()
artifact_file = storage.open(artifact.file.name)
self.content_artifact = ContentArtifact.objects.create(
artifact=artifact, content=self.content, relative_path=artifact.file.path
artifact=artifact, content=self.content, relative_path=artifact_file.name
)
self.content_artifact.save()
self.repository = FileRepository.objects.create(name="foo")
Expand Down
3 changes: 3 additions & 0 deletions template_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ plugin_snake: pulp_file
plugin_snake_short: file
pulp_settings: null
pulpcore_branch: master
pulpcore_pip_version_specifier: null
pydocstyle: true
pypi_username: pulp
stable_branch: '0.2'
test: false
test_bindings: true
test_performance: true
test_s3: true
travis_addtl_services: []
travis_notifications:
irc:
channels:
Expand Down

0 comments on commit b7c47b1

Please sign in to comment.