Skip to content

Fix docker local tests to be compatible with newer versions of pg image #3047

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

Merged
merged 1 commit into from
Mar 12, 2020

Conversation

tylercloke
Copy link
Contributor

@tylercloke tylercloke commented Mar 6, 2020

🔩 Description: What code changed, and why?

Recently, the docker image's default security config was changed because it defaulted to super insecure settings:

docker-library/postgres#580

We didn't care about that since we were only using it locally for testing. Updating the Makefiles for auth related services to work with newer versions of the docker postgres image. Also cleaned up some of authn's use of PG_URL so there was less inconsistency and hard-codedness.

👟 How to Build and Test the Change

Get on the latest docker image:

docker image ls
docker image rm -f <imageid>

In teams, authz, and authn services:

make setup_docker_pg
make test_with_db
make kill_docker_pg

✅ Checklist

@tylercloke tylercloke force-pushed the tc/fix-docker-local-tests branch from 2000450 to 36bf561 Compare March 6, 2020 00:45
@@ -61,14 +85,9 @@ func TestChefClientAuthn(t *testing.T) {
t.Fatalf("parse test upstream URL %+v: %v", upstream, err)
}

pgURLGiven := false
pgCfg := pg.Config{
PGURL: constants.TestPgURL,
Copy link
Contributor

Choose a reason for hiding this comment

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

is this what was passing the postgres user? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep

@susanev susanev added the auth-team anything that needs to be on the auth team board label Mar 6, 2020
t.Fatalf("opening connector: %s", err)
} else {
t.Logf("opening database: %s", err)
t.Logf(testconstants.SkipPGMessageFmt, pgCfg.PGURL)
t.Logf("failed to open test database with PG_URL: %q", pgCfg.PGURL)

Choose a reason for hiding this comment

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

These subsequent logs seem confusing-- if we know we're going to log a failure, why log the attempt?

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 think we are just logging the error and the URL it failed with?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be more clear though. Open to whatever.

Choose a reason for hiding this comment

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

We hit this line if the PG_URL wasn't provided, right? Can we log that and indicate that we are skipping pg tests (something more akin to the old message)?

Choose a reason for hiding this comment

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

Basically I would be led astray by the word "failed"

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah same

@@ -50,11 +50,11 @@ test:

test_with_db:
@docker ps | grep authn-postgres || (echo "Docker postgres not up. Run 'make setup_docker_pg' and try this command again."; exit 1)
@PG_URL="postgresql://[email protected]:5432/authn_test?sslmode=disable&timezone=UTC" go test -cover -count=1 -parallel=1 -p 1 $(packages)
@PGTZ=UTC PG_URL="postgresql://[email protected]:5432/authn_test?sslmode=disable&password=docker" go test -cover -count=1 -parallel=1 -p 1 $(packages)

Choose a reason for hiding this comment

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

any idea what the timezone parameter was doing for us?

Choose a reason for hiding this comment

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

Oh I see you've moved it above 🤔

Copy link

@blakestier blakestier left a comment

Choose a reason for hiding this comment

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

Would like a message explaining the skipping/jogging my old brain about how to change the skipping

//
// Yes those lines are long, but if we linebreak, the output ends up starting
// with TAB characters, which makes it harder to copy-paste the commands.
const SkipPGMessageFmt = `
Copy link
Contributor

Choose a reason for hiding this comment

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

Like @blakestier was saying, this is a much more actionable error message. Do we need to remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't think that's what we want people to do? this made sense when we weren't automating with the makefile.

Copy link
Contributor

@bcmdarroch bcmdarroch left a comment

Choose a reason for hiding this comment

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

👍 👍 thanks for digging into this!

@tylercloke tylercloke force-pushed the tc/fix-docker-local-tests branch from 36bf561 to cf091f4 Compare March 9, 2020 20:59
Copy link
Contributor

@msorens msorens left a comment

Choose a reason for hiding this comment

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

Works for me--after rebasing to latest master. (The recent golang bump to 1.14 caused a problem, but rebasing fixed it for me.)

$ make test_with_db
. . .
go: inconsistent vendoring in /Users/msorens/code/go/src/github.com/chef/automate:
	golang.org/x/[email protected]: is explicitly required in go.mod, but vendor/modules.txt indicates golang.org/x/[email protected]

Recently, the docker image's default security config was changed because it defaulted to super insecure settings:

docker-library/postgres#580

We didn't care about that since we were only using it locally for testing. Updating the Makefiles for auth related services to work with newer versions of the docker postgres image. Also cleaned up some of authn's use of PG_URL so there was less inconsistency and hard-codedness.

Signed-off-by: Tyler Cloke <[email protected]>
@tylercloke tylercloke force-pushed the tc/fix-docker-local-tests branch from cf091f4 to 2027968 Compare March 11, 2020 17:54
@tylercloke tylercloke merged commit 4bc727e into master Mar 12, 2020
@tylercloke tylercloke deleted the tc/fix-docker-local-tests branch March 12, 2020 17:39
@tylercloke tylercloke mentioned this pull request Mar 19, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth-team anything that needs to be on the auth team board
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants