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

Refactor of workerqueue health testing #164

Merged
merged 1 commit into from
Apr 6, 2018

Conversation

markmandel
Copy link
Member

  • Moved the health check testing out of the gameserver controller, into the workerqueue test as the health check will be in place in multiple controllers
  • Added the use of the httptest package, so we can run this test in parralel
  • Updated more tests to be parralel.

@markmandel markmandel added the kind/cleanup Refactoring code, fixing up documentation, etc label Apr 6, 2018
@markmandel markmandel added this to the 0.2 milestone Apr 6, 2018
@markmandel markmandel requested a review from enocom April 6, 2018 01:21
Copy link
Contributor

@enocom enocom left a comment

Choose a reason for hiding this comment

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

Looks good. The controller tests are hard to write and it's nice to move health checking concerns closer to where they belong.

defer server.Close()

stop := make(chan struct{})
go func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The call to wq.Run can be inlined to remove func.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

wq := NewWorkerQueue(handler, logrus.WithField("source", "test"), "test")
health.AddLivenessCheck("test", wq.Healthy)

server := httptest.NewServer(health)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a great choice, as all the port handling between different tests isn't our responsibility.

@@ -109,7 +109,7 @@ func NewController(
c.recorder = eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: "gameserver-controller"})

c.workerqueue = workerqueue.NewWorkerQueue(c.syncGameServer, c.logger, stable.GroupName+".GameServerController")
health.AddLivenessCheck("game-server-worker-queue", healthcheck.Check(c.workerqueue.Healthy))
health.AddLivenessCheck("gameserver-workerqueue", healthcheck.Check(c.workerqueue.Healthy))
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know of a convention for naming these liveness checks from Kubernetes?

Copy link
Member Author

Choose a reason for hiding this comment

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

No idea. I just figured keep it closer to the names of the CRDs and objects that back them.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 38e60c79-1792-458b-bdac-ef91de9f19de

The following development artifacts have been built, and will exist for the next 30 days:

- Moved the health check testing out of the
  gameserver controller, into the workerqueue test
  as the health check will be in place in multiple controllers
- Added the use of the httptest package, so we can run this
  test in parralel
- Updated more tests to be parralel.
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 22108b8a-2c74-400b-9042-7f33998cb93b

The following development artifacts have been built, and will exist for the next 30 days:

@markmandel markmandel merged commit afd0e3d into googleforgames:master Apr 6, 2018
@markmandel markmandel deleted the refactor/health-tests branch April 6, 2018 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Refactoring code, fixing up documentation, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants