refactor(netx): merge archival, trace, and the savers (#772)
This diff creates a new package under netx called tracex that contains everything we need to perform measurements using events tracing and postprocessing (which is the technique with which we implement most network experiments). The general idea here is to (1) create a unique package out of all of these packages; (2) clean up the code a bit (improve tests, docs, apply more recent code patterns); (3) move the resulting code as a toplevel package inside of internal. Once this is done, netx can be further refactored to avoid subpackages and we can search for more code to salvage/refactor. See https://github.com/ooni/probe/issues/2121
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/randx"
|
||||
)
|
||||
|
||||
@@ -42,8 +42,8 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "response body is truncated",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
BodyIsTruncated: true,
|
||||
},
|
||||
}},
|
||||
@@ -59,8 +59,8 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "response body length is zero",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{},
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{},
|
||||
}},
|
||||
},
|
||||
ctrl: webconnectivity.ControlResponse{
|
||||
@@ -74,9 +74,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "control length is negative",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(768),
|
||||
},
|
||||
},
|
||||
@@ -93,9 +93,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "match with bigger control",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(768),
|
||||
},
|
||||
},
|
||||
@@ -113,9 +113,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "match with bigger measurement",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(1024),
|
||||
},
|
||||
},
|
||||
@@ -133,9 +133,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "not match with bigger control",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(8),
|
||||
},
|
||||
},
|
||||
@@ -153,9 +153,9 @@ func TestHTTPBodyLengthChecks(t *testing.T) {
|
||||
name: "match with bigger measurement",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: randx.Letters(16),
|
||||
},
|
||||
},
|
||||
@@ -203,15 +203,15 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with a request but zero status codes",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
}, {
|
||||
name: "with equal status codes including 5xx",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 501,
|
||||
},
|
||||
}},
|
||||
@@ -227,8 +227,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with different status codes and the control being 5xx",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 407,
|
||||
},
|
||||
}},
|
||||
@@ -244,8 +244,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with different status codes and the control being not 5xx",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 407,
|
||||
},
|
||||
}},
|
||||
@@ -261,8 +261,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with only response status code and no control status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
},
|
||||
}},
|
||||
@@ -272,8 +272,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with response status code and -1 as control status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
},
|
||||
}},
|
||||
@@ -288,8 +288,8 @@ func TestStatusCodeMatch(t *testing.T) {
|
||||
name: "with only control status code and no response status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 0,
|
||||
},
|
||||
}},
|
||||
@@ -346,7 +346,7 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with request and no response status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
ctrl: webconnectivity.ControlResponse{
|
||||
HTTPRequest: webconnectivity.ControlHTTPRequestResult{
|
||||
@@ -363,9 +363,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with no control status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
},
|
||||
Code: 200,
|
||||
@@ -379,9 +379,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with negative control status code",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
},
|
||||
Code: 200,
|
||||
@@ -399,9 +399,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with no uncommon headers",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
},
|
||||
Code: 200,
|
||||
@@ -422,9 +422,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with equal uncommon headers",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
"Antani": {Value: "MASCETTI"},
|
||||
},
|
||||
@@ -447,9 +447,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with different uncommon headers",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Date": {Value: "Mon Jul 13 21:10:08 CEST 2020"},
|
||||
"Antani": {Value: "MASCETTI"},
|
||||
},
|
||||
@@ -472,9 +472,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with small uncommon intersection (X-Cache)",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Accept-Ranges": {Value: "bytes"},
|
||||
"Age": {Value: "404727"},
|
||||
"Cache-Control": {Value: "max-age=604800"},
|
||||
@@ -519,9 +519,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with no uncommon intersection",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Accept-Ranges": {Value: "bytes"},
|
||||
"Age": {Value: "404727"},
|
||||
"Cache-Control": {Value: "max-age=604800"},
|
||||
@@ -564,9 +564,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with exactly equal headers",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"Accept-Ranges": {Value: "bytes"},
|
||||
"Age": {Value: "404727"},
|
||||
"Cache-Control": {Value: "max-age=604800"},
|
||||
@@ -605,9 +605,9 @@ func TestHeadersMatch(t *testing.T) {
|
||||
name: "with equal headers except for the case",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Headers: map[string]archival.MaybeBinaryValue{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Headers: map[string]tracex.MaybeBinaryValue{
|
||||
"accept-ranges": {Value: "bytes"},
|
||||
"AGE": {Value: "404727"},
|
||||
"cache-Control": {Value: "max-age=604800"},
|
||||
@@ -674,7 +674,7 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "with a request and no response",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
wantOut: nil,
|
||||
@@ -682,8 +682,8 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "with a response with truncated body",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
BodyIsTruncated: true,
|
||||
},
|
||||
@@ -695,10 +695,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "with a response with good body",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{Value: "<HTML/>"},
|
||||
Body: tracex.MaybeBinaryValue{Value: "<HTML/>"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
@@ -708,10 +708,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "with all good but no titles",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{Value: "<HTML/>"},
|
||||
Body: tracex.MaybeBinaryValue{Value: "<HTML/>"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
@@ -727,10 +727,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "reasonably common case where it succeeds",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TITLE>La community di MSN</TITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
@@ -747,10 +747,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "reasonably common case where it fails",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TITLE>La communità di MSN</TITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
@@ -767,10 +767,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "when the title is too long",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TITLE>" + randx.Letters(1024) + "</TITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
@@ -787,10 +787,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "reasonably common case where it succeeds with case variations",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TiTLe>La commUNity di MSN</tITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
@@ -807,10 +807,10 @@ func TestTitleMatch(t *testing.T) {
|
||||
name: "when the control status code is negative",
|
||||
args: args{
|
||||
tk: urlgetter.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Response: archival.HTTPResponse{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Response: tracex.HTTPResponse{
|
||||
Code: 200,
|
||||
Body: archival.MaybeBinaryValue{
|
||||
Body: tracex.MaybeBinaryValue{
|
||||
Value: "<HTML><TiTLe>La commUNity di MSN</tITLE></HTML>"},
|
||||
},
|
||||
}},
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
|
||||
@@ -41,8 +41,8 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with an HTTPS request with no failure",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Request: archival.HTTPRequest{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Request: tracex.HTTPRequest{
|
||||
URL: "https://www.kernel.org/",
|
||||
},
|
||||
Failure: nil,
|
||||
@@ -210,7 +210,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with connection refused",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeConnectionRefused,
|
||||
}},
|
||||
},
|
||||
@@ -226,7 +226,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with connection reset",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeConnectionReset,
|
||||
}},
|
||||
},
|
||||
@@ -242,7 +242,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with NXDOMAIN",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeNXDOMAIN,
|
||||
}},
|
||||
},
|
||||
@@ -258,7 +258,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with EOF",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeEOFError,
|
||||
}},
|
||||
},
|
||||
@@ -274,7 +274,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with timeout",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeTimeout,
|
||||
}},
|
||||
},
|
||||
@@ -290,7 +290,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with SSL invalid hostname",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLInvalidHost,
|
||||
}},
|
||||
},
|
||||
@@ -306,7 +306,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with SSL invalid cert",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLInvalidCert,
|
||||
}},
|
||||
},
|
||||
@@ -322,7 +322,7 @@ func TestSummarize(t *testing.T) {
|
||||
name: "with SSL unknown auth",
|
||||
args: args{
|
||||
tk: &webconnectivity.TestKeys{
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLUnknownAuth,
|
||||
}},
|
||||
},
|
||||
@@ -341,7 +341,7 @@ func TestSummarize(t *testing.T) {
|
||||
DNSAnalysisResult: webconnectivity.DNSAnalysisResult{
|
||||
DNSConsistency: &webconnectivity.DNSInconsistent,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLUnknownAuth,
|
||||
}},
|
||||
},
|
||||
@@ -361,7 +361,7 @@ func TestSummarize(t *testing.T) {
|
||||
DNSAnalysisResult: webconnectivity.DNSAnalysisResult{
|
||||
DNSConsistency: &webconnectivity.DNSInconsistent,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{
|
||||
Requests: []tracex.RequestEntry{{
|
||||
Failure: &probeSSLUnknownAuth,
|
||||
}, {}},
|
||||
},
|
||||
@@ -381,7 +381,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &trueValue,
|
||||
BodyLengthMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
wantOut: webconnectivity.Summary{
|
||||
@@ -398,7 +398,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &trueValue,
|
||||
HeadersMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
wantOut: webconnectivity.Summary{
|
||||
@@ -415,7 +415,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &trueValue,
|
||||
TitleMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
},
|
||||
},
|
||||
wantOut: webconnectivity.Summary{
|
||||
@@ -432,7 +432,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &falseValue,
|
||||
TitleMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
DNSAnalysisResult: webconnectivity.DNSAnalysisResult{
|
||||
DNSConsistency: &webconnectivity.DNSInconsistent,
|
||||
},
|
||||
@@ -453,7 +453,7 @@ func TestSummarize(t *testing.T) {
|
||||
StatusCodeMatch: &falseValue,
|
||||
TitleMatch: &trueValue,
|
||||
},
|
||||
Requests: []archival.RequestEntry{{}},
|
||||
Requests: []tracex.RequestEntry{{}},
|
||||
DNSAnalysisResult: webconnectivity.DNSAnalysisResult{
|
||||
DNSConsistency: &webconnectivity.DNSConsistent,
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity/internal"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
)
|
||||
|
||||
@@ -34,12 +34,12 @@ type TestKeys struct {
|
||||
// is rather obvious where they come from.
|
||||
//
|
||||
// See https://github.com/ooni/probe/issues/1413.
|
||||
NetworkEvents []archival.NetworkEvent `json:"network_events"`
|
||||
TLSHandshakes []archival.TLSHandshake `json:"tls_handshakes"`
|
||||
NetworkEvents []tracex.NetworkEvent `json:"network_events"`
|
||||
TLSHandshakes []tracex.TLSHandshake `json:"tls_handshakes"`
|
||||
|
||||
// DNS experiment
|
||||
Queries []archival.DNSQueryEntry `json:"queries"`
|
||||
DNSExperimentFailure *string `json:"dns_experiment_failure"`
|
||||
Queries []tracex.DNSQueryEntry `json:"queries"`
|
||||
DNSExperimentFailure *string `json:"dns_experiment_failure"`
|
||||
DNSAnalysisResult
|
||||
|
||||
// Control experiment
|
||||
@@ -48,13 +48,13 @@ type TestKeys struct {
|
||||
Control ControlResponse `json:"control"`
|
||||
|
||||
// TCP/TLS "connect" experiment
|
||||
TCPConnect []archival.TCPConnectEntry `json:"tcp_connect"`
|
||||
TCPConnectSuccesses int `json:"-"`
|
||||
TCPConnectAttempts int `json:"-"`
|
||||
TCPConnect []tracex.TCPConnectEntry `json:"tcp_connect"`
|
||||
TCPConnectSuccesses int `json:"-"`
|
||||
TCPConnectAttempts int `json:"-"`
|
||||
|
||||
// HTTP experiment
|
||||
Requests []archival.RequestEntry `json:"requests"`
|
||||
HTTPExperimentFailure *string `json:"http_experiment_failure"`
|
||||
Requests []tracex.RequestEntry `json:"requests"`
|
||||
HTTPExperimentFailure *string `json:"http_experiment_failure"`
|
||||
HTTPAnalysisResult
|
||||
|
||||
// Top-level analysis
|
||||
@@ -180,7 +180,7 @@ func (m Measurer) Run(
|
||||
TCPConnect: epnts.Endpoints(),
|
||||
})
|
||||
tk.THRuntime = time.Since(thBegin)
|
||||
tk.ControlFailure = archival.NewFailure(err)
|
||||
tk.ControlFailure = tracex.NewFailure(err)
|
||||
// 4. analyze DNS results
|
||||
if tk.ControlFailure == nil {
|
||||
tk.DNSAnalysisResult = DNSAnalysis(URL, dnsResult, tk.Control)
|
||||
@@ -240,9 +240,9 @@ func (m Measurer) Run(
|
||||
|
||||
// ComputeTCPBlocking will return a copy of the input TCPConnect structure
|
||||
// where we set the Blocking value depending on the control results.
|
||||
func ComputeTCPBlocking(measurement []archival.TCPConnectEntry,
|
||||
control map[string]ControlTCPConnectResult) (out []archival.TCPConnectEntry) {
|
||||
out = []archival.TCPConnectEntry{}
|
||||
func ComputeTCPBlocking(measurement []tracex.TCPConnectEntry,
|
||||
control map[string]ControlTCPConnectResult) (out []tracex.TCPConnectEntry) {
|
||||
out = []tracex.TCPConnectEntry{}
|
||||
for _, me := range measurement {
|
||||
epnt := net.JoinHostPort(me.IP, strconv.Itoa(me.Port))
|
||||
if ce, ok := control[epnt]; ok {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
engine "github.com/ooni/probe-cli/v3/internal/engine"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival"
|
||||
"github.com/ooni/probe-cli/v3/internal/engine/netx/tracex"
|
||||
"github.com/ooni/probe-cli/v3/internal/model"
|
||||
"github.com/ooni/probe-cli/v3/internal/netxlite"
|
||||
)
|
||||
@@ -232,33 +232,33 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
failure := io.EOF.Error()
|
||||
anotherFailure := "unknown_error"
|
||||
type args struct {
|
||||
measurement []archival.TCPConnectEntry
|
||||
measurement []tracex.TCPConnectEntry
|
||||
control map[string]webconnectivity.ControlTCPConnectResult
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []archival.TCPConnectEntry
|
||||
want []tracex.TCPConnectEntry
|
||||
}{{
|
||||
name: "with all empty",
|
||||
args: args{},
|
||||
want: []archival.TCPConnectEntry{},
|
||||
want: []tracex.TCPConnectEntry{},
|
||||
}, {
|
||||
name: "with control failure",
|
||||
args: args{
|
||||
measurement: []archival.TCPConnectEntry{{
|
||||
measurement: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
},
|
||||
}},
|
||||
},
|
||||
want: []archival.TCPConnectEntry{{
|
||||
want: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
},
|
||||
@@ -266,10 +266,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
}, {
|
||||
name: "with failures on both ends",
|
||||
args: args{
|
||||
measurement: []archival.TCPConnectEntry{{
|
||||
measurement: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
},
|
||||
@@ -281,10 +281,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: []archival.TCPConnectEntry{{
|
||||
want: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Blocked: &falseValue,
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
@@ -293,10 +293,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
}, {
|
||||
name: "with failure on the probe side",
|
||||
args: args{
|
||||
measurement: []archival.TCPConnectEntry{{
|
||||
measurement: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
},
|
||||
@@ -308,10 +308,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: []archival.TCPConnectEntry{{
|
||||
want: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Blocked: &trueValue,
|
||||
Failure: &failure,
|
||||
Success: false,
|
||||
@@ -320,10 +320,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
}, {
|
||||
name: "with failure on the control side",
|
||||
args: args{
|
||||
measurement: []archival.TCPConnectEntry{{
|
||||
measurement: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Failure: nil,
|
||||
Success: true,
|
||||
},
|
||||
@@ -335,10 +335,10 @@ func TestComputeTCPBlocking(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: []archival.TCPConnectEntry{{
|
||||
want: []tracex.TCPConnectEntry{{
|
||||
IP: "1.1.1.1",
|
||||
Port: 853,
|
||||
Status: archival.TCPConnectStatus{
|
||||
Status: tracex.TCPConnectStatus{
|
||||
Blocked: &falseValue,
|
||||
Failure: nil,
|
||||
Success: true,
|
||||
|
||||
Reference in New Issue
Block a user