-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Container services #49
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d545b19
Add docker containers to test services.
marcosnils 0db5500
Add cirleci script
marcosnils ae385b3
Remove unnecessary circleci configuration as we're using default
marcosnils 6355228
Remove circle ci implementation due to Golang bug.
marcosnils 4471e2b
Use postgres default configuration
marcosnils aa86c16
Add --no-recreate option to prepare target
marcosnils d2810dd
Add DOCKER_HOST support for tests
marcosnils ef335d9
Add missing files
marcosnils File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
prepare: | ||
go get -d -v -t ./... | ||
docker-compose up -d --no-recreate | ||
|
||
test: prepare | ||
go test -short ./... | ||
|
||
update: | ||
go get -u -v -d -t ./... | ||
|
||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
mysql: | ||
image: mysql | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
|
||
memcached: | ||
image: memcached | ||
ports: | ||
- "11211:11211" | ||
|
||
postgres: | ||
image: postgres | ||
ports: | ||
- "5432:5432" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package testutil | ||
|
||
import "os" | ||
|
||
var localhost = "localhost" | ||
|
||
func GetLocalHost() string { | ||
if dockerHostVar := os.Getenv("DOCKER_HOST"); dockerHostVar != "" { | ||
return dockerHostVar | ||
} | ||
return localhost | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package testutil | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestDockerHost(t *testing.T) { | ||
|
||
os.Unsetenv("DOCKER_HOST") | ||
|
||
host := GetLocalHost() | ||
|
||
if host != localhost { | ||
t.Fatalf("Host should be localhost when DOCKER_HOST is not set. Current value [%s]", host) | ||
} | ||
|
||
os.Setenv("DOCKER_HOST", "1.1.1.1") | ||
|
||
host = GetLocalHost() | ||
|
||
if host != "1.1.1.1" { | ||
t.Fatalf("Host should take DOCKER_HOST value when set. Current value is [%s] and DOCKER_HOST is [%s]", host, os.Getenv("DOCKER_HOST")) | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the changes below it mean that the tests won't run as the current user any longer, which breaks the non-docker test setup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evanphx AFAIK there's no
non-docker
test setup in telegraf. The reason why this PR exists is because if you need to run telegraf tests as today you need to install almost all the services (which are not mocked) in your local machine and expect them to be set-up with the proper/default? (is there really a proper?) configuration.This PR provides a docker based deterministic way to set-up all the services and run tests against them, so changing the default DB test user (BTW, I've used the default in the official postgres docker image) seems trivial as long as the tests run in a deterministic way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record, I had to change the user because the postgres docker image uses it to initialize the DB configuration. If I wanted to use some other user (like the default/session one) then I had to make a custom docker image which I didn't want to do.