Implements query for build/insmod/test logs
This commit is contained in:
parent
5ed23ee2b0
commit
b7624f0d28
22
db.go
22
db.go
@ -156,6 +156,28 @@ func getAllArtifactLogs(db *sql.DB, num int, ka config.Artifact) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getLogByID(db *sql.DB, id int) (le logEntry, err error) {
|
||||||
|
stmt, err := db.Prepare("SELECT id, time, name, type, " +
|
||||||
|
"distro_type, distro_release, kernel_release, " +
|
||||||
|
"build_ok, run_ok, test_ok, " +
|
||||||
|
"build_output, run_output, test_output, " +
|
||||||
|
"kernel_panic, timeout_kill " +
|
||||||
|
"FROM log WHERE id=$1")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer stmt.Close()
|
||||||
|
|
||||||
|
err = stmt.QueryRow(id).Scan(&le.ID, &le.Timestamp,
|
||||||
|
&le.Name, &le.Type,
|
||||||
|
&le.DistroType, &le.DistroRelease, &le.KernelRelease,
|
||||||
|
&le.Build.Ok, &le.Run.Ok, &le.Test.Ok,
|
||||||
|
&le.Build.Output, &le.Run.Output, &le.Test.Output,
|
||||||
|
&le.KernelPanic, &le.KilledByTimeout,
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func createSchema(db *sql.DB) (err error) {
|
func createSchema(db *sql.DB) (err error) {
|
||||||
err = createLogTable(db)
|
err = createLogTable(db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
39
log.go
39
log.go
@ -92,3 +92,42 @@ func logHandler(db *sql.DB, path string, num int, rate bool) (err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func logDumpHandler(db *sql.DB, id int) (err error) {
|
||||||
|
l, err := getLogByID(db, id)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("ID:", l.ID)
|
||||||
|
fmt.Println("Date:", l.Timestamp)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
fmt.Println("Type:", l.Type.String())
|
||||||
|
fmt.Println("Name:", l.Name)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
fmt.Println("Distro:", l.DistroType.String(), l.DistroRelease)
|
||||||
|
fmt.Println("Kernel:", l.KernelRelease)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
fmt.Println("Build ok:", l.Build.Ok)
|
||||||
|
if l.Type == config.KernelModule {
|
||||||
|
fmt.Println("Insmod ok:", l.Run.Ok)
|
||||||
|
}
|
||||||
|
fmt.Println("Test ok:", l.Test.Ok)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
fmt.Printf("Build output:\n%s\n", l.Build.Output)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
if l.Type == config.KernelModule {
|
||||||
|
fmt.Printf("Insmod output:\n%s\n", l.Run.Output)
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Test output:\n%s\n", l.Test.Output)
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
16
main.go
16
main.go
@ -158,9 +158,15 @@ func main() {
|
|||||||
bootstrapCommand := app.Command("bootstrap",
|
bootstrapCommand := app.Command("bootstrap",
|
||||||
"Create directories && download images")
|
"Create directories && download images")
|
||||||
|
|
||||||
logCommand := app.Command("log", "Query logs")
|
logCommand := app.Command("log", "Logs")
|
||||||
logNum := logCommand.Flag("num", "How much lines").Default("50").Int()
|
|
||||||
logRate := logCommand.Flag("rate", "Show artifact success rate").Bool()
|
logQueryCommand := logCommand.Command("query", "Query logs")
|
||||||
|
logNum := logQueryCommand.Flag("num", "How much lines").Default("50").Int()
|
||||||
|
logRate := logQueryCommand.Flag("rate", "Show artifact success rate").Bool()
|
||||||
|
|
||||||
|
logDumpCommand := logCommand.Command("dump",
|
||||||
|
"Show all info for log entry with ID")
|
||||||
|
logDumpID := logDumpCommand.Arg("ID", "").Required().Int()
|
||||||
|
|
||||||
err = checkRequiredUtils()
|
err = checkRequiredUtils()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -240,8 +246,10 @@ func main() {
|
|||||||
*dockerTimeout)
|
*dockerTimeout)
|
||||||
case bootstrapCommand.FullCommand():
|
case bootstrapCommand.FullCommand():
|
||||||
err = bootstrapHandler()
|
err = bootstrapHandler()
|
||||||
case logCommand.FullCommand():
|
case logQueryCommand.FullCommand():
|
||||||
err = logHandler(db, *path, *logNum, *logRate)
|
err = logHandler(db, *path, *logNum, *logRate)
|
||||||
|
case logDumpCommand.FullCommand():
|
||||||
|
err = logDumpHandler(db, *logDumpID)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user