-
Notifications
You must be signed in to change notification settings - Fork 131
TRT-2768: Import /payload job results from PRs into postgres #3728
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
Open
dgoodwin
wants to merge
6
commits into
openshift:main
Choose a base branch
from
dgoodwin:import-pr-payload-jobs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ce37c2e
Import /payload job results from PRs
dgoodwin 376b4d7
Port PR test failures API from bigquery to postgres
dgoodwin 5408c21
e2e testing for new Presubmits import of /payload jobs
dgoodwin cc2b47b
Address code review: normalize releaseJobName and fix TestGridURL bac…
dgoodwin 966df4b
Default date range to 2 weeks, add SHA filter to PR test results API
dgoodwin d5763a0
Replace sha param with latest_sha_only bool for PR test results API
dgoodwin 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 hidden or 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 |
|---|---|---|
|
|
@@ -125,7 +125,7 @@ type testCount struct { | |
| flake int | ||
| } | ||
|
|
||
| var syntheticReleases = []string{"4.22", "4.21", "4.20", "4.19"} | ||
| var syntheticReleases = []string{"4.22", "4.21", "4.20", "4.19", "Presubmits"} | ||
|
|
||
| var syntheticJobs = []syntheticJobDef{ | ||
| { | ||
|
|
@@ -429,6 +429,11 @@ func seedSyntheticData(dbc *db.DB) error { | |
| return err | ||
| } | ||
|
|
||
| if err := seedPresubmitData(dbc); err != nil { | ||
| return errors.WithMessage(err, "failed to seed presubmit data") | ||
| } | ||
| log.Info("Seeded presubmit/PR test data") | ||
|
|
||
| if err := createLabelsAndSymptoms(dbc); err != nil { | ||
| return errors.WithMessage(err, "failed to create labels and symptoms") | ||
| } | ||
|
|
@@ -770,6 +775,198 @@ func syncRegressions(dbc *db.DB) error { | |
| return nil | ||
| } | ||
|
|
||
| func seedPresubmitData(dbc *db.DB) error { | ||
| now := time.Now().UTC().Truncate(time.Hour) | ||
|
|
||
| var suite models.Suite | ||
| if err := dbc.DB.Where("name = ?", "synthetic").First(&suite).Error; err != nil { | ||
| return fmt.Errorf("failed to find suite: %w", err) | ||
| } | ||
|
|
||
| // Look up existing test records to reuse | ||
| testNames := []string{ | ||
| "install should succeed: overall", | ||
| "[sig-network] Services should serve endpoints on same port and different protocol", | ||
| } | ||
| testsByName := map[string]uint{} | ||
| for _, name := range testNames { | ||
| var t models.Test | ||
| if err := dbc.DB.Where("name = ?", name).First(&t).Error; err != nil { | ||
| return fmt.Errorf("failed to find test %q: %w", name, err) | ||
| } | ||
| testsByName[name] = t.ID | ||
| } | ||
|
|
||
| // Create presubmit ProwJobs | ||
| presubmitJobs := []models.ProwJob{ | ||
| { | ||
| Kind: models.ProwKind("presubmit"), | ||
| Name: "openshift-origin-ci-5.0-e2e-aws-ovn-upgrade", | ||
| Release: "Presubmits", | ||
| Variants: pq.StringArray{ | ||
| "Architecture:amd64", "FeatureSet:default", "Installer:ipi", | ||
| "LayeredProduct:none", "Network:ovn", "Platform:aws", | ||
| "Suite:unknown", "Topology:ha", "Upgrade:minor", | ||
| }, | ||
| }, | ||
| { | ||
| Kind: models.ProwKind("presubmit"), | ||
| Name: "openshift-origin-ci-5.0-e2e-gcp-ovn-amd64", | ||
| Release: "Presubmits", | ||
| Variants: pq.StringArray{ | ||
| "Architecture:amd64", "FeatureSet:default", "Installer:ipi", | ||
| "LayeredProduct:none", "Network:ovn", "Platform:gcp", | ||
| "Suite:parallel", "Topology:ha", "Upgrade:none", | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| for i, pj := range presubmitJobs { | ||
| if err := dbc.DB.Create(&pj).Error; err != nil { | ||
| return fmt.Errorf("failed to create presubmit ProwJob %s: %w", pj.Name, err) | ||
| } | ||
| presubmitJobs[i] = pj | ||
| } | ||
|
|
||
| // Create ProwPullRequests | ||
| prs := []models.ProwPullRequest{ | ||
| { | ||
| Org: "openshift", | ||
| Repo: "origin", | ||
| Number: 99001, | ||
| Author: "test-author-1", | ||
| Title: "Test PR 99001", | ||
| SHA: "abc123def456", | ||
| Link: "https://github.com/openshift/origin/pull/99001", | ||
| }, | ||
| { | ||
| Org: "openshift", | ||
| Repo: "origin", | ||
| Number: 99002, | ||
| Author: "test-author-2", | ||
| Title: "Test PR 99002", | ||
| SHA: "789abc012def", | ||
| Link: "https://github.com/openshift/origin/pull/99002", | ||
| }, | ||
| } | ||
|
|
||
| for i, pr := range prs { | ||
| if err := dbc.DB.Create(&pr).Error; err != nil { | ||
| return fmt.Errorf("failed to create ProwPullRequest %d: %w", pr.Number, err) | ||
| } | ||
| prs[i] = pr | ||
| } | ||
|
|
||
| // Create runs: 3 runs per job, PR 99001 gets job[0] runs, PR 99002 gets job[1] runs | ||
| type runInfo struct { | ||
| run models.ProwJobRun | ||
| prIdx int | ||
| } | ||
| var runs []runInfo | ||
|
|
||
| for jobIdx, pj := range presubmitJobs { | ||
| for i := 0; i < 3; i++ { | ||
| timestamp := now.Add(-time.Duration(3-i) * 20 * time.Hour) | ||
| run := models.ProwJobRun{ | ||
| ProwJobID: pj.ID, | ||
| ProwJobRelease: "Presubmits", | ||
| Cluster: "build01", | ||
| Timestamp: timestamp, | ||
| Duration: 2 * time.Hour, | ||
| OverallResult: v1.JobTestFailure, | ||
| Failed: true, | ||
| } | ||
| if err := dbc.DB.Create(&run).Error; err != nil { | ||
| return fmt.Errorf("failed to create ProwJobRun: %w", err) | ||
| } | ||
| runs = append(runs, runInfo{run: run, prIdx: jobIdx}) | ||
| } | ||
| } | ||
|
|
||
| // Link runs to PRs via join table | ||
| for _, ri := range runs { | ||
| jrpr := models.ProwJobRunProwPullRequest{ | ||
| ProwJobRunID: ri.run.ID, | ||
| ProwPullRequestID: prs[ri.prIdx].ID, | ||
| ProwJobRunRelease: "Presubmits", | ||
| ProwJobRunTimestamp: ri.run.Timestamp, | ||
| } | ||
| if err := dbc.DB.Create(&jrpr).Error; err != nil { | ||
| return fmt.Errorf("failed to create ProwJobRunProwPullRequest: %w", err) | ||
| } | ||
| } | ||
|
|
||
| // Create test results with mixed statuses | ||
| installTestID := testsByName["install should succeed: overall"] | ||
| networkTestID := testsByName["[sig-network] Services should serve endpoints on same port and different protocol"] | ||
|
|
||
| for _, ri := range runs { | ||
| // Failure result for install test | ||
| failResult := models.ProwJobRunTest{ | ||
| ProwJobRunID: ri.run.ID, | ||
| ProwJobID: ri.run.ProwJobID, | ||
| ProwJobRunRelease: "Presubmits", | ||
| ProwJobRunTimestamp: ri.run.Timestamp, | ||
| TestID: installTestID, | ||
| SuiteID: &suite.ID, | ||
| Status: 12, | ||
| Duration: 5.0, | ||
| CreatedAt: ri.run.Timestamp, | ||
| } | ||
| if err := dbc.DB.Create(&failResult).Error; err != nil { | ||
| return fmt.Errorf("failed to create failure ProwJobRunTest: %w", err) | ||
| } | ||
|
|
||
| // Add output for the first failure only | ||
| if ri.prIdx == 0 && ri.run.Timestamp.Equal(runs[0].run.Timestamp) { | ||
| output := models.ProwJobRunTestOutput{ | ||
| ProwJobRunTestID: failResult.ID, | ||
| Output: "Expected install to succeed but got timeout after 30m", | ||
| ProwJobRunTestTimestamp: ri.run.Timestamp, | ||
| ProwJobRunTestRelease: "Presubmits", | ||
| } | ||
| if err := dbc.DB.Create(&output).Error; err != nil { | ||
| return fmt.Errorf("failed to create ProwJobRunTestOutput: %w", err) | ||
| } | ||
| } | ||
|
|
||
| // Success result for install test (same test, different run aspect) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment accurate? Is says it is for the same install test, but the TestID used is "networkTestID". |
||
| successResult := models.ProwJobRunTest{ | ||
| ProwJobRunID: ri.run.ID, | ||
| ProwJobID: ri.run.ProwJobID, | ||
| ProwJobRunRelease: "Presubmits", | ||
| ProwJobRunTimestamp: ri.run.Timestamp, | ||
| TestID: networkTestID, | ||
| SuiteID: &suite.ID, | ||
| Status: 1, | ||
| Duration: 3.0, | ||
| CreatedAt: ri.run.Timestamp, | ||
| } | ||
| if err := dbc.DB.Create(&successResult).Error; err != nil { | ||
| return fmt.Errorf("failed to create success ProwJobRunTest: %w", err) | ||
| } | ||
|
|
||
| // Flake result for network test on a different test | ||
| flakeResult := models.ProwJobRunTest{ | ||
| ProwJobRunID: ri.run.ID, | ||
| ProwJobID: ri.run.ProwJobID, | ||
| ProwJobRunRelease: "Presubmits", | ||
| ProwJobRunTimestamp: ri.run.Timestamp, | ||
| TestID: installTestID, | ||
| SuiteID: &suite.ID, | ||
| Status: 13, | ||
| Duration: 4.0, | ||
| CreatedAt: ri.run.Timestamp, | ||
| } | ||
| if err := dbc.DB.Create(&flakeResult).Error; err != nil { | ||
| return fmt.Errorf("failed to create flake ProwJobRunTest: %w", err) | ||
| } | ||
| } | ||
|
|
||
| log.Infof("Created presubmit seed data: %d jobs, %d PRs, %d runs", len(presubmitJobs), len(prs), len(runs)) | ||
| return nil | ||
| } | ||
|
|
||
| const syntheticViewsFile = "config/seed-views.yaml" | ||
|
|
||
| // variantMapToArray converts a variant map to a pq.StringArray. | ||
|
|
||
Oops, something went wrong.
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.
Should we use the constants for Status?
https://github.com/dgoodwin/sippy/blob/d5763a01aef34537cb3c36a371780739aee6092d/pkg/apis/sippyprocessing/v1/types.go#L206-L212