Skip to content

Commit

Permalink
refactor(minipipeline): allow avoiding linear analysis (#1448)
Browse files Browse the repository at this point in the history
This is yak shaving for ooni/probe#2640.
  • Loading branch information
bassosimone authored Jan 16, 2024
1 parent 4bf2ae2 commit 75780fd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/cmd/minipipeline/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ func main() {

// generate and write observations analysis
analysisPath := filepath.Join(*destdirFlag, *prefixFlag+"analysis.json")
analysis := minipipeline.AnalyzeWebObservations(container)
analysis := minipipeline.AnalyzeWebObservationsWithLinearAnalysis(container)
mustWriteFileFn(analysisPath, must.MarshalAndIndentJSON(analysis, "", " "), 0600)

// generate and write the classic analysis
classicAnalysisPath := filepath.Join(*destdirFlag, *prefixFlag+"analysis_classic.json")
analysisClassic := minipipeline.AnalyzeWebObservations(containerClassic)
analysisClassic := minipipeline.AnalyzeWebObservationsWithLinearAnalysis(containerClassic)
mustWriteFileFn(classicAnalysisPath, must.MarshalAndIndentJSON(analysisClassic, "", " "), 0600)
}
4 changes: 2 additions & 2 deletions internal/cmd/qatool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ func runWebConnectivityLTE(tc *webconnectivityqa.TestCase) {
mustSerializeMkdirAllAndWriteFile(actualDestdir, "observations_classic.json", observationsContainerClassic)

// analyze the observations
analysis := minipipeline.AnalyzeWebObservations(observationsContainer)
analysis := minipipeline.AnalyzeWebObservationsWithLinearAnalysis(observationsContainer)

// serialize the observations analysis
mustSerializeMkdirAllAndWriteFile(actualDestdir, "analysis.json", analysis)

// perform the classic analysis
analysisClassic := minipipeline.AnalyzeWebObservations(observationsContainerClassic)
analysisClassic := minipipeline.AnalyzeWebObservationsWithLinearAnalysis(observationsContainerClassic)

// serialize the classic analysis results
mustSerializeMkdirAllAndWriteFile(actualDestdir, "analysis_classic.json", analysisClassic)
Expand Down
2 changes: 1 addition & 1 deletion internal/experiment/webconnectivitylte/analysisclassic.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (tk *TestKeys) analysisClassic(logger model.Logger) {
classic := minipipeline.ClassicFilter(container)

// 3. produce a web observations analysis based on the web observations
woa := minipipeline.AnalyzeWebObservations(classic)
woa := minipipeline.AnalyzeWebObservationsWithLinearAnalysis(classic)

// 4. determine the DNS consistency
tk.DNSConsistency = analysisClassicDNSConsistency(woa)
Expand Down
13 changes: 10 additions & 3 deletions internal/minipipeline/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ func NewLinearWebAnalysis(input *WebObservationsContainer) (output []*WebObserva
return
}

// AnalyzeWebObservations generates a [*WebAnalysis] from a [*WebObservationsContainer].
func AnalyzeWebObservations(container *WebObservationsContainer) *WebAnalysis {
// AnalyzeWebObservationsWithoutLinearAnalysis generates a [*WebAnalysis] from a [*WebObservationsContainer]
// but avoids calling [NewLinearyAnalysis] to generate a linear analysis.
func AnalyzeWebObservationsWithoutLinearAnalysis(container *WebObservationsContainer) *WebAnalysis {
analysis := &WebAnalysis{}

analysis.dnsComputeSuccessMetrics(container)
Expand All @@ -105,8 +106,14 @@ func AnalyzeWebObservations(container *WebObservationsContainer) *WebAnalysis {
analysis.httpComputeFailureMetrics(container)
analysis.httpComputeFinalResponseMetrics(container)

analysis.Linear = NewLinearWebAnalysis(container)
return analysis
}

// AnalyzeWebObservationsWithLinearAnalysis generates a [*WebAnalysis] from a [*WebObservationsContainer]
// and ensures we also use [NewLinearyAnalysis] to generate a linear analysis.
func AnalyzeWebObservationsWithLinearAnalysis(container *WebObservationsContainer) *WebAnalysis {
analysis := AnalyzeWebObservationsWithoutLinearAnalysis(container)
analysis.Linear = NewLinearWebAnalysis(container)
return analysis
}

Expand Down
4 changes: 2 additions & 2 deletions internal/minipipeline/qa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ func testMustRunAllWebTestCases(t *testing.T, topdir string) {
gotClassicContainerData := minipipeline.ClassicFilter(gotContainerData)

// analyze the measurement
gotAnalysisData := minipipeline.AnalyzeWebObservations(gotContainerData)
gotAnalysisData := minipipeline.AnalyzeWebObservationsWithLinearAnalysis(gotContainerData)

// perform the classic web-connectivity-v0.4-like analysis
gotClassicAnalysisData := minipipeline.AnalyzeWebObservations(gotClassicContainerData)
gotClassicAnalysisData := minipipeline.AnalyzeWebObservationsWithLinearAnalysis(gotClassicContainerData)

//
// Note: if tests fail, you likely need to regenerate the static test
Expand Down

0 comments on commit 75780fd

Please sign in to comment.