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

NO-JIRA: debug jiraloader component #2067

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions pkg/api/pull_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ package api
import (
apitype "github.com/openshift/sippy/pkg/apis/api"
"github.com/openshift/sippy/pkg/db"
"github.com/openshift/sippy/pkg/db/models"
"github.com/openshift/sippy/pkg/db/query"
"github.com/openshift/sippy/pkg/filter"
)

func GetPullRequestsReportFromDB(dbc *db.DB, release string, filterOpts *filter.FilterOptions) ([]apitype.PullRequest, error) {
return query.PullRequestReport(dbc, filterOpts, release)
}

func GetPayloadDiffPullRequests(dbc *db.DB, fromPayload, toPayload string) ([]models.ReleasePullRequest, error) {
return query.GetPayloadDiff(dbc.DB, fromPayload, toPayload)
}
1 change: 1 addition & 0 deletions pkg/dataloader/jiraloader/jiraloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (jl *JiraLoader) componentLoader() {
var components []v1jira.Component
err = json.Unmarshal(body, &components)
if err != nil {
log.Infof("JIRA Component Request Body Length: %d\n\n%s\n\n", len(body), body)
jl.errors = append(jl.errors, err)
return
}
Expand Down
15 changes: 15 additions & 0 deletions pkg/db/query/payload_queries.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
package query

import (
"fmt"
"time"

"gorm.io/gorm"

"github.com/openshift/sippy/pkg/db/models"
)

func GetPayloadDiff(db *gorm.DB, fromPayload, toPayload string) ([]models.ReleasePullRequest, error) {
results := make([]models.ReleasePullRequest, 0)
query := fmt.Sprintf(`SELECT url,pull_request_id,name,description,bug_url FROM release_pull_requests
WHERE id IN ( SELECT release_pull_request_id FROM release_tag_pull_requests WHERE release_tag_id IN (SELECT id FROM release_tags WHERE release_tag ='%s'))
AND id NOT IN ( SELECT release_pull_request_id FROM release_tag_pull_requests WHERE release_tag_id IN (SELECT id FROM release_tags WHERE release_tag ='%s')) ORDER BY url`, toPayload, fromPayload)
result := db.Raw(query).Scan(&results)

if result.Error != nil {
return nil, result.Error
}

return results, nil
}

// GetLastAcceptedByArchitectureAndStream returns the last accepted payload for each architecture/stream combo.
func GetLastAcceptedByArchitectureAndStream(db *gorm.DB, release string, reportEnd time.Time) ([]models.ReleaseTag, error) {
results := make([]models.ReleaseTag, 0)
Expand Down
23 changes: 23 additions & 0 deletions pkg/sippyserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,23 @@ func (s *Server) jsonReleaseHealthReport(w http.ResponseWriter, req *http.Reques
api.RespondWithJSON(http.StatusOK, w, results)
}

func (s *Server) jsonPayloadDiff(w http.ResponseWriter, req *http.Request) {
fromPayload := req.URL.Query().Get("fromPayload")
toPayload := req.URL.Query().Get("toPayload")
results, err := api.GetPayloadDiffPullRequests(s.db, fromPayload, toPayload)

if err != nil {
log.WithError(err).Error("error generating payload diff")
api.RespondWithJSON(http.StatusInternalServerError, w, map[string]interface{}{
"code": http.StatusInternalServerError,
"message": err.Error(),
})
return
}

api.RespondWithJSON(http.StatusOK, w, results)
}

func (s *Server) jsonTestAnalysis(w http.ResponseWriter, req *http.Request, dbFN func(*db.DB, *filter.Filter, string, string, time.Time) (map[string][]api.CountByDate, error)) {
testName := req.URL.Query().Get("test")
if testName == "" {
Expand Down Expand Up @@ -1617,6 +1634,12 @@ func (s *Server) Serve() {
Capabilities: []string{LocalDBCapability},
HandlerFunc: s.jsonGetPayloadTestFailures,
},
{
EndpointPath: "/api/payloads/diff",
Description: "Reports pull requests that differ between payloads",
Capabilities: []string{LocalDBCapability},
HandlerFunc: s.jsonPayloadDiff,
},
}

for _, ep := range endpoints {
Expand Down