2016-12-17 03:39:53 +00:00
|
|
|
package main
|
2017-04-12 10:10:36 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
import (
|
|
|
|
"bytes"
|
2017-11-11 08:46:30 +00:00
|
|
|
"database/sql"
|
2017-09-03 04:50:31 +00:00
|
|
|
"log"
|
2017-06-10 07:58:15 +00:00
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
2019-02-10 05:52:26 +00:00
|
|
|
"runtime/debug"
|
2017-11-11 08:46:30 +00:00
|
|
|
"strconv"
|
|
|
|
"strings"
|
2017-09-03 04:50:31 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
2017-10-14 07:39:22 +00:00
|
|
|
|
2018-08-29 02:55:24 +00:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
c "github.com/Azareal/Gosora/common"
|
2018-10-27 04:16:34 +00:00
|
|
|
"github.com/Azareal/Gosora/install"
|
2018-10-27 03:21:02 +00:00
|
|
|
"github.com/Azareal/Gosora/query_gen"
|
|
|
|
"github.com/Azareal/Gosora/routes"
|
2017-06-10 07:58:15 +00:00
|
|
|
)
|
2017-01-17 07:55:46 +00:00
|
|
|
|
2017-10-14 07:39:22 +00:00
|
|
|
//var dbTest *sql.DB
|
2017-09-03 04:50:31 +00:00
|
|
|
var dbProd *sql.DB
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
var gloinited bool
|
2017-10-16 07:32:58 +00:00
|
|
|
var installAdapter install.InstallAdapter
|
2017-02-28 09:27:28 +00:00
|
|
|
|
2017-10-16 07:32:58 +00:00
|
|
|
func ResetTables() (err error) {
|
|
|
|
err = installAdapter.InitDatabase()
|
|
|
|
if err != nil {
|
2018-08-29 02:55:24 +00:00
|
|
|
return errors.WithStack(err)
|
2017-10-16 07:32:58 +00:00
|
|
|
}
|
2017-07-29 14:04:20 +00:00
|
|
|
|
2017-10-16 07:32:58 +00:00
|
|
|
err = installAdapter.TableDefs()
|
2017-10-14 07:39:22 +00:00
|
|
|
if err != nil {
|
2018-08-29 02:55:24 +00:00
|
|
|
return errors.WithStack(err)
|
2017-10-14 07:39:22 +00:00
|
|
|
}
|
|
|
|
|
2017-10-16 07:32:58 +00:00
|
|
|
err = installAdapter.CreateAdmin()
|
2017-10-14 07:39:22 +00:00
|
|
|
if err != nil {
|
2018-08-29 02:55:24 +00:00
|
|
|
return errors.WithStack(err)
|
2017-10-14 07:39:22 +00:00
|
|
|
}
|
|
|
|
|
2017-10-16 07:32:58 +00:00
|
|
|
return installAdapter.InitialData()
|
|
|
|
}
|
2017-10-14 07:39:22 +00:00
|
|
|
|
2017-10-16 07:32:58 +00:00
|
|
|
func gloinit() (err error) {
|
2018-08-29 02:34:46 +00:00
|
|
|
if gloinited {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2018-06-06 06:13:55 +00:00
|
|
|
// TODO: Make these configurable via flags to the go test command
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = false
|
|
|
|
c.Dev.SuperDebug = false
|
|
|
|
c.Dev.TemplateDebug = false
|
2018-06-06 06:13:55 +00:00
|
|
|
qgen.LogPrepares = false
|
2017-10-16 07:32:58 +00:00
|
|
|
//nogrouplog = true
|
2019-04-19 08:20:10 +00:00
|
|
|
c.StartTime = time.Now()
|
2017-10-14 07:39:22 +00:00
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
err = c.LoadConfig()
|
2018-06-17 08:12:39 +00:00
|
|
|
if err != nil {
|
2018-08-29 02:55:24 +00:00
|
|
|
return errors.WithStack(err)
|
2018-06-17 08:12:39 +00:00
|
|
|
}
|
2019-04-19 08:20:10 +00:00
|
|
|
err = c.ProcessConfig()
|
2017-10-14 07:39:22 +00:00
|
|
|
if err != nil {
|
2018-08-29 02:55:24 +00:00
|
|
|
return errors.WithStack(err)
|
2017-10-14 07:39:22 +00:00
|
|
|
}
|
2018-06-17 08:12:39 +00:00
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
err = c.InitTemplates()
|
2019-02-10 05:52:26 +00:00
|
|
|
if err != nil {
|
|
|
|
return errors.WithStack(err)
|
|
|
|
}
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Themes, err = c.NewThemeList()
|
2017-10-14 07:39:22 +00:00
|
|
|
if err != nil {
|
2018-08-29 02:55:24 +00:00
|
|
|
return errors.WithStack(err)
|
2017-10-14 07:39:22 +00:00
|
|
|
}
|
2019-04-19 08:20:10 +00:00
|
|
|
c.TopicListThaw = c.NewSingleServerThaw()
|
|
|
|
c.SwitchToTestDB()
|
2017-10-16 07:32:58 +00:00
|
|
|
|
|
|
|
var ok bool
|
|
|
|
installAdapter, ok = install.Lookup(dbAdapter)
|
|
|
|
if !ok {
|
2018-08-29 02:55:24 +00:00
|
|
|
return errors.WithStack(errors.New("We couldn't find the adapter '" + dbAdapter + "'"))
|
2017-10-14 07:39:22 +00:00
|
|
|
}
|
2019-04-19 08:20:10 +00:00
|
|
|
installAdapter.SetConfig(c.DbConfig.Host, c.DbConfig.Username, c.DbConfig.Password, c.DbConfig.Dbname, c.DbConfig.Port)
|
2017-10-14 07:39:22 +00:00
|
|
|
|
2017-10-16 07:32:58 +00:00
|
|
|
err = ResetTables()
|
2017-04-12 10:10:36 +00:00
|
|
|
if err != nil {
|
2017-08-27 09:33:45 +00:00
|
|
|
return err
|
2017-04-12 10:10:36 +00:00
|
|
|
}
|
2017-11-11 08:46:30 +00:00
|
|
|
err = InitDatabase()
|
2017-09-03 04:50:31 +00:00
|
|
|
if err != nil {
|
2018-08-29 03:23:02 +00:00
|
|
|
return err
|
2017-09-03 04:50:31 +00:00
|
|
|
}
|
2017-11-23 05:37:08 +00:00
|
|
|
err = afterDBInit()
|
2017-08-27 09:33:45 +00:00
|
|
|
if err != nil {
|
2018-08-29 03:36:17 +00:00
|
|
|
return err
|
2017-08-27 09:33:45 +00:00
|
|
|
}
|
|
|
|
|
2018-04-03 04:34:07 +00:00
|
|
|
router, err = NewGenRouter(http.FileServer(http.Dir("./uploads")))
|
|
|
|
if err != nil {
|
2018-08-29 02:55:24 +00:00
|
|
|
return errors.WithStack(err)
|
2018-04-03 04:34:07 +00:00
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
gloinited = true
|
2017-08-27 09:33:45 +00:00
|
|
|
return nil
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
2016-12-17 03:39:53 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func init() {
|
2017-09-03 04:50:31 +00:00
|
|
|
err := gloinit()
|
2017-01-17 07:55:46 +00:00
|
|
|
if err != nil {
|
2017-10-16 07:32:58 +00:00
|
|
|
log.Print("Something bad happened")
|
2018-08-29 02:55:24 +00:00
|
|
|
//debug.PrintStack()
|
2018-08-29 03:09:01 +00:00
|
|
|
log.Fatalf("%+v\n", err)
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
|
2018-12-31 09:03:49 +00:00
|
|
|
const benchTidI = 1
|
2018-11-17 02:36:02 +00:00
|
|
|
const benchTid = "1"
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Swap out LocalError for a panic for this?
|
2017-01-17 07:55:46 +00:00
|
|
|
func BenchmarkTopicAdminRouteParallel(b *testing.B) {
|
2018-11-01 06:43:56 +00:00
|
|
|
binit(b)
|
2018-11-12 09:23:36 +00:00
|
|
|
cfg := NewStashConfig()
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = false
|
|
|
|
c.Dev.SuperDebug = false
|
2018-02-10 15:07:21 +00:00
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
admin, err := c.Users.Get(1)
|
2018-02-10 15:07:21 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
if !admin.IsAdmin {
|
|
|
|
b.Fatal("UID1 is not an admin")
|
|
|
|
}
|
2019-04-19 08:20:10 +00:00
|
|
|
adminUIDCookie := http.Cookie{Name: "uid", Value: "1", Path: "/", MaxAge: c.Year}
|
|
|
|
adminSessionCookie := http.Cookie{Name: "session", Value: admin.Session, Path: "/", MaxAge: c.Year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2018-02-10 15:07:21 +00:00
|
|
|
for pb.Next() {
|
2018-11-12 09:23:36 +00:00
|
|
|
w := httptest.NewRecorder()
|
2018-11-17 02:36:02 +00:00
|
|
|
reqAdmin := httptest.NewRequest("get", "/topic/hm."+benchTid, bytes.NewReader(nil))
|
2018-11-12 09:23:36 +00:00
|
|
|
reqAdmin.AddCookie(&adminUIDCookie)
|
|
|
|
reqAdmin.AddCookie(&adminSessionCookie)
|
2018-02-10 15:07:21 +00:00
|
|
|
|
|
|
|
// Deal with the session stuff, etc.
|
2019-04-19 08:20:10 +00:00
|
|
|
user, ok := c.PreRoute(w, reqAdmin)
|
2018-02-10 15:07:21 +00:00
|
|
|
if !ok {
|
|
|
|
b.Fatal("Mysterious error!")
|
|
|
|
}
|
2019-04-19 08:20:10 +00:00
|
|
|
head, err := c.UserCheck(w, reqAdmin, &user)
|
2018-11-12 09:23:36 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
//w.Body.Reset()
|
|
|
|
routes.ViewTopic(w, reqAdmin, user, head, "1")
|
|
|
|
if w.Code != 200 {
|
|
|
|
b.Log(w.Body)
|
2018-02-10 15:07:21 +00:00
|
|
|
b.Fatal("HTTP Error!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-11-12 09:23:36 +00:00
|
|
|
cfg.Restore()
|
2018-02-10 15:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTopicAdminRouteParallelWithRouter(b *testing.B) {
|
2018-11-01 06:43:56 +00:00
|
|
|
binit(b)
|
|
|
|
router, err := NewGenRouter(http.FileServer(http.Dir("./uploads")))
|
2018-04-03 04:34:07 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
2018-11-12 09:23:36 +00:00
|
|
|
cfg := NewStashConfig()
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = false
|
|
|
|
c.Dev.SuperDebug = false
|
2018-02-10 15:07:21 +00:00
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
admin, err := c.Users.Get(1)
|
2018-02-10 15:07:21 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
if !admin.IsAdmin {
|
|
|
|
b.Fatal("UID1 is not an admin")
|
|
|
|
}
|
2019-04-19 08:20:10 +00:00
|
|
|
uidCookie := http.Cookie{Name: "uid", Value: "1", Path: "/", MaxAge: c.Year}
|
|
|
|
sessionCookie := http.Cookie{Name: "session", Value: admin.Session, Path: "/", MaxAge: c.Year}
|
2018-12-31 09:03:49 +00:00
|
|
|
path := "/topic/hm." + benchTid
|
2018-02-10 15:07:21 +00:00
|
|
|
|
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
for pb.Next() {
|
2018-11-12 09:23:36 +00:00
|
|
|
w := httptest.NewRecorder()
|
2018-12-17 04:58:55 +00:00
|
|
|
reqAdmin := httptest.NewRequest("get", path, bytes.NewReader(nil))
|
2018-11-12 09:23:36 +00:00
|
|
|
reqAdmin.AddCookie(&uidCookie)
|
|
|
|
reqAdmin.AddCookie(&sessionCookie)
|
|
|
|
reqAdmin.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36")
|
|
|
|
reqAdmin.Header.Set("Host", "localhost")
|
|
|
|
reqAdmin.Host = "localhost"
|
|
|
|
//w.Body.Reset()
|
|
|
|
router.ServeHTTP(w, reqAdmin)
|
|
|
|
if w.Code != 200 {
|
|
|
|
b.Log(w.Body)
|
2018-02-10 15:07:21 +00:00
|
|
|
b.Fatal("HTTP Error!")
|
|
|
|
}
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
2018-02-10 15:07:21 +00:00
|
|
|
})
|
|
|
|
|
2018-11-12 09:23:36 +00:00
|
|
|
cfg.Restore()
|
2018-02-10 15:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTopicAdminRouteParallelAlt(b *testing.B) {
|
|
|
|
BenchmarkTopicAdminRouteParallel(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTopicAdminRouteParallelWithRouterAlt(b *testing.B) {
|
|
|
|
BenchmarkTopicAdminRouteParallelWithRouter(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTopicAdminRouteParallelAltAlt(b *testing.B) {
|
|
|
|
BenchmarkTopicAdminRouteParallel(b)
|
|
|
|
}
|
|
|
|
|
2018-12-17 04:58:55 +00:00
|
|
|
func BenchmarkTopicGuestAdminRouteParallelWithRouter(b *testing.B) {
|
|
|
|
binit(b)
|
|
|
|
router, err := NewGenRouter(http.FileServer(http.Dir("./uploads")))
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
cfg := NewStashConfig()
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = false
|
|
|
|
c.Dev.SuperDebug = false
|
2018-12-17 04:58:55 +00:00
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
admin, err := c.Users.Get(1)
|
2018-12-17 04:58:55 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
if !admin.IsAdmin {
|
|
|
|
b.Fatal("UID1 is not an admin")
|
|
|
|
}
|
2019-04-19 08:20:10 +00:00
|
|
|
uidCookie := http.Cookie{Name: "uid", Value: "1", Path: "/", MaxAge: c.Year}
|
|
|
|
sessionCookie := http.Cookie{Name: "session", Value: admin.Session, Path: "/", MaxAge: c.Year}
|
2018-12-31 09:03:49 +00:00
|
|
|
path := "/topic/hm." + benchTid
|
|
|
|
|
2018-12-17 04:58:55 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
for pb.Next() {
|
|
|
|
w := httptest.NewRecorder()
|
|
|
|
reqAdmin := httptest.NewRequest("get", path, bytes.NewReader(nil))
|
|
|
|
reqAdmin.AddCookie(&uidCookie)
|
|
|
|
reqAdmin.AddCookie(&sessionCookie)
|
|
|
|
reqAdmin.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36")
|
|
|
|
reqAdmin.Header.Set("Host", "localhost")
|
|
|
|
reqAdmin.Host = "localhost"
|
|
|
|
router.ServeHTTP(w, reqAdmin)
|
|
|
|
if w.Code != 200 {
|
|
|
|
b.Log(w.Body)
|
|
|
|
b.Fatal("HTTP Error!")
|
|
|
|
}
|
|
|
|
|
2018-12-31 09:03:49 +00:00
|
|
|
{
|
|
|
|
w := httptest.NewRecorder()
|
|
|
|
req := httptest.NewRequest("GET", path, bytes.NewReader(nil))
|
|
|
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36")
|
|
|
|
req.Header.Set("Host", "localhost")
|
|
|
|
req.Host = "localhost"
|
|
|
|
router.ServeHTTP(w, req)
|
|
|
|
if w.Code != 200 {
|
|
|
|
b.Log(w.Body)
|
|
|
|
b.Fatal("HTTP Error!")
|
|
|
|
}
|
2018-12-17 04:58:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
cfg.Restore()
|
|
|
|
}
|
|
|
|
|
2018-02-10 15:07:21 +00:00
|
|
|
func BenchmarkTopicGuestRouteParallel(b *testing.B) {
|
2018-11-01 06:43:56 +00:00
|
|
|
binit(b)
|
2018-11-12 09:23:36 +00:00
|
|
|
cfg := NewStashConfig()
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = false
|
|
|
|
c.Dev.SuperDebug = false
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2018-02-10 15:07:21 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2017-01-17 07:55:46 +00:00
|
|
|
for pb.Next() {
|
2018-11-12 09:23:36 +00:00
|
|
|
w := httptest.NewRecorder()
|
2018-11-17 02:36:02 +00:00
|
|
|
req := httptest.NewRequest("get", "/topic/hm."+benchTid, bytes.NewReader(nil))
|
2019-04-19 08:20:10 +00:00
|
|
|
user := c.GuestUser
|
2018-11-12 09:23:36 +00:00
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
head, err := c.UserCheck(w, req, &user)
|
2018-11-12 09:23:36 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
//w.Body.Reset()
|
|
|
|
routes.ViewTopic(w, req, user, head, "1")
|
|
|
|
if w.Code != 200 {
|
|
|
|
b.Log(w.Body)
|
2018-02-10 15:07:21 +00:00
|
|
|
b.Fatal("HTTP Error!")
|
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
|
|
|
})
|
2018-11-12 09:23:36 +00:00
|
|
|
cfg.Restore()
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
|
|
|
|
2018-02-10 15:07:21 +00:00
|
|
|
func BenchmarkTopicGuestRouteParallelDebugMode(b *testing.B) {
|
2018-11-01 06:43:56 +00:00
|
|
|
binit(b)
|
2018-11-12 09:23:36 +00:00
|
|
|
cfg := NewStashConfig()
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = true
|
|
|
|
c.Dev.SuperDebug = false
|
2018-02-10 15:07:21 +00:00
|
|
|
|
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
for pb.Next() {
|
2018-11-12 09:23:36 +00:00
|
|
|
w := httptest.NewRecorder()
|
2018-11-17 02:36:02 +00:00
|
|
|
req := httptest.NewRequest("get", "/topic/hm."+benchTid, bytes.NewReader(nil))
|
2019-04-19 08:20:10 +00:00
|
|
|
user := c.GuestUser
|
2018-11-12 09:23:36 +00:00
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
head, err := c.UserCheck(w, req, &user)
|
2018-11-12 09:23:36 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
//w.Body.Reset()
|
|
|
|
routes.ViewTopic(w, req, user, head, "1")
|
|
|
|
if w.Code != 200 {
|
|
|
|
b.Log(w.Body)
|
2018-02-10 15:07:21 +00:00
|
|
|
b.Fatal("HTTP Error!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2018-11-12 09:23:36 +00:00
|
|
|
cfg.Restore()
|
2018-02-10 15:07:21 +00:00
|
|
|
}
|
|
|
|
|
2018-11-12 09:23:36 +00:00
|
|
|
func obRoute(b *testing.B, path string) {
|
2018-11-01 06:43:56 +00:00
|
|
|
binit(b)
|
|
|
|
cfg := NewStashConfig()
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = false
|
|
|
|
c.Dev.SuperDebug = false
|
2018-11-12 09:23:36 +00:00
|
|
|
b.RunParallel(benchRoute(b, path))
|
2018-11-01 06:43:56 +00:00
|
|
|
cfg.Restore()
|
|
|
|
}
|
2018-02-10 15:07:21 +00:00
|
|
|
|
2018-12-17 04:58:55 +00:00
|
|
|
func obRouteNoError(b *testing.B, path string) {
|
|
|
|
binit(b)
|
|
|
|
cfg := NewStashConfig()
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = false
|
|
|
|
c.Dev.SuperDebug = false
|
2018-12-17 04:58:55 +00:00
|
|
|
b.RunParallel(benchRouteNoError(b, path))
|
|
|
|
cfg.Restore()
|
|
|
|
}
|
|
|
|
|
2018-11-01 06:43:56 +00:00
|
|
|
func BenchmarkTopicsGuestRouteParallelWithRouter(b *testing.B) {
|
2018-11-12 09:23:36 +00:00
|
|
|
obRoute(b, "/topics/")
|
2018-02-10 15:07:21 +00:00
|
|
|
}
|
|
|
|
|
2019-02-10 05:52:26 +00:00
|
|
|
func BenchmarkTopicsGuestJSRouteParallelWithRouter(b *testing.B) {
|
|
|
|
obRoute(b, "/topics/?js=1")
|
|
|
|
}
|
|
|
|
|
2018-02-10 15:07:21 +00:00
|
|
|
func BenchmarkForumsGuestRouteParallelWithRouter(b *testing.B) {
|
2018-11-12 09:23:36 +00:00
|
|
|
obRoute(b, "/forums/")
|
2018-11-01 06:43:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkForumGuestRouteParallelWithRouter(b *testing.B) {
|
2018-11-12 09:23:36 +00:00
|
|
|
obRoute(b, "/forum/general.2")
|
2018-11-01 06:43:56 +00:00
|
|
|
}
|
|
|
|
|
2018-11-17 02:36:02 +00:00
|
|
|
func BenchmarkTopicGuestRouteParallelWithRouter(b *testing.B) {
|
|
|
|
obRoute(b, "/topic/hm."+benchTid)
|
|
|
|
}
|
|
|
|
|
2018-12-15 04:39:50 +00:00
|
|
|
func BenchmarkTopicGuestRouteParallelWithRouterAlt(b *testing.B) {
|
|
|
|
obRoute(b, "/topic/hm."+benchTid)
|
|
|
|
}
|
|
|
|
|
2018-12-17 04:58:55 +00:00
|
|
|
func BenchmarkBadRouteGuestRouteParallelWithRouter(b *testing.B) {
|
|
|
|
obRouteNoError(b, "/garble/haa")
|
|
|
|
}
|
2018-11-17 02:36:02 +00:00
|
|
|
|
2018-12-15 04:39:50 +00:00
|
|
|
// TODO: Alternate between member and guest to bust some CPU caches?
|
|
|
|
|
2018-11-01 06:43:56 +00:00
|
|
|
func binit(b *testing.B) {
|
2018-02-10 15:07:21 +00:00
|
|
|
b.ReportAllocs()
|
2018-08-29 02:34:46 +00:00
|
|
|
err := gloinit()
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
2018-02-10 15:07:21 +00:00
|
|
|
}
|
2018-11-01 06:43:56 +00:00
|
|
|
}
|
2018-08-29 02:34:46 +00:00
|
|
|
|
2018-11-01 06:43:56 +00:00
|
|
|
type StashConfig struct {
|
2018-11-12 09:23:36 +00:00
|
|
|
prev bool
|
2018-11-01 06:43:56 +00:00
|
|
|
prev2 bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewStashConfig() *StashConfig {
|
2019-04-19 08:20:10 +00:00
|
|
|
prev := c.Dev.DebugMode
|
|
|
|
prev2 := c.Dev.SuperDebug
|
2018-11-12 09:23:36 +00:00
|
|
|
return &StashConfig{prev, prev2}
|
2018-02-10 15:07:21 +00:00
|
|
|
}
|
|
|
|
|
2018-11-01 06:43:56 +00:00
|
|
|
func (cfg *StashConfig) Restore() {
|
2019-04-19 08:20:10 +00:00
|
|
|
c.Dev.DebugMode = cfg.prev
|
|
|
|
c.Dev.SuperDebug = cfg.prev2
|
2018-11-01 06:43:56 +00:00
|
|
|
}
|
2018-08-29 02:34:46 +00:00
|
|
|
|
2018-11-01 06:43:56 +00:00
|
|
|
func benchRoute(b *testing.B, path string) func(*testing.PB) {
|
|
|
|
router, err := NewGenRouter(http.FileServer(http.Dir("./uploads")))
|
2018-04-03 04:34:07 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
2018-11-01 06:43:56 +00:00
|
|
|
return func(pb *testing.PB) {
|
2018-02-10 15:07:21 +00:00
|
|
|
for pb.Next() {
|
2018-12-17 04:58:55 +00:00
|
|
|
w := httptest.NewRecorder()
|
|
|
|
req := httptest.NewRequest("GET", path, bytes.NewReader(nil))
|
|
|
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36")
|
|
|
|
req.Header.Set("Host", "localhost")
|
|
|
|
req.Host = "localhost"
|
|
|
|
router.ServeHTTP(w, req)
|
|
|
|
if w.Code != 200 {
|
|
|
|
b.Log(w.Body)
|
2018-02-10 15:07:21 +00:00
|
|
|
b.Fatal("HTTP Error!")
|
|
|
|
}
|
|
|
|
}
|
2018-11-01 06:43:56 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-10 15:07:21 +00:00
|
|
|
|
2018-12-17 04:58:55 +00:00
|
|
|
func benchRouteNoError(b *testing.B, path string) func(*testing.PB) {
|
|
|
|
router, err := NewGenRouter(http.FileServer(http.Dir("./uploads")))
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
return func(pb *testing.PB) {
|
|
|
|
for pb.Next() {
|
|
|
|
w := httptest.NewRecorder()
|
|
|
|
req := httptest.NewRequest("GET", path, bytes.NewReader(nil))
|
|
|
|
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36")
|
|
|
|
req.Header.Set("Host", "localhost")
|
|
|
|
req.Host = "localhost"
|
|
|
|
router.ServeHTTP(w, req)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-01 06:43:56 +00:00
|
|
|
func BenchmarkProfileGuestRouteParallelWithRouter(b *testing.B) {
|
2018-11-12 09:23:36 +00:00
|
|
|
obRoute(b, "/profile/admin.1")
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-31 09:03:49 +00:00
|
|
|
func BenchmarkPopulateTopicWithRouter(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2019-04-19 08:20:10 +00:00
|
|
|
topic, err := c.Topics.Get(benchTidI)
|
2018-12-31 09:03:49 +00:00
|
|
|
if err != nil {
|
|
|
|
debug.PrintStack()
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
for pb.Next() {
|
|
|
|
for i := 0; i < 25; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_, err := c.Rstore.Create(topic, "hiii", "::1", 1)
|
2018-12-31 09:03:49 +00:00
|
|
|
if err != nil {
|
|
|
|
debug.PrintStack()
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
//var fullPage = false
|
|
|
|
|
|
|
|
func BenchmarkTopicAdminFullPageRouteParallelWithRouter(b *testing.B) {
|
|
|
|
/*if !fullPage {
|
2019-04-19 08:20:10 +00:00
|
|
|
topic, err := c.Topics.Get(benchTidI)
|
2018-12-31 09:03:49 +00:00
|
|
|
panicIfErr(err)
|
|
|
|
for i := 0; i < 25; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_, err = c.Rstore.Create(topic, "hiii", "::1", 1)
|
2018-12-31 09:03:49 +00:00
|
|
|
panicIfErr(err)
|
|
|
|
}
|
|
|
|
fullPage = true
|
|
|
|
}*/
|
|
|
|
BenchmarkTopicAdminRouteParallel(b)
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkTopicGuestFullPageRouteParallelWithRouter(b *testing.B) {
|
|
|
|
/*if !fullPage {
|
2019-04-19 08:20:10 +00:00
|
|
|
topic, err := c.Topics.Get(benchTidI)
|
2018-12-31 09:03:49 +00:00
|
|
|
panicIfErr(err)
|
|
|
|
for i := 0; i < 25; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_, err = c.Rstore.Create(topic, "hiii", "::1", 1)
|
2018-12-31 09:03:49 +00:00
|
|
|
panicIfErr(err)
|
|
|
|
}
|
|
|
|
fullPage = true
|
|
|
|
}*/
|
|
|
|
obRoute(b, "/topic/hm."+benchTid)
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Make these routes compatible with the changes to the router
|
2017-08-06 15:22:18 +00:00
|
|
|
/*
|
2017-01-17 07:55:46 +00:00
|
|
|
func BenchmarkForumsAdminRouteParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2017-09-15 22:20:01 +00:00
|
|
|
admin, err := users.Get(1)
|
2017-02-15 10:49:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
2018-02-10 15:07:21 +00:00
|
|
|
adminUidCookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
adminSessionCookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2018-02-10 15:07:21 +00:00
|
|
|
forumsW := httptest.NewRecorder()
|
|
|
|
forumsReq := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
2018-11-01 06:43:56 +00:00
|
|
|
forumsReqAdmin := forums_req
|
|
|
|
forumsReqAdmin.AddCookie(&adminUidCookie)
|
|
|
|
forumsReqAdmin.AddCookie(&adminSessionCookie)
|
2018-02-10 15:07:21 +00:00
|
|
|
forumsHandler := http.HandlerFunc(route_forums)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
for pb.Next() {
|
2018-02-10 15:07:21 +00:00
|
|
|
forumsW.Body.Reset()
|
|
|
|
forumsHandler.ServeHTTP(forumsW,forumsReqAdmin)
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkForumsAdminRouteParallelProf(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2017-09-15 22:20:01 +00:00
|
|
|
admin, err := users.Get(1)
|
2017-02-15 10:49:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
2018-02-10 15:07:21 +00:00
|
|
|
adminUidCookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
adminSessionCookie := http.Cookie{Name:"session",Value: admin.Session,Path: "/",MaxAge: year}
|
|
|
|
|
|
|
|
forumsW := httptest.NewRecorder()
|
|
|
|
forumsReq := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forumsReqAdmin := forumsReq
|
|
|
|
forumsReqAdmin.AddCookie(&admin_uid_cookie)
|
|
|
|
forumsReqAdmin.AddCookie(&admin_session_cookie)
|
|
|
|
forumsHandler := http.HandlerFunc(route_forums)
|
2017-01-17 07:55:46 +00:00
|
|
|
f, err := os.Create("cpu_forums_admin_parallel.prof")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
pprof.StartCPUProfile(f)
|
|
|
|
for pb.Next() {
|
2018-02-10 15:07:21 +00:00
|
|
|
forumsW.Body.Reset()
|
|
|
|
forumsHandler.ServeHTTP(forumsW,forumsReqAdmin)
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
|
|
|
pprof.StopCPUProfile()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2018-02-10 15:07:21 +00:00
|
|
|
func BenchmarkRoutesSerial(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
b.ReportAllocs()
|
2017-09-15 22:20:01 +00:00
|
|
|
admin, err := users.Get(1)
|
2017-02-15 10:49:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path: "/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
if plugins_inited {
|
|
|
|
b.Log("Plugins have already been initialised, they can't be deinitialised so these tests will run with plugins on")
|
|
|
|
}
|
|
|
|
static_w := httptest.NewRecorder()
|
2019-08-14 10:39:04 +00:00
|
|
|
static_req := httptest.NewRequest("get","/s/global.js",bytes.NewReader(nil))
|
2017-01-17 07:55:46 +00:00
|
|
|
static_handler := http.HandlerFunc(route_static)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
topic_w := httptest.NewRecorder()
|
|
|
|
topic_req := httptest.NewRequest("get","/topic/1",bytes.NewReader(nil))
|
|
|
|
topic_req_admin := topic_req
|
|
|
|
topic_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
topic_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
topic_handler := http.HandlerFunc(route_topic_id)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
topics_w := httptest.NewRecorder()
|
|
|
|
topics_req := httptest.NewRequest("get","/topics/",bytes.NewReader(nil))
|
|
|
|
topics_req_admin := topics_req
|
|
|
|
topics_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
topics_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
topics_handler := http.HandlerFunc(route_topics)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
forum_w := httptest.NewRecorder()
|
|
|
|
forum_req := httptest.NewRequest("get","/forum/1",bytes.NewReader(nil))
|
|
|
|
forum_req_admin := forum_req
|
|
|
|
forum_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forum_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forum_handler := http.HandlerFunc(route_forum)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2016-12-23 12:35:22 +00:00
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_req_admin := forums_req
|
|
|
|
forums_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forums_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_cpu.prof")
|
|
|
|
//if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
|
|
|
///defer pprof.StopCPUProfile()
|
|
|
|
///pprof.StopCPUProfile()
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("static_recorder", func(b *testing.B) {
|
2017-01-01 15:45:43 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2017-02-15 10:49:30 +00:00
|
|
|
//static_w.Code = 200
|
2017-01-01 15:45:43 +00:00
|
|
|
static_w.Body.Reset()
|
|
|
|
static_handler.ServeHTTP(static_w,static_req)
|
2017-02-15 10:49:30 +00:00
|
|
|
//if static_w.Code != 200 {
|
2017-08-13 11:22:34 +00:00
|
|
|
// b.Print(static_w.Body)
|
|
|
|
// b.Fatal("HTTP Error!")
|
2017-02-15 10:49:30 +00:00
|
|
|
//}
|
2016-12-23 12:35:22 +00:00
|
|
|
}
|
2017-01-01 15:45:43 +00:00
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic_admin_recorder", func(b *testing.B) {
|
|
|
|
//f, err := os.Create("routes_bench_topic_cpu.prof")
|
|
|
|
//if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
// b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
//topic_w.Code = 200
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req_admin)
|
|
|
|
//if topic_w.Code != 200 {
|
2017-08-13 11:22:34 +00:00
|
|
|
// b.Print(topic_w.Body)
|
|
|
|
// b.Fatal("HTTP Error!")
|
2016-12-23 12:35:22 +00:00
|
|
|
//}
|
2016-12-17 03:39:53 +00:00
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
//pprof.StopCPUProfile()
|
2016-12-17 03:39:53 +00:00
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic_guest_recorder", func(b *testing.B) {
|
|
|
|
f, err := os.Create("routes_bench_topic_cpu_2.prof")
|
|
|
|
if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
|
|
|
pprof.StartCPUProfile(f)
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
//topic_w.Code = 200
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req)
|
2016-12-17 03:39:53 +00:00
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
pprof.StopCPUProfile()
|
2016-12-17 03:39:53 +00:00
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topics_admin_recorder", func(b *testing.B) {
|
2016-12-17 03:39:53 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
//topics_w.Code = 200
|
|
|
|
topics_w.Body.Reset()
|
|
|
|
topics_handler.ServeHTTP(topics_w,topics_req_admin)
|
2016-12-21 02:30:32 +00:00
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topics_guest_recorder", func(b *testing.B) {
|
2016-12-21 02:30:32 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
2016-12-23 12:35:22 +00:00
|
|
|
//topics_w.Code = 200
|
|
|
|
topics_w.Body.Reset()
|
|
|
|
topics_handler.ServeHTTP(topics_w,topics_req)
|
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("forum_admin_recorder", func(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forum_w.Code = 200
|
|
|
|
forum_w.Body.Reset()
|
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req_admin)
|
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("forum_guest_recorder", func(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forum_w.Code = 200
|
|
|
|
forum_w.Body.Reset()
|
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req)
|
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("forums_admin_recorder", func(b *testing.B) {
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forums_w.Code = 200
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req_admin)
|
|
|
|
}
|
|
|
|
})
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("forums_guest_recorder", func(b *testing.B) {
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_forums_cpu_2.prof")
|
|
|
|
//if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
// b.Fatal(err)
|
2017-06-10 07:58:15 +00:00
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2016-12-23 12:35:22 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forums_w.Code = 200
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req)
|
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
//pprof.StopCPUProfile()
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic_admin_recorder_with_plugins", func(b *testing.B) {
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_topic_cpu.prof")
|
|
|
|
//if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
// b.Fatal(err)
|
2017-06-10 07:58:15 +00:00
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2017-01-17 07:55:46 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//topic_w.Code = 200
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req_admin)
|
|
|
|
//if topic_w.Code != 200 {
|
2017-08-13 11:22:34 +00:00
|
|
|
// b.Print(topic_w.Body)
|
|
|
|
// b.Fatal("HTTP Error!")
|
2017-01-17 07:55:46 +00:00
|
|
|
//}
|
|
|
|
}
|
|
|
|
//pprof.StopCPUProfile()
|
|
|
|
})
|
|
|
|
b.Run("topic_guest_recorder_with_plugins", func(b *testing.B) {
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_topic_cpu_2.prof")
|
|
|
|
//if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
// b.Fatal(err)
|
2017-06-10 07:58:15 +00:00
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2017-01-17 07:55:46 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//topic_w.Code = 200
|
|
|
|
topic_w.Body.Reset()
|
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req)
|
|
|
|
}
|
|
|
|
//pprof.StopCPUProfile()
|
|
|
|
})
|
|
|
|
b.Run("topics_admin_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//topics_w.Code = 200
|
|
|
|
topics_w.Body.Reset()
|
|
|
|
topics_handler.ServeHTTP(topics_w,topics_req_admin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("topics_guest_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//topics_w.Code = 200
|
|
|
|
topics_w.Body.Reset()
|
|
|
|
topics_handler.ServeHTTP(topics_w,topics_req)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("forum_admin_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forum_w.Code = 200
|
|
|
|
forum_w.Body.Reset()
|
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req_admin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("forum_guest_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forum_w.Code = 200
|
|
|
|
forum_w.Body.Reset()
|
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("forums_admin_recorder_with_plugins", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forums_w.Code = 200
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req_admin)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("forums_guest_recorder_with_plugins", func(b *testing.B) {
|
2017-06-10 07:58:15 +00:00
|
|
|
//f, err := os.Create("routes_bench_forums_cpu_2.prof")
|
|
|
|
//if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
// b.Fatal(err)
|
2017-06-10 07:58:15 +00:00
|
|
|
//}
|
|
|
|
//pprof.StartCPUProfile(f)
|
2017-01-17 07:55:46 +00:00
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
//forums_w.Code = 200
|
|
|
|
forums_w.Body.Reset()
|
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req)
|
|
|
|
}
|
|
|
|
//pprof.StopCPUProfile()
|
|
|
|
})
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-01-17 07:55:46 +00:00
|
|
|
|
|
|
|
func BenchmarkQueryTopicParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2018-08-29 02:34:46 +00:00
|
|
|
err := gloinit()
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2019-04-19 08:20:10 +00:00
|
|
|
var tu c.TopicUser
|
2017-01-17 07:55:46 +00:00
|
|
|
for pb.Next() {
|
2018-08-30 10:31:21 +00:00
|
|
|
err := db.QueryRow("select topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.views, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level from topics left join users ON topics.createdBy = users.uid where tid = ?", 1).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.IsClosed, &tu.Sticky, &tu.ParentID, &tu.IPAddress, &tu.ViewCount, &tu.PostCount, &tu.LikeCount, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
|
2017-06-28 12:05:26 +00:00
|
|
|
if err == ErrNoRows {
|
2017-01-17 07:55:46 +00:00
|
|
|
log.Fatal("No rows found!")
|
|
|
|
return
|
|
|
|
} else if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkQueryPreparedTopicParallel(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2018-08-29 02:34:46 +00:00
|
|
|
err := gloinit()
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
2019-04-19 08:20:10 +00:00
|
|
|
var tu c.TopicUser
|
2017-11-11 08:46:30 +00:00
|
|
|
|
|
|
|
getTopicUser, err := qgen.Builder.SimpleLeftJoin("topics", "users", "topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level", "topics.createdBy = users.uid", "tid = ?", "", "")
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
}
|
2017-11-11 23:34:27 +00:00
|
|
|
defer getTopicUser.Close()
|
2017-11-11 08:46:30 +00:00
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
for pb.Next() {
|
2017-11-11 08:46:30 +00:00
|
|
|
err := getTopicUser.QueryRow(1).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.IsClosed, &tu.Sticky, &tu.ParentID, &tu.IPAddress, &tu.PostCount, &tu.LikeCount, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
|
2017-06-28 12:05:26 +00:00
|
|
|
if err == ErrNoRows {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal("No rows found!")
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
} else if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-10-30 09:57:08 +00:00
|
|
|
func BenchmarkUserGet(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2018-08-29 02:34:46 +00:00
|
|
|
err := gloinit()
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
2017-10-30 09:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
var err error
|
|
|
|
for pb.Next() {
|
2019-04-19 08:20:10 +00:00
|
|
|
_, err = c.Users.Get(1)
|
2017-10-30 09:57:08 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func BenchmarkUserBypassGet(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2018-08-29 02:34:46 +00:00
|
|
|
err := gloinit()
|
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
2017-10-30 09:57:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bypass the cache and always hit the database
|
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
var err error
|
|
|
|
for pb.Next() {
|
2019-04-19 08:20:10 +00:00
|
|
|
_, err = c.Users.BypassGet(1)
|
2017-10-30 09:57:08 +00:00
|
|
|
if err != nil {
|
|
|
|
b.Fatal(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
func BenchmarkQueriesSerial(b *testing.B) {
|
|
|
|
b.ReportAllocs()
|
2019-04-19 08:20:10 +00:00
|
|
|
var tu c.TopicUser
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
err := db.QueryRow("select topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level from topics left join users ON topics.createdBy = users.uid where tid = ?", 1).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.IsClosed, &tu.Sticky, &tu.ParentID, &tu.IPAddress, &tu.PostCount, &tu.LikeCount, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
|
2017-06-28 12:05:26 +00:00
|
|
|
if err == ErrNoRows {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal("No rows found!")
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
} else if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("topic_replies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
rows, err := db.Query("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.is_super_admin, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress from replies left join users ON replies.createdBy = users.uid where tid = ?", 1)
|
|
|
|
if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
}
|
2017-08-13 11:22:34 +00:00
|
|
|
defer rows.Close()
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
for rows.Next() {
|
|
|
|
}
|
2017-01-17 07:55:46 +00:00
|
|
|
err = rows.Err()
|
|
|
|
if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2019-04-19 08:20:10 +00:00
|
|
|
var replyItem c.ReplyUser
|
2017-09-03 04:50:31 +00:00
|
|
|
var isSuperAdmin bool
|
2017-02-15 10:49:30 +00:00
|
|
|
var group int
|
2017-01-17 07:55:46 +00:00
|
|
|
b.Run("topic_replies_scan", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
rows, err := db.Query("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.is_super_admin, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress from replies left join users ON replies.createdBy = users.uid where tid = ?", 1)
|
|
|
|
if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
for rows.Next() {
|
2017-09-03 04:50:31 +00:00
|
|
|
err := rows.Scan(&replyItem.ID, &replyItem.Content, &replyItem.CreatedBy, &replyItem.CreatedAt, &replyItem.LastEdit, &replyItem.LastEditBy, &replyItem.Avatar, &replyItem.CreatedByName, &isSuperAdmin, &group, &replyItem.URLPrefix, &replyItem.URLName, &replyItem.Level, &replyItem.IPAddress)
|
2017-01-17 07:55:46 +00:00
|
|
|
if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2017-08-13 11:22:34 +00:00
|
|
|
defer rows.Close()
|
|
|
|
|
2017-01-17 07:55:46 +00:00
|
|
|
err = rows.Err()
|
|
|
|
if err != nil {
|
2017-08-13 11:22:34 +00:00
|
|
|
b.Fatal(err)
|
2017-01-17 07:55:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2016-12-23 12:35:22 +00:00
|
|
|
})
|
2016-12-24 13:14:40 +00:00
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
// TODO: Take the attachment system into account in these parser benches
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkParserSerial(b *testing.B) {
|
2017-01-05 14:41:14 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.Run("empty_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_ = c.ParseMessage("", 0, "")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("short_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_ = c.ParseMessage("Hey everyone, how's it going?", 0, "")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_smily", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_ = c.ParseMessage("Hey everyone, how's it going? :)", 0, "")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_ = c.ParseMessage("Hey everyone, how's it going? :):):):):)", 0, "")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_ = c.ParseMessage("Hey everyone, how's it going? :):):):):):):):):):)", 0, "")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("twenty_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2019-04-19 08:20:10 +00:00
|
|
|
_ = c.ParseMessage("Hey everyone, how's it going? :):):):):):):):):):):):):):):):):):):):)", 0, "")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkBBCodePluginWithRegexpSerial(b *testing.B) {
|
2017-01-05 14:41:14 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.Run("empty_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("short_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("Hey everyone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_smily", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("Hey everyone, how's it going? :)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("Hey everyone, how's it going? :):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("Hey everyone, how's it going? :):):):):):):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("twenty_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("Hey everyone, how's it going? :):):):):):):):):):):):):):):):):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("[b]H[/b]ey everyone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b]eryone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeRegexParse("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b][b]e[/b][b]r[/b][b]y[/b][b]o[/b][b]n[/b]e, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkBBCodePluginWithoutCodeTagSerial(b *testing.B) {
|
2017-01-05 14:41:14 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.Run("empty_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("short_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("Hey everyone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_smily", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("Hey everyone, how's it going? :)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("Hey everyone, how's it going? :):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("Hey everyone, how's it going? :):):):):):):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("twenty_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("Hey everyone, how's it going? :):):):):):):):):):):):):):):):):):):):)")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("[b]H[/b]ey everyone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b]eryone, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeParseWithoutCode("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b][b]e[/b][b]r[/b][b]y[/b][b]o[/b][b]n[/b]e, how's it going?")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
func BenchmarkBBCodePluginWithFullParserSerial(b *testing.B) {
|
2017-01-07 06:31:04 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.Run("empty_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("short_post", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("Hey everyone, how's it going?")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_smily", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("Hey everyone, how's it going? :)")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("Hey everyone, how's it going? :):):):):)")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("Hey everyone, how's it going? :):):):):):):):):):)")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("twenty_smilies", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("Hey everyone, how's it going? :):):):):):):):):):):):):):):):):):):):)")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("one_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("[b]H[/b]ey everyone, how's it going?")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("five_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b]eryone, how's it going?")
|
2017-01-07 06:31:04 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
b.Run("ten_bold", func(b *testing.B) {
|
|
|
|
for i := 0; i < b.N; i++ {
|
2017-09-03 04:50:31 +00:00
|
|
|
_ = bbcodeFullParse("[b]H[/b][b]e[/b][b]y[/b] [b]e[/b][b]v[/b][b]e[/b][b]r[/b][b]y[/b][b]o[/b][b]n[/b]e, how's it going?")
|
2017-01-05 14:41:14 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-01-12 02:55:08 +00:00
|
|
|
func TestLevels(t *testing.T) {
|
2019-04-19 08:20:10 +00:00
|
|
|
levels := c.GetLevels(40)
|
2017-01-12 02:55:08 +00:00
|
|
|
for level, score := range levels {
|
|
|
|
sscore := strconv.FormatFloat(score, 'f', -1, 64)
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Level: " + strconv.Itoa(level) + " Score: " + sscore)
|
2017-01-12 02:55:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Make this compatible with the changes to the router
|
2017-07-12 11:05:18 +00:00
|
|
|
/*
|
2017-02-15 10:49:30 +00:00
|
|
|
func TestStaticRoute(t *testing.T) {
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-02-15 10:49:30 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
static_w := httptest.NewRecorder()
|
2019-08-14 10:39:04 +00:00
|
|
|
static_req := httptest.NewRequest("get","/s/global.js",bytes.NewReader(nil))
|
2017-02-15 10:49:30 +00:00
|
|
|
static_handler := http.HandlerFunc(route_static)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
static_handler.ServeHTTP(static_w,static_req)
|
|
|
|
if static_w.Code != 200 {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal(static_w.Body)
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func TestTopicAdminRoute(t *testing.T) {
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-02-15 10:49:30 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-09-15 22:20:01 +00:00
|
|
|
admin, err := users.Get(1)
|
2017-02-15 10:49:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_w := httptest.NewRecorder()
|
|
|
|
topic_req := httptest.NewRequest("get","/topic/1",bytes.NewReader(nil))
|
|
|
|
topic_req_admin := topic_req
|
|
|
|
topic_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
topic_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
topic_handler := http.HandlerFunc(route_topic_id)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req_admin)
|
|
|
|
if topic_w.Code != 200 {
|
2017-08-13 11:22:34 +00:00
|
|
|
t.Print(topic_w.Body)
|
|
|
|
t.Fatal("HTTP Error!")
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
2017-08-13 11:22:34 +00:00
|
|
|
t.Print("No problems found in the topic-admin route!")
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func TestTopicGuestRoute(t *testing.T) {
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-02-15 10:49:30 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_w := httptest.NewRecorder()
|
|
|
|
topic_req := httptest.NewRequest("get","/topic/1",bytes.NewReader(nil))
|
|
|
|
topic_handler := http.HandlerFunc(route_topic_id)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
topic_handler.ServeHTTP(topic_w,topic_req)
|
|
|
|
if topic_w.Code != 200 {
|
2017-08-13 11:22:34 +00:00
|
|
|
t.Print(topic_w.Body)
|
|
|
|
t.Fatal("HTTP Error!")
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
2017-08-13 11:22:34 +00:00
|
|
|
t.Print("No problems found in the topic-guest route!")
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Make these routes compatible with the changes to the router
|
2017-07-12 11:05:18 +00:00
|
|
|
/*
|
2017-02-15 10:49:30 +00:00
|
|
|
func TestForumsAdminRoute(t *testing.T) {
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-02-15 10:49:30 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-09-15 22:20:01 +00:00
|
|
|
admin, err := users.Get(1)
|
2017-02-15 10:49:30 +00:00
|
|
|
if err != nil {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal(err)
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal("UID1 is not an admin")
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_req_admin := forums_req
|
|
|
|
forums_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forums_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req_admin)
|
|
|
|
if forums_w.Code != 200 {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal(forums_w.Body)
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestForumsGuestRoute(t *testing.T) {
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-02-15 10:49:30 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forums_w := httptest.NewRecorder()
|
|
|
|
forums_req := httptest.NewRequest("get","/forums/",bytes.NewReader(nil))
|
|
|
|
forums_handler := http.HandlerFunc(route_forums)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forums_handler.ServeHTTP(forums_w,forums_req)
|
|
|
|
if forums_w.Code != 200 {
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Fatal(forums_w.Body)
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func TestForumAdminRoute(t *testing.T) {
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-02-15 10:49:30 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-09-15 22:20:01 +00:00
|
|
|
admin, err := users.Get(1)
|
2017-02-15 10:49:30 +00:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
if !admin.Is_Admin {
|
|
|
|
panic("UID1 is not an admin")
|
|
|
|
}
|
|
|
|
admin_uid_cookie := http.Cookie{Name:"uid",Value:"1",Path:"/",MaxAge: year}
|
|
|
|
admin_session_cookie := http.Cookie{Name:"session",Value: admin.Session,Path:"/",MaxAge: year}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_w := httptest.NewRecorder()
|
2017-02-15 15:29:05 +00:00
|
|
|
forum_req := httptest.NewRequest("get","/forum/1",bytes.NewReader(nil))
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_req_admin := forum_req
|
|
|
|
forum_req_admin.AddCookie(&admin_uid_cookie)
|
|
|
|
forum_req_admin.AddCookie(&admin_session_cookie)
|
|
|
|
forum_handler := http.HandlerFunc(route_forum)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req_admin)
|
|
|
|
if forum_w.Code != 200 {
|
2017-08-13 11:22:34 +00:00
|
|
|
t.Print(forum_w.Body)
|
|
|
|
t.Fatal("HTTP Error!")
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-06-10 07:58:15 +00:00
|
|
|
/*func TestForumGuestRoute(t *testing.T) {
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-02-15 10:49:30 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_w := httptest.NewRecorder()
|
|
|
|
forum_req := httptest.NewRequest("get","/forum/2",bytes.NewReader(nil))
|
|
|
|
forum_handler := http.HandlerFunc(route_forum)
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-15 10:49:30 +00:00
|
|
|
forum_handler.ServeHTTP(forum_w,forum_req)
|
|
|
|
if forum_w.Code != 200 {
|
2017-08-13 11:22:34 +00:00
|
|
|
t.Print(forum_w.Body)
|
|
|
|
t.Fatal("HTTP Error!")
|
2017-02-15 10:49:30 +00:00
|
|
|
}
|
2017-06-10 07:58:15 +00:00
|
|
|
}*/
|
2017-02-15 10:49:30 +00:00
|
|
|
|
2017-02-28 09:27:28 +00:00
|
|
|
/*func TestAlerts(t *testing.T) {
|
2018-08-29 02:34:46 +00:00
|
|
|
gloinit()
|
2017-02-28 09:27:28 +00:00
|
|
|
if !plugins_inited {
|
|
|
|
init_plugins()
|
|
|
|
}
|
|
|
|
db = db_test
|
|
|
|
alert_w := httptest.NewRecorder()
|
2017-03-01 11:36:50 +00:00
|
|
|
alert_req := httptest.NewRequest("get","/api/?action=get&module=alerts&format=json",bytes.NewReader(nil))
|
2017-02-28 09:27:28 +00:00
|
|
|
alert_handler := http.HandlerFunc(route_api)
|
|
|
|
//testdb.StubQuery()
|
|
|
|
testdb.SetQueryFunc(func(query string) (result sql.Rows, err error) {
|
|
|
|
cols := []string{"asid","actor","targetUser","event","elementType","elementID"}
|
|
|
|
rows := `1,1,0,like,post,5
|
|
|
|
1,1,0,friend_invite,user,2`
|
|
|
|
return testdb.RowsFromCSVString(cols,rows), nil
|
|
|
|
})
|
2017-06-28 12:05:26 +00:00
|
|
|
|
2017-02-28 09:27:28 +00:00
|
|
|
alert_handler.ServeHTTP(alert_w,alert_req)
|
2017-08-13 11:22:34 +00:00
|
|
|
t.Print(alert_w.Body)
|
2017-02-28 09:27:28 +00:00
|
|
|
if alert_w.Code != 200 {
|
2017-08-13 11:22:34 +00:00
|
|
|
t.Fatal("HTTP Error!")
|
2017-02-28 09:27:28 +00:00
|
|
|
}
|
|
|
|
db = db_prod
|
|
|
|
}*/
|
|
|
|
|
2017-04-12 10:10:36 +00:00
|
|
|
func TestSplittyThing(t *testing.T) {
|
2017-09-03 04:50:31 +00:00
|
|
|
var extraData string
|
|
|
|
var path = "/pages/hohoho"
|
|
|
|
t.Log("Raw Path:", path)
|
|
|
|
if path[len(path)-1] != '/' {
|
|
|
|
extraData = path[strings.LastIndexByte(path, '/')+1:]
|
|
|
|
path = path[:strings.LastIndexByte(path, '/')+1]
|
2017-04-12 10:10:36 +00:00
|
|
|
}
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Path:", path)
|
2017-09-03 04:50:31 +00:00
|
|
|
t.Log("Extra Data:", extraData)
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Path Bytes:", []byte(path))
|
2017-09-03 04:50:31 +00:00
|
|
|
t.Log("Extra Data Bytes:", []byte(extraData))
|
2017-06-28 12:05:26 +00:00
|
|
|
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Splitty thing test")
|
2017-04-12 10:10:36 +00:00
|
|
|
path = "/topics/"
|
2017-09-03 04:50:31 +00:00
|
|
|
extraData = ""
|
|
|
|
t.Log("Raw Path:", path)
|
|
|
|
if path[len(path)-1] != '/' {
|
|
|
|
extraData = path[strings.LastIndexByte(path, '/')+1:]
|
|
|
|
path = path[:strings.LastIndexByte(path, '/')+1]
|
2017-04-12 10:10:36 +00:00
|
|
|
}
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Path:", path)
|
2017-09-03 04:50:31 +00:00
|
|
|
t.Log("Extra Data:", extraData)
|
Added the Social Groups plugin. This is still under construction.
Made a few improvements to the ForumStore, including bringing it's API closer in line with the other datastores, adding stubs for future subforum functionality, and improving efficiency in a few places.
The auth interface now handles all the authentication stuff.
Renamed the debug config variable to debug_mode.
Added the PluginPerms API.
Internal Errors will now dump the stack trace in the console.
Added support for installable plugins.
Refactored the routing logic so that the router now handles the common PreRoute logic(exc. /static/)
Added the CreateTable method to the query generator. It might need some tweaking to better support other database systems.
Added the same CreateTable method to the query builder.
Began work on PostgreSQL support.
Added the string-string hook type
Added the pre_render hook type.
Added the ParentID and ParentType fields to forums.
Added the get_forum_url_prefix function.
Added a more generic build_slug function.
Added the get_topic_url_prefix function.
Added the override_perms and override_forum_perms functions for bulk setting and unsetting permissions.
Added more ExtData fields in a few structs and removed them on the Perms struct as the PluginPerms API supersedes them there.
Plugins can now see the router instance.
The plugin initialisation handlers can now throw errors.
Plugins are now initialised after all the forum's subsystems are.
Refactored the unit test logic. For instance, we now use the proper .Log method rather than fmt.Println in many cases.
Sorry, we'll have to break Github's generated file detection, as the build instructions aren't working, unless I put them at the top, and they're far, far more important than getting Github to recognise the generated code as generated code.
Fixed an issue with mysql.go's _init_database() overwriting the dbpassword variable. Not a huge issue, but it is a "gotcha" for those not expecting a ':' at the start.
Fixed an issue with forum creation where the forum permissions didn't get cached.
Fixed a bug in plugin_bbcode where negative numbers in rand would crash Gosora.
Made the outputs of plugin_markdown and plugin_bbcode more compliant with the tests.
Revamped the phrase system to make it easier for us to add language pack related features in the future.
Added the WidgetMenu widget type.
Revamped the theme again. I'm experimenting to see which approach I like most.
- Excuse the little W3C rage. Some things about CSS drive me crazy :p
Tests:
Added 22 bbcode_full_parse tests.
Added 19 bbcode_regex_parse tests.
Added 27 markdown_parse tests.
Added four UserStore tests. More to come when the test database functionality is added.
Added 18 name_to_slug tests.
Hooks:
Added the pre_render hook.
Added the pre_render_forum_list hook.
Added the pre_render_view_forum hook.
Added the pre_render_topic_list hook.
Added the pre_render_view_topic hook.
Added the pre_render_profile hook.
Added the pre_render_custom_page hook.
Added the pre_render_overview hook.
Added the pre_render_create_topic hook.
Added the pre_render_account_own_edit_critical hook.
Added the pre_render_account_own_edit_avatar hook.
Added the pre_render_account_own_edit_username hook.
Added the pre_render_account_own_edit_email hook.
Added the pre_render_login hook.
Added the pre_render_register hook.
Added the pre_render_ban hook.
Added the pre_render_panel_dashboard hook.
Added the pre_render_panel_forums hook.
Added the pre_render_panel_delete_forum hook.
Added the pre_render_panel_edit_forum hook.
Added the pre_render_panel_settings hook.
Added the pre_render_panel_setting hook.
Added the pre_render_panel_plugins hook.
Added the pre_render_panel_users hook.
Added the pre_render_panel_edit_user hook.
Added the pre_render_panel_groups hook.
Added the pre_render_panel_edit_group hook.
Added the pre_render_panel_edit_group_perms hook.
Added the pre_render_panel_themes hook.
Added the pre_render_panel_mod_log hook.
Added the pre_render_error hook.
Added the pre_render_security_error hook.
Added the create_group_preappend hook.
Added the intercept_build_widgets hook.
Added the simple_forum_check_pre_perms hook.
Added the forum_check_pre_perms hook.
2017-07-09 12:06:04 +00:00
|
|
|
t.Log("Path Bytes:", []byte(path))
|
2017-09-03 04:50:31 +00:00
|
|
|
t.Log("Extra Data Bytes:", []byte(extraData))
|
2017-04-12 10:10:36 +00:00
|
|
|
}
|