Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
marrobi committed Nov 30, 2023
1 parent 4b53dfb commit 7e78614
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api_app/service_bus/airlock_request_status_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def init_repos(self):
self.workspace_repo = await WorkspaceRepository.create(db_client)

async def receive_messages(self):
with tracer.start_as_current_span("airlock_receive_messages") as current_span:
with tracer.start_as_current_span("airlock_receive_messages"):
while True:
try:
async with credentials.get_credential_async() as credential:
Expand Down
2 changes: 1 addition & 1 deletion api_app/service_bus/deployment_status_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def run(self, *args, **kwargs):
asyncio.run(self.receive_messages())

async def receive_messages(self):
with tracer.start_as_current_span("deployment_status_receive_messages") as current_span:
with tracer.start_as_current_span("deployment_status_receive_messages"):
while True:
try:
async with credentials.get_credential_async() as credential:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def test_get_workspace_by_id_queries_db(workspace_repo, workspace):
@patch('db.repositories.workspaces.WorkspaceRepository.validate_input_against_template')
@patch('core.config.RESOURCE_LOCATION', "useast2")
@patch('core.config.TRE_ID', "9876")
async def test_create_workspace_item_creates_a_workspace_with_the_right_values(validate_input_mock, new_cidr_mock, workspace_repo, basic_workspace_request, basic_resource_template):
async def test_create_workspace_item_creates_a_workspace_with_the_right_values(validate_input_mock, new_cidr_mock, workspace_repo, basic_workspace_request, basic_resource_template):
workspace_to_create = basic_workspace_request
# make sure the input has 'None' for values that we expect to be set
workspace_to_create.properties.pop("address_space", None)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
#cloud-config
# cloud-config
package_upgrade: true
apt:
sources:
Expand Down Expand Up @@ -79,8 +79,11 @@ runcmd:
# (https://microsoft.github.io/AzureTRE/troubleshooting-faq/troubleshooting-rp/#Logs)
- printf '\nalias dlf="docker logs --since 1m --follow"' >> /etc/bash.bashrc
- printf '\nalias dlf1='\''dlf $(docker ps -q | head -n 1)'\''' >> /etc/bash.bashrc
- printf '\nalias rpstatus='\''tmux new-session -d "watch docker ps"; tmux split-window -p 100 -v "docker logs --since 1m --follow resource_processor1"; tmux split-window -v -p 90; tmux -2 attach-session -d'\''\n' >> /etc/bash.bashrc

- >
printf '\nalias rpstatus='\''tmux new-session -d "watch docker ps"; \
tmux split-window -p 100 -v "docker logs --since 1m --follow resource_processor1"; \
tmux split-window -v -p 90; \
tmux -2 attach-session -d'\''\n' >> /etc/bash.bashrc
- export DEBIAN_FRONTEND=noninteractive
- az cloud set --name ${azure_environment}
- az login --identity -u ${vmss_msi_id}
Expand Down
1 change: 0 additions & 1 deletion resource_processor/shared/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def initialize_logging() -> logging.Logger:
elif logging_level == "ERROR":
logging_level = logging.ERROR


if os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING"):
configure_azure_monitor(
logger_name="azuretre_resource_processor",
Expand Down
4 changes: 4 additions & 0 deletions resource_processor/tests_rp/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
import logging
from shared.logging import shell_output_logger


@patch("shared.logging.logger")
def test_shell_output_logger_empty_console_output(mock_logger):
shell_output_logger("", "prefix", logging.DEBUG)
mock_logger.debug.assert_called_once_with("shell console output is empty.")


@patch("shared.logging.logger")
def test_shell_output_logger_image_not_present_locally(mock_logger):
console_output = "Unable to find image 'test_image' locally\nexecution completed successfully!"
shell_output_logger(console_output, "prefix", logging.DEBUG)
mock_logger.debug.assert_called_with("Image not present locally, removing text from console output.")
mock_logger.log.assert_called_with(logging.INFO, "prefix execution completed successfully!")


@patch("shared.logging.logger")
def test_shell_output_logger_execution_completed_successfully(mock_logger):
console_output = "execution completed successfully!"
shell_output_logger(console_output, "prefix", logging.DEBUG)
mock_logger.log.assert_called_with(logging.INFO, "prefix execution completed successfully!")


@patch("shared.logging.logger")
def test_shell_output_logger_normal_case(mock_logger):
console_output = "Some logs"
Expand Down
6 changes: 4 additions & 2 deletions resource_processor/vmss_porter/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ async def run_porter(command, config: dict):
*command
]

proc = await asyncio.create_subprocess_shell(''.join(command),
proc = await asyncio.create_subprocess_shell(
''.join(command),
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
env=config["porter_env"])
env=config["porter_env"]
)

stdout, stderr = await proc.communicate()
logger.debug(f'run porter exited with {proc.returncode}')
Expand Down

0 comments on commit 7e78614

Please sign in to comment.