From a00ceae0e55f866e13ffd568469b50d094752e97 Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Thu, 21 Apr 2022 14:01:49 +0200 Subject: [PATCH] Pull request #28: Prefetch adjustment Merge in RR/pyinfra from prefetch_adjustment to master Squashed commit of the following: commit 6f9d75bf49ad196bf5728386527499025ac27b3a Author: Matthias Bisping Date: Thu Apr 21 13:47:40 2022 +0200 removed tests without much value that caused teardown problems with docker containers commit b7ccbe20e3babbf1127ea5738a1d710d8029c90b Merge: 51a459c 5925737 Author: Matthias Bisping Date: Thu Apr 21 13:04:34 2022 +0200 Merge branch 'sonarscan_refac' into prefetch_adjustment commit 51a459cbf04e9884cf6b7c2c3145206ecf1a0ffb Author: Matthias Bisping Date: Thu Apr 21 13:03:48 2022 +0200 set prefetch count to 1; removed obsolete imports commit 592573793cdfd098012a98cfc7ab0cc1fbfd0e44 Author: Matthias Bisping Date: Tue Apr 19 18:01:46 2022 +0200 refactoring; cleanup --- bamboo-specs/src/main/resources/scripts/sonar-scan.sh | 10 +--------- pyinfra/queue/queue_manager/pika_queue_manager.py | 1 + pyinfra/storage/adapters/azure.py | 4 +--- pyinfra/test/unit_tests/storage_test.py | 11 ----------- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/bamboo-specs/src/main/resources/scripts/sonar-scan.sh b/bamboo-specs/src/main/resources/scripts/sonar-scan.sh index f8716e2..0df9717 100755 --- a/bamboo-specs/src/main/resources/scripts/sonar-scan.sh +++ b/bamboo-specs/src/main/resources/scripts/sonar-scan.sh @@ -8,19 +8,13 @@ source build_venv/bin/activate python3 -m pip install --upgrade pip python3 -m pip install dependency-check python3 -m pip install docker-compose - -echo "coverage report generation" - python3 -m pip install coverage -# Install module & dependencies -#python3 -m pip install -e . -#python3 -m pip install -r requirements.txt - echo "docker-compose down" docker-compose down sleep 30 +echo "coverage report generation" bash run_tests.sh if [ ! -f reports/coverage.xml ] @@ -28,8 +22,6 @@ then exit 1 fi -#coverage run -m pytest pyinfra/test/ -x && coverage report -m && coverage xml - SERVICE_NAME=$1 echo "dependency-check:aggregate" diff --git a/pyinfra/queue/queue_manager/pika_queue_manager.py b/pyinfra/queue/queue_manager/pika_queue_manager.py index 4346658..8bc70d4 100644 --- a/pyinfra/queue/queue_manager/pika_queue_manager.py +++ b/pyinfra/queue/queue_manager/pika_queue_manager.py @@ -72,6 +72,7 @@ class PikaQueueManager(QueueManager): self.connection = pika.BlockingConnection(parameters=connection_params) self.channel = self.connection.channel() + self.channel.basic_qos(prefetch_count=1) if not dead_letter_queue: dead_letter_queue = CONFIG.rabbitmq.queues.dead_letter diff --git a/pyinfra/storage/adapters/azure.py b/pyinfra/storage/adapters/azure.py index aa28279..334dbaf 100644 --- a/pyinfra/storage/adapters/azure.py +++ b/pyinfra/storage/adapters/azure.py @@ -1,10 +1,8 @@ -from itertools import repeat import logging -from functools import wraps +from itertools import repeat from operator import attrgetter from azure.storage.blob import ContainerClient, BlobServiceClient -from retry import retry from pyinfra.storage.adapters.adapter import StorageAdapter diff --git a/pyinfra/test/unit_tests/storage_test.py b/pyinfra/test/unit_tests/storage_test.py index 6e8293f..efb7b62 100644 --- a/pyinfra/test/unit_tests/storage_test.py +++ b/pyinfra/test/unit_tests/storage_test.py @@ -2,9 +2,6 @@ import logging import pytest -from pyinfra.storage.storage import Storage -from pyinfra.storage.storages import get_azure_storage, get_s3_storage - logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) @@ -46,11 +43,3 @@ class TestStorage: storage.put_object(bucket_name, "file2", b"content 2") full_names_received = storage.get_all_object_names(bucket_name) assert {(bucket_name, "file1"), (bucket_name, "file2")} == {*full_names_received} - - -def test_get_azure_storage_yields_storage(): - assert isinstance(get_azure_storage(), Storage) - - -def test_get_s3_storage_yields_storage(): - assert isinstance(get_s3_storage(), Storage)