By some CI fine tunes (`run tests`), SQLite & MSSQL could complete
in about 12~13 minutes (before > 14), MySQL could complete in 18 minutes
(before: about 23 or even > 30)
Major changes:
1. use tmpfs for MySQL storage
1. run `make test-mysql` instead of `make integration-test-coverage`
because the code coverage is not really used at the moment.
1. refactor testlogger to make it more reliable and be able to report
stuck stacktrace
1. do not requeue failed items when a queue is being flushed (failed
items would keep failing and make flush uncompleted)
1. reduce the file sizes for testing
1. use math ChaCha20 random data instead of crypot/rand (for testing
purpose only)
1. no need to `DeleteRepository` in `TestLinguist`
1. other related refactoring to make code easier to maintain
log.Debug("Queue %q is shutting down",q.GetName())
return
casedata,dataOk:=<-wg.popItemChan:
if!dataOk{
return
@ -251,9 +262,6 @@ loop:
log.Error("Failed to pop item from queue %q (doFlush): %v",q.GetName(),err)
}
return
case<-q.ctxRun.Done():
log.Debug("Queue %q is shutting down",q.GetName())
return
case<-time.After(20*time.Millisecond):
// There is no reliable way to make sure all queue items are consumed by the Flush, there always might be some items stored in some buffers/temp variables.
// If we run Gitea in a cluster, we can even not guarantee all items are consumed in a deterministic instance.
_,_=fmt.Fprintf(os.Stdout,"+++ %s is a slow test (took %v)\n",fmt.Formatter(log.NewColoredValue(t.Name(),log.Bold,log.FgYellow)),fmt.Formatter(log.NewColoredValue(took,log.Bold,log.FgYellow)))
}else{
_,_=fmt.Fprintf(os.Stdout,"+++ %s is a slow test (took %v)\n",t.Name(),took)
}
}
timer:=time.AfterFunc(SlowFlush,func(){
iflog.CanColorStdout{
_,_=fmt.Fprintf(os.Stdout,"+++ %s ... still flushing after %v ...\n",fmt.Formatter(log.NewColoredValue(t.Name(),log.Bold,log.FgRed)),SlowFlush)
}else{
_,_=fmt.Fprintf(os.Stdout,"+++ %s ... still flushing after %v ...\n",t.Name(),SlowFlush)
t.Errorf("Flushing queues failed with error %v",err)
}
timer.Stop()
flushTook:=time.Since(start)-took
ifflushTook>SlowFlush{
iflog.CanColorStdout{
_,_=fmt.Fprintf(os.Stdout,"+++ %s had a slow clean-up flush (took %v)\n",fmt.Formatter(log.NewColoredValue(t.Name(),log.Bold,log.FgRed)),fmt.Formatter(log.NewColoredValue(flushTook,log.Bold,log.FgRed)))
}else{
_,_=fmt.Fprintf(os.Stdout,"+++ %s had a slow clean-up flush (took %v)\n",t.Name(),flushTook)
}
}
WriterCloser.popT()
}
}
slowFlushChecker.Stop()
timeoutChecker.Stop()
// Printf takes a format and args and prints the string to os.Stdout
funcPrintf(formatstring,args...any){
iflog.CanColorStdout{
fori:=0;i<len(args);i++{
args[i]=log.NewColoredValue(args[i])
runDuration:=time.Since(runStart)
flushDuration:=time.Since(flushStart)
ifrunDuration>TestSlowRun{
Printf("+++ %s is a slow test (run: %v, flush: %v)\n",log.NewColoredValue(t.Name(),log.Bold,log.FgYellow),runDuration,flushDuration)
}
WriterCloser.popT()
}
_,_=fmt.Fprintf(os.Stdout,"\t"+format,args...)
}
// TestLogEventWriter is a logger which will write to the testing log
@ -149,19 +151,36 @@ type TestLogEventWriter struct {
*log.EventWriterBaseImpl
}
// NewTestLoggerWriter creates a TestLogEventWriter as a log.LoggerProvider