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

tests: controller integration tests #27

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

guicassolato
Copy link
Contributor

Add proper integration tests for the controller package.

  • Runs the tests against a test kubernetes cluster started with Kind.
  • Fixed TestStartControllerManaged test case

Added target for running the tests:

make test-integration

Other targets introduced:

make test-unit
make test

@guicassolato guicassolato self-assigned this Aug 30, 2024
@guicassolato guicassolato force-pushed the controller-integration-tests branch from 5013870 to e78b382 Compare August 30, 2024 16:13
Signed-off-by: Guilherme Cassolato <[email protected]>
@guicassolato guicassolato force-pushed the controller-integration-tests branch from e78b382 to 35eb125 Compare August 30, 2024 16:15
Copy link
Contributor

@Boomatang Boomatang left a comment

Choose a reason for hiding this comment

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

The comment about the waitGroups is the only real concern that I have.

cancel()
}
}()
time.Sleep(3 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for this sleep. Would it not be safer to set up a wait group for the go routines and exit once all have finished.

Copy link
Contributor Author

@guicassolato guicassolato Sep 2, 2024

Choose a reason for hiding this comment

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

The goroutine won't finish. It only finishes when the context is done (canceled), hence the wait and the deferred call to cancel().

The wait is mainly to give the manager time to start processes such as the metrics service and others. This is more relevant to controller-runtime managed controllers than to informers-based ones. The latter boot up significantly quicker.

cancel()
}
}()
time.Sleep(3 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again would a wait group be better here.


.PHONY: test-unit
test-unit: ## Run unit tests.
go test -tags=unit -v ./...
Copy link
Contributor

Choose a reason for hiding this comment

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

In general I don't like using the -v by default when it is being run in automation, but as there is very limited logs currently I am okay with this.

Copy link
Contributor

@KevFan KevFan 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 to me 👍

@guicassolato guicassolato merged commit 85837a3 into main Sep 3, 2024
6 checks passed
@guicassolato guicassolato deleted the controller-integration-tests branch September 3, 2024 13:11
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.

3 participants