Skip to content

Adding rabbitmq to Pavilion for sending data #1075

Draft
cielling wants to merge 1 commit into
developfrom
carolae/rabbitmq
Draft

Adding rabbitmq to Pavilion for sending data #1075
cielling wants to merge 1 commit into
developfrom
carolae/rabbitmq

Conversation

@cielling

Copy link
Copy Markdown
Collaborator

Code review checklist:

  • Code is generally sensical and well commented
  • Variable/function names all telegraph their purpose and contents
  • Functions/classes have useful doc strings
  • Function arguments are typed
  • Added/modified unit tests to cover changes.
  • New features have documentation added to the docs.
  • New features and backwards compatibility breaks are noted in the RELEASE.md

import sys
import json
import ssl
from pika import BlockingConnection, ConnectionParameters, SSLOptions, BasicProperties

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add pika (probably version 1.3) as a vendored dependency under lib/sub_repos, with a symlink under lib.

"port": 5671,
"vhost": "pavilion",
"exchange": "pavilion",
"routing_key": "test.result"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put these parameters in the result logger config rather than in a file.

message only and skips the publish.
"""
if verbose != 0:
print(message)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid print() in production code.

if verbose != 0:
print(message)
if verbose < 0:
print("\n INFO: verbose < 0: Not sending to rabbitmq!\n")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

def __exit__(self, exc_type, exc_val, exc_tb):
try:
self.connection.close()
except Exception:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Catch specific exceptions rather than generic Exception.

try:
self.client.send_as_json(results)
self.logger.debug("Result sent to RabbitMQ")
except Exception as exc: # noqa: BLE001

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

self.logger.debug("Result sent to RabbitMQ")
except Exception as exc: # noqa: BLE001
# Emit a warning to the logging system.
self.logger.warning(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raise ResultLoggerPluginError rather than logging a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants