-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
cmd/devp2p: submit Route53 changes in batches #20524
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1ce4179
cmd/devp2p: submit Route53 changes in batches
fjl b9c87b0
cmd/devp2p: ensure Route53 changes are sorted
fjl ba51571
cmd/devp2p: use original TTL for Route53 deletes
fjl c3d62ee
cmd/devp2p: add missing copyright header
fjl 91b9f5d
cmd/devp2p: use TTL constants in the CloudFlare deployer
fjl 577c760
cmd/devp2p: lower the Route53 limit
fjl 6e8ea88
cmd/devp2p: fix lint
fjl 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
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,124 @@ | ||
package main | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/service/route53" | ||
) | ||
|
||
// This test checks that computeChanges/splitChanges create DNS changes in | ||
// leaf-added -> root-changed -> leaf-deleted order. | ||
func TestRoute53ChangeSort(t *testing.T) { | ||
testTree0 := map[string][]string{ | ||
"fdxn3sn67na5dka4j2gok7bvqi.n": {"enrtree-branch:"}, | ||
"n": {"enrtree-root:v1 e=FDXN3SN67NA5DKA4J2GOK7BVQI l=FDXN3SN67NA5DKA4J2GOK7BVQI seq=0 sig=Me7k32DXwG06XmqzNW4b3opMrGXQV9Atv6hmJrVPuNx0QZ-PugeoYlMMndDxyN8cOkWGCxOze26WOyD2JAsAvgE"}, | ||
} | ||
|
||
testTree1 := map[string]string{ | ||
"n": "enrtree-root:v1 e=JWXYDBPXYWG6FX3GMDIBFA6CJ4 l=C7HRFPF3BLGF3YR4DY5KX3SMBE seq=1 sig=o908WmNp7LibOfPsr4btQwatZJ5URBr2ZAuxvK4UWHlsB9sUOTJQaGAlLPVAhM__XJesCHxLISo94z5Z2a463gA", | ||
"C7HRFPF3BLGF3YR4DY5KX3SMBE.n": "enrtree://AM5FCQLWIZX2QFPNJAP7VUERCCRNGRHWZG3YYHIUV7BVDQ5FDPRT2@morenodes.example.org", | ||
"JWXYDBPXYWG6FX3GMDIBFA6CJ4.n": "enrtree-branch:2XS2367YHAXJFGLZHVAWLQD4ZY,H4FHT4B454P6UXFD7JCYQ5PWDY,MHTDO6TMUBRIA2XWG5LUDACK24", | ||
"2XS2367YHAXJFGLZHVAWLQD4ZY.n": "enr:-HW4QOFzoVLaFJnNhbgMoDXPnOvcdVuj7pDpqRvh6BRDO68aVi5ZcjB3vzQRZH2IcLBGHzo8uUN3snqmgTiE56CH3AMBgmlkgnY0iXNlY3AyNTZrMaECC2_24YYkYHEgdzxlSNKQEnHhuNAbNlMlWJxrJxbAFvA", | ||
"H4FHT4B454P6UXFD7JCYQ5PWDY.n": "enr:-HW4QAggRauloj2SDLtIHN1XBkvhFZ1vtf1raYQp9TBW2RD5EEawDzbtSmlXUfnaHcvwOizhVYLtr7e6vw7NAf6mTuoCgmlkgnY0iXNlY3AyNTZrMaECjrXI8TLNXU0f8cthpAMxEshUyQlK-AM0PW2wfrnacNI", | ||
"MHTDO6TMUBRIA2XWG5LUDACK24.n": "enr:-HW4QLAYqmrwllBEnzWWs7I5Ev2IAs7x_dZlbYdRdMUx5EyKHDXp7AV5CkuPGUPdvbv1_Ms1CPfhcGCvSElSosZmyoqAgmlkgnY0iXNlY3AyNTZrMaECriawHKWdDRk2xeZkrOXBQ0dfMFLHY4eENZwdufn1S1o", | ||
} | ||
|
||
wantChanges := []*route53.Change{ | ||
{ | ||
Action: sp("CREATE"), | ||
ResourceRecordSet: &route53.ResourceRecordSet{ | ||
Name: sp("2xs2367yhaxjfglzhvawlqd4zy.n"), | ||
ResourceRecords: []*route53.ResourceRecord{{ | ||
Value: sp(`"enr:-HW4QOFzoVLaFJnNhbgMoDXPnOvcdVuj7pDpqRvh6BRDO68aVi5ZcjB3vzQRZH2IcLBGHzo8uUN3snqmgTiE56CH3AMBgmlkgnY0iXNlY3AyNTZrMaECC2_24YYkYHEgdzxlSNKQEnHhuNAbNlMlWJxrJxbAFvA"`), | ||
}}, | ||
TTL: ip(2147483647), | ||
Type: sp("TXT"), | ||
}, | ||
}, | ||
{ | ||
Action: sp("CREATE"), | ||
ResourceRecordSet: &route53.ResourceRecordSet{ | ||
Name: sp("c7hrfpf3blgf3yr4dy5kx3smbe.n"), | ||
ResourceRecords: []*route53.ResourceRecord{{ | ||
Value: sp(`"enrtree://AM5FCQLWIZX2QFPNJAP7VUERCCRNGRHWZG3YYHIUV7BVDQ5FDPRT2@morenodes.example.org"`), | ||
}}, | ||
TTL: ip(2147483647), | ||
Type: sp("TXT"), | ||
}, | ||
}, | ||
{ | ||
Action: sp("CREATE"), | ||
ResourceRecordSet: &route53.ResourceRecordSet{ | ||
Name: sp("h4fht4b454p6uxfd7jcyq5pwdy.n"), | ||
ResourceRecords: []*route53.ResourceRecord{{ | ||
Value: sp(`"enr:-HW4QAggRauloj2SDLtIHN1XBkvhFZ1vtf1raYQp9TBW2RD5EEawDzbtSmlXUfnaHcvwOizhVYLtr7e6vw7NAf6mTuoCgmlkgnY0iXNlY3AyNTZrMaECjrXI8TLNXU0f8cthpAMxEshUyQlK-AM0PW2wfrnacNI"`), | ||
}}, | ||
TTL: ip(2147483647), | ||
Type: sp("TXT"), | ||
}, | ||
}, | ||
{ | ||
Action: sp("CREATE"), | ||
ResourceRecordSet: &route53.ResourceRecordSet{ | ||
Name: sp("jwxydbpxywg6fx3gmdibfa6cj4.n"), | ||
ResourceRecords: []*route53.ResourceRecord{{ | ||
Value: sp(`"enrtree-branch:2XS2367YHAXJFGLZHVAWLQD4ZY,H4FHT4B454P6UXFD7JCYQ5PWDY,MHTDO6TMUBRIA2XWG5LUDACK24"`), | ||
}}, | ||
TTL: ip(2147483647), | ||
Type: sp("TXT"), | ||
}, | ||
}, | ||
{ | ||
Action: sp("CREATE"), | ||
ResourceRecordSet: &route53.ResourceRecordSet{ | ||
Name: sp("mhtdo6tmubria2xwg5ludack24.n"), | ||
ResourceRecords: []*route53.ResourceRecord{{ | ||
Value: sp(`"enr:-HW4QLAYqmrwllBEnzWWs7I5Ev2IAs7x_dZlbYdRdMUx5EyKHDXp7AV5CkuPGUPdvbv1_Ms1CPfhcGCvSElSosZmyoqAgmlkgnY0iXNlY3AyNTZrMaECriawHKWdDRk2xeZkrOXBQ0dfMFLHY4eENZwdufn1S1o"`), | ||
}}, | ||
TTL: ip(2147483647), | ||
Type: sp("TXT"), | ||
}, | ||
}, | ||
{ | ||
Action: sp("UPSERT"), | ||
ResourceRecordSet: &route53.ResourceRecordSet{ | ||
Name: sp("n"), | ||
ResourceRecords: []*route53.ResourceRecord{{ | ||
Value: sp(`"enrtree-root:v1 e=JWXYDBPXYWG6FX3GMDIBFA6CJ4 l=C7HRFPF3BLGF3YR4DY5KX3SMBE seq=1 sig=o908WmNp7LibOfPsr4btQwatZJ5URBr2ZAuxvK4UWHlsB9sUOTJQaGAlLPVAhM__XJesCHxLISo94z5Z2a463gA"`), | ||
}}, | ||
TTL: ip(1), | ||
Type: sp("TXT"), | ||
}, | ||
}, | ||
{ | ||
Action: sp("DELETE"), | ||
ResourceRecordSet: &route53.ResourceRecordSet{ | ||
Name: sp("fdxn3sn67na5dka4j2gok7bvqi.n"), | ||
ResourceRecords: []*route53.ResourceRecord{{ | ||
Value: sp("enrtree-branch:"), | ||
}}, | ||
TTL: ip(1), | ||
Type: sp("TXT"), | ||
}, | ||
}, | ||
} | ||
|
||
var client route53Client | ||
changes := client.computeChanges("n", testTree1, testTree0) | ||
if !reflect.DeepEqual(changes, wantChanges) { | ||
t.Fatalf("wrong changes (got %d, want %d)", len(changes), len(wantChanges)) | ||
} | ||
|
||
wantSplit := [][]*route53.Change{ | ||
wantChanges[:4], | ||
wantChanges[4:7], | ||
} | ||
split := splitChanges(changes, 600) | ||
if !reflect.DeepEqual(split, wantSplit) { | ||
t.Fatalf("wrong split batches: got %d, want %d", len(split), len(wantSplit)) | ||
} | ||
} | ||
|
||
func sp(s string) *string { return &s } | ||
func ip(i int64) *int64 { return &i } |
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.
Pls add the copyright header