-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add end-to-end integration test for entire pipeline
- Loading branch information
Showing
3 changed files
with
76 additions
and
29 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// Build runs the entire QRank pipeline. | ||
func Build(dumps string, numWeeks int, s3 S3) error { | ||
ctx := context.Background() | ||
|
||
pageviews, err := buildPageviews(ctx, dumps, numWeeks, s3) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
sites, err := ReadWikiSites(dumps) | ||
if err != nil { | ||
return err | ||
} | ||
logger.Printf("found wikimedia dumps for %d sites", len(*sites)) | ||
|
||
if err := buildPageSignals(ctx, dumps, sites, s3); err != nil { | ||
return err | ||
} | ||
|
||
_, err = buildItemSignals(ctx, pageviews, sites, s3) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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,41 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"log" | ||
"path/filepath" | ||
"slices" | ||
"testing" | ||
) | ||
|
||
// TestBuild is a large integration test that runs the entire pipeline. | ||
func TestBuild(t *testing.T) { | ||
if testing.Short() { | ||
t.Skip() | ||
} | ||
|
||
logger = log.New(&bytes.Buffer{}, "", log.Lshortfile) | ||
dumps := filepath.Join("testdata", "dumps") | ||
s3 := NewFakeS3() | ||
if err := Build(dumps /*numWeeks*/, 1, s3); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
got, err := s3.ReadLines("public/item_signals-20240501.csv.zst") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
want := []string{ | ||
"item,pageviews_52w,wikitext_bytes,claims,identifiers,sitelinks", | ||
"Q72,0,3142,550,85,186", | ||
"Q5296,0,2872,0,0,0", | ||
"Q662541,3,4973,32,9,15", | ||
"Q5649951,0,0,1,0,20", | ||
"Q107661323,0,3470,0,0,0", | ||
} | ||
|
||
if !slices.Equal(got, want) { | ||
t.Errorf("got %v, want %v", got, want) | ||
} | ||
} |
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