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

fix(webconnectivitylte): never sort test keys #1506

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions internal/cmd/qatool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ func runWebConnectivityLTE(tc *webconnectivityqa.TestCase) {
// run the test case
measurement := runtimex.Try1(webconnectivityqa.MeasureTestCase(measurer, tc))

// obtain the test keys
tk := measurement.TestKeys.(*webconnectivitylte.TestKeys)

// normalize the test keys
//
// see https://github.com/ooni/probe/issues/2677
tk.Queries = minipipeline.SortDNSLookupResults(tk.Queries)
tk.Do53.Queries = minipipeline.SortDNSLookupResults(tk.Do53.Queries)
tk.DoH.Queries = minipipeline.SortDNSLookupResults(tk.DoH.Queries)
tk.DNSDuplicateResponses = minipipeline.SortDNSLookupResults(tk.DNSDuplicateResponses)
tk.NetworkEvents = minipipeline.SortNetworkEvents(tk.NetworkEvents)
tk.TCPConnect = minipipeline.SortTCPConnectResults(tk.TCPConnect)
tk.TLSHandshakes = minipipeline.SortTLSHandshakeResults(tk.TLSHandshakes)

// serialize the original measurement
mustSerializeMkdirAllAndWriteFile(actualDestdir, "measurement.json", measurement)
}
Expand Down Expand Up @@ -135,9 +149,6 @@ func main() {
// build the regexp
selector := regexp.MustCompile(*runFlag)

// make sure we produce more predictable observations in output
webconnectivitylte.SortObservations.Add(1)

// select which test cases to run
for _, tc := range webconnectivityqa.AllTestCases() {
name := "webconnectivitylte/" + tc.Name
Expand Down
22 changes: 0 additions & 22 deletions internal/experiment/webconnectivitylte/measurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/ooni/probe-cli/v3/internal/experiment/webconnectivity"
"github.com/ooni/probe-cli/v3/internal/inputparser"
"github.com/ooni/probe-cli/v3/internal/minipipeline"
"github.com/ooni/probe-cli/v3/internal/model"
"golang.org/x/net/publicsuffix"
)
Expand Down Expand Up @@ -145,23 +144,6 @@ func (m *Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
}
}

// sort test keys to make output more predictable and avoid churn when generating
// minipipeline test cases; see https://github.com/ooni/probe/issues/2677.
//
// Note that tk.Do53 and tk.DoH are initialized by NewTestKeys so we know they're not nil.
//
// Note that we MUST NOT sort tk.Requests because its order matters for historical
// reasons and we don't wnat to break existing data consumers.
if SortObservations.Load() > 0 {
tk.Queries = minipipeline.SortDNSLookupResults(tk.Queries)
tk.Do53.Queries = minipipeline.SortDNSLookupResults(tk.Do53.Queries)
tk.DoH.Queries = minipipeline.SortDNSLookupResults(tk.DoH.Queries)
tk.DNSDuplicateResponses = minipipeline.SortDNSLookupResults(tk.DNSDuplicateResponses)
tk.NetworkEvents = minipipeline.SortNetworkEvents(tk.NetworkEvents)
tk.TCPConnect = minipipeline.SortTCPConnectResults(tk.TCPConnect)
tk.TLSHandshakes = minipipeline.SortTLSHandshakeResults(tk.TLSHandshakes)
}

// return whether there was a fundamental failure, which would prevent
// the measurement from being submitted to the OONI collector.
return tk.fundamentalFailure
Expand All @@ -177,7 +159,3 @@ func registerExtensions(m *model.Measurement) {
model.ArchivalExtTLSHandshake.AddTo(m)
model.ArchivalExtTunnel.AddTo(m)
}

// SortObservations allows to configure sorting observations when that's needed to
// reduce churn in the generated JSON files (mainly for minipipeline).
var SortObservations = &atomic.Int64{}
1 change: 0 additions & 1 deletion internal/experiment/webconnectivitylte/qa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
)

func TestQA(t *testing.T) {
SortObservations.Add(1) // make sure we have predictable observations
for _, tc := range webconnectivityqa.AllTestCases() {
t.Run(tc.Name, func(t *testing.T) {
if (tc.Flags & webconnectivityqa.TestCaseFlagNoLTE) != 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"Failure": "ssl_invalid_certificate",
"TransactionID": 3,
"TagFetchBody": true,
"DNSTransactionID": 2,
"DNSTransactionID": 1,
"DNSDomain": "expired.badssl.com",
"DNSLookupFailure": "",
"DNSQueryType": null,
Expand Down Expand Up @@ -108,8 +108,8 @@
"DNSTransactionID": 2,
"DNSDomain": "expired.badssl.com",
"DNSLookupFailure": "",
"DNSQueryType": "ANY",
"DNSEngine": "getaddrinfo",
"DNSQueryType": "A",
"DNSEngine": "udp",
"DNSResolvedAddrs": [
"104.154.89.105"
],
Expand Down Expand Up @@ -155,8 +155,8 @@
"DNSTransactionID": 1,
"DNSDomain": "expired.badssl.com",
"DNSLookupFailure": "",
"DNSQueryType": "A",
"DNSEngine": "udp",
"DNSQueryType": "ANY",
"DNSEngine": "getaddrinfo",
"DNSResolvedAddrs": [
"104.154.89.105"
],
Expand Down Expand Up @@ -197,9 +197,9 @@
"TagDepth": 0,
"Type": 0,
"Failure": "dns_no_answer",
"TransactionID": 1,
"TransactionID": 2,
"TagFetchBody": null,
"DNSTransactionID": 1,
"DNSTransactionID": 2,
"DNSDomain": "expired.badssl.com",
"DNSLookupFailure": "dns_no_answer",
"DNSQueryType": "AAAA",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"FinalResponseFailure": "unknown_error"
},
"DNSLookupSuccess": [
2
1
],
"DNSLookupSuccessWithInvalidAddresses": [],
"DNSLookupSuccessWithValidAddress": [
2
1
],
"DNSLookupSuccessWithBogonAddresses": [],
"DNSLookupSuccessWithInvalidAddressesClassic": [],
"DNSLookupSuccessWithValidAddressClassic": [
2
1
],
"DNSLookupUnexpectedFailure": [],
"DNSLookupUnexplainedFailure": [],
Expand Down Expand Up @@ -55,7 +55,7 @@
"Failure": "ssl_invalid_certificate",
"TransactionID": 3,
"TagFetchBody": true,
"DNSTransactionID": 2,
"DNSTransactionID": 1,
"DNSDomain": "expired.badssl.com",
"DNSLookupFailure": "",
"DNSQueryType": null,
Expand Down Expand Up @@ -100,9 +100,9 @@
"TagDepth": 0,
"Type": 0,
"Failure": "",
"TransactionID": 2,
"TransactionID": 1,
"TagFetchBody": null,
"DNSTransactionID": 2,
"DNSTransactionID": 1,
"DNSDomain": "expired.badssl.com",
"DNSLookupFailure": "",
"DNSQueryType": "ANY",
Expand Down
Loading
Loading