From 357adfbc2165b59b233878ba29a04c4d4333d370 Mon Sep 17 00:00:00 2001 From: Joey Orlando Date: Wed, 7 Jun 2023 12:51:58 +0200 Subject: [PATCH] make make test command much more robust + address several more backend test warnings (#2115) # What this PR does see more detailed comments under the "Files changed" tab --------- Co-authored-by: Vadim Stepanov --- docker-compose-developer.yml | 4 +++- engine/apps/api/views/slack_channel.py | 2 +- engine/apps/public_api/views/action.py | 2 +- engine/apps/public_api/views/alerts.py | 2 +- engine/apps/public_api/views/escalation_chains.py | 2 +- engine/apps/public_api/views/slack_channels.py | 2 +- engine/apps/public_api/views/teams.py | 2 +- engine/apps/public_api/views/user_groups.py | 2 +- engine/requirements.txt | 2 +- 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docker-compose-developer.yml b/docker-compose-developer.yml index 080dd6fb..d840c3a3 100644 --- a/docker-compose-developer.yml +++ b/docker-compose-developer.yml @@ -10,8 +10,10 @@ x-oncall-build: &oncall-build-args x-oncall-volumes: &oncall-volumes - ./engine:/etc/app + # see all the fun answers/comments here on why we need to do this + # tldr; using /dev/null as a default leads to a lot of fun problems # https://stackoverflow.com/a/60456034 - - ${ENTERPRISE_ENGINE:-/dev/null}:/etc/app/extensions/engine_enterprise + - ${ENTERPRISE_ENGINE:-/dev/null}:${ENTERPRISE_ENGINE_VOLUME_MOUNT_DEST_DIR:-/tmp/empty:ro} - ${SQLITE_DB_FILE:-/dev/null}:/var/lib/oncall/oncall.db # this is mounted for testing purposes. Some of the authorization tests # reference this file diff --git a/engine/apps/api/views/slack_channel.py b/engine/apps/api/views/slack_channel.py index a5237e5e..59ba10f3 100644 --- a/engine/apps/api/views/slack_channel.py +++ b/engine/apps/api/views/slack_channel.py @@ -29,4 +29,4 @@ class SlackChannelView(PublicPrimaryKeyMixin, mixins.ListModelMixin, mixins.Retr is_archived=False, ) - return queryset + return queryset.order_by("id") diff --git a/engine/apps/public_api/views/action.py b/engine/apps/public_api/views/action.py index 1d1ecdb8..eb8af372 100644 --- a/engine/apps/public_api/views/action.py +++ b/engine/apps/public_api/views/action.py @@ -32,7 +32,7 @@ class ActionView(RateLimitHeadersMixin, PublicPrimaryKeyMixin, UpdateSerializerM if action_name: queryset = queryset.filter(name=action_name) - return queryset + return queryset.order_by("id") def perform_create(self, serializer): serializer.save() diff --git a/engine/apps/public_api/views/alerts.py b/engine/apps/public_api/views/alerts.py index b4be1c73..bfa12157 100644 --- a/engine/apps/public_api/views/alerts.py +++ b/engine/apps/public_api/views/alerts.py @@ -46,4 +46,4 @@ class AlertView(RateLimitHeadersMixin, mixins.ListModelMixin, GenericViewSet): queryset = self.serializer_class.setup_eager_loading(queryset) - return queryset + return queryset.order_by("id") diff --git a/engine/apps/public_api/views/escalation_chains.py b/engine/apps/public_api/views/escalation_chains.py index 017ca470..88cf24ba 100644 --- a/engine/apps/public_api/views/escalation_chains.py +++ b/engine/apps/public_api/views/escalation_chains.py @@ -34,7 +34,7 @@ class EscalationChainView(RateLimitHeadersMixin, ModelViewSet): if name is not None: queryset = queryset.filter(name=name) - return queryset + return queryset.order_by("id") def get_object(self): public_primary_key = self.kwargs["pk"] diff --git a/engine/apps/public_api/views/slack_channels.py b/engine/apps/public_api/views/slack_channels.py index 41be9616..1f363596 100644 --- a/engine/apps/public_api/views/slack_channels.py +++ b/engine/apps/public_api/views/slack_channels.py @@ -30,4 +30,4 @@ class SlackChannelView(RateLimitHeadersMixin, mixins.ListModelMixin, GenericView if channel_name: queryset = queryset.filter(name=channel_name) - return queryset + return queryset.order_by("id") diff --git a/engine/apps/public_api/views/teams.py b/engine/apps/public_api/views/teams.py index 40eb0e87..96cea48d 100644 --- a/engine/apps/public_api/views/teams.py +++ b/engine/apps/public_api/views/teams.py @@ -27,4 +27,4 @@ class TeamView(PublicPrimaryKeyMixin, RetrieveModelMixin, ListModelMixin, viewse queryset = self.request.auth.organization.teams.all() if name: queryset = queryset.filter(name=name) - return queryset + return queryset.order_by("id") diff --git a/engine/apps/public_api/views/user_groups.py b/engine/apps/public_api/views/user_groups.py index 2859199d..3db86954 100644 --- a/engine/apps/public_api/views/user_groups.py +++ b/engine/apps/public_api/views/user_groups.py @@ -26,4 +26,4 @@ class UserGroupView(RateLimitHeadersMixin, mixins.ListModelMixin, GenericViewSet ).distinct() if slack_handle: queryset = queryset.filter(handle=slack_handle) - return queryset + return queryset.order_by("id") diff --git a/engine/requirements.txt b/engine/requirements.txt index 2c4a735b..71a18dee 100644 --- a/engine/requirements.txt +++ b/engine/requirements.txt @@ -24,7 +24,7 @@ slack-export-viewer==1.1.4 beautifulsoup4==4.12.2 social-auth-app-django==5.0.0 cryptography==38.0.4 # version 39.0.0 introduced an issue - https://stackoverflow.com/a/75053968/3902555 -pytest==7.1.3 +pytest==7.3.1 pytest-django==4.5.2 pytest_factoryboy==2.5.1 factory-boy<3.0