Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple queue instantiation and population #34

Merged
merged 1 commit into from
Nov 17, 2017

Conversation

casperisfine
Copy link
Contributor

Fix: #19

This allows to check if the queue was exhausted without having to boot the entire test environment, which should allow a late worker to exit faster.

This PR also change the queue interface. Queues now receive and return arbitrary objects instead of strings. This will make it easier to implement adapters for test frameworks others than Minitest.

@@ -7,8 +7,8 @@ def initialize(redis:, build_id:)
@build_id = build_id
end

def empty?
size == 0
def exhausted?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed empty? to exhausted? to more clearly reflect that the queue is empty because it was fully worked off, and not because it's not populated yet.

@casperisfine
Copy link
Contributor Author

Not sure why, but the python test suite is failing:

pkg_resources.DistributionNotFound: The 'pycodestyle>=2.3' distribution was not found and is required by autopep8

@solackerman any idea?

@solackerman
Copy link
Contributor

@casperisfine
Copy link
Contributor Author

That fixed it thanks.

Copy link
Member

@DazWorrall DazWorrall left a comment

Choose a reason for hiding this comment

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

LGTM

def master_elected?
@master_elected ||= begin
status = master_status
status == 'ready' || status == 'finished'
Copy link
Member

Choose a reason for hiding this comment

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

Do we consider the master elected after the queue is populated (state == ready) or when a worker gets the lock to begin pushing the queue (state == setup)? Just want to make sure master_elected? is what you intend.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, the master is indeed already elected when the status is set to setup.

However at that point the queue isn't filled, so yeah maybe that method should be along the lines ofmaster_elected_and_queue_initialized? but it's seem a bit verbose.

WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe just queue_initialized?.That implies that a master has been elected as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense.

@@ -1,12 +1,36 @@
module SharedQueueAssertions
class TestCase
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to have a test case class in the actual library, rather than just for test purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a fake class. Since we're about to support multiple test frameworks, the queue implementations don't know what kind of objects they contain.

However we could expect an interface, and the different implementations would have to wrap whatever test case objects they have in some kind of delegate object to translate to and from string.

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.

None yet

5 participants