Skip to content

Add fake Akamai purge server for integration testing - #3946

Merged
cpu merged 2 commits into
masterfrom
akamai-test-srv
Nov 27, 2018
Merged

Add fake Akamai purge server for integration testing#3946
cpu merged 2 commits into
masterfrom
akamai-test-srv

Conversation

@rolandshoemaker

Copy link
Copy Markdown
Contributor

Fixes #3916.

@rolandshoemaker
rolandshoemaker requested a review from a team as a code owner November 19, 2018 23:38

@cpu cpu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only small nits. The substance of the PR is 💯 - thanks @rolandshoemaker

Comment thread cmd/ocsp-updater/main.go Outdated
var allPurgeURLs []string
for _, status := range statuses {
// It's possible that, if our ticks are fast enough (mainly in tests), we
// will get a status where the ocspLastUpdated == revokedDate and has already

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: I think "we will get a status where the ocspLastUpdated == revokedDate and has already been revoked." is missing a word:

Suggested change
// will get a status where the ocspLastUpdated == revokedDate and has already
// will get a certificate status where the ocspLastUpdated == revokedDate and the certificate has already

"akamaiBaseURL": "http://localhost:6789",
"akamaiClientToken": "its-a-token",
"akamaiClientSecret": "its-a-secret",
"akamaiAccessToken": "idk-how-this-is-different-from-client-token-but-okay",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😂

Comment thread test/integration-test.py
purgeData = response.json()
if os.environ.get('BOULDER_CONFIG_DIR', '').startswith("test/config-next"):
if len(purgeData["V3"]) is not 1:
raise Exception("Unexpected number of Akamai v3 purges")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should there also be a check that when the config is config-next that there are no v2 purges (and vice-versa for config)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup, done.

Comment thread test/akamai-test-srv/main.go Outdated
v2Purges := [][]string{}
v3Purges := [][]string{}
mu := sync.Mutex{}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would be nicer to see this broken up into separate handler functions registered on a mux. Right now its a pretty long function and has to do its own path checking.

Comment thread test/akamai-test-srv/main.go Outdated
return
}
err = akamai.CheckSignature(*secret, "http://"+*listenAddr, r, body)
if err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: this if and err = assignment could be combined.

Comment thread test/akamai-test-srv/main.go Outdated
return
}
err = json.Unmarshal(body, &purgeRequest)
if err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: this if and err = assignment could be combined.

Comment thread cmd/ocsp-updater/main.go
}

if updater.ccu != nil {
if updater.ccu != nil && len(allPurgeURLs) > 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious: why was this len check needed? Was it fixing another bug?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Kind of. We don't do any special empty set logic for findRevokedCertificatesToUpdate so even when it returned an empty list of statuses we would call out to the purger. Because of how we manage batching it wouldn't actually end up sending a request (although it's entirely possible we did in the past, didn't really bother checking that) but we should save a CPU cycle or two by avoiding needing to do that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

(Probably at some point we should fix the logic in findRevokedCertificatesToUpdate and above, but that gets a bit more involved than I wanted to do here)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks! Makes sense to me.

@jsha jsha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, thanks!

HTTPStatus int
EstimatedSeconds int
}{
PurgeID: "welcome-to-the-purge",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💯

@cpu cpu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @rolandshoemaker - looks great!

@cpu
cpu merged commit ba7a8e8 into master Nov 27, 2018
@cpu
cpu deleted the akamai-test-srv branch November 27, 2018 14:49
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