Commit 91d65a96 authored by Kirill Smelkov's avatar Kirill Smelkov

fixup! client_test/NEOSrv += LogContent for better debug

LogContent -> LogTail
py/neolog  -> `python -m neo.scripts.neolog`
FIXME for glog
FIXME for admin_0.log and other log files
parent f6b59772
// Copyright (C) 2020-2021 Nexedi SA and Contributors. // Copyright (C) 2020-2023 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com> // Kirill Smelkov <kirr@nexedi.com>
// //
// This program is free software: you can Use, Study, Modify and Redistribute // This program is free software: you can Use, Study, Modify and Redistribute
...@@ -56,7 +56,7 @@ type NEOSrv interface { ...@@ -56,7 +56,7 @@ type NEOSrv interface {
// supports only fixed encoding, and, if yes, which one. // supports only fixed encoding, and, if yes, which one.
BugEncFixed() (bool, proto.Encoding) BugEncFixed() (bool, proto.Encoding)
LogContent() (string, error) // content of log files LogTail() (string, error) // tail of log files
} }
// NEOSrvOptions represents options for a NEO server. // NEOSrvOptions represents options for a NEO server.
...@@ -178,25 +178,26 @@ func (n *NEOPySrv) URL() string { ...@@ -178,25 +178,26 @@ func (n *NEOPySrv) URL() string {
return fmt.Sprintf("%s%s/%s", n.opt.URLPrefix(), n.masterAddr, n.clusterName()) return fmt.Sprintf("%s%s/%s", n.opt.URLPrefix(), n.masterAddr, n.clusterName())
} }
func (n *NEOPySrv) LogContent() (string, error) { func (n *NEOPySrv) LogTail() (string, error) {
scontent, err := n.logFileContent("storage_0.log") stail, err := n.logFileTail("storage_0.log")
if err != nil { if err != nil {
return "", err return "", err
} }
mcontent, err := n.logFileContent("master_0.log") mtail, err := n.logFileTail("master_0.log")
if err != nil { if err != nil {
return "", err return "", err
} }
return scontent + "\n\n" + mcontent, nil // FIXME _ admin_0.log and generally automatically detect all log files
return stail + "\n\n" + mtail, nil
} }
func (n *NEOPySrv) logFileContent(logfilename string) (string, error) { func (n *NEOPySrv) logFileTail(logfilename string) (string, error) {
c := xexec.Command("./py/neolog", fmt.Sprintf("%s/%s", n.opt.workdir, logfilename)) c := xexec.Command("python", "-m", "neo.scripts.neolog", fmt.Sprintf("%s/%s", n.opt.workdir, logfilename))
o, err := c.Output() o, err := c.Output()
if err != nil { if err != nil {
return "", err return "", err
} }
return fmt.Sprintf("log file '%s' content:\n\n", logfilename) + tail(string(o)), nil return fmt.Sprintf("log file '%s' tail:\n\n", logfilename) + tail(string(o)), nil
} }
func tail(s string) (string) { func tail(s string) (string) {
...@@ -316,8 +317,8 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) { ...@@ -316,8 +317,8 @@ func StartNEOGoSrv(opt NEOSrvOptions) (_ *NEOGoSrv, err error) {
return n, nil return n, nil
} }
func (n *NEOGoSrv) LogContent() (string, error) { func (n *NEOGoSrv) LogTail() (string, error) {
return "", nil return "", nil // FIXME return data from glog
} }
func (n *NEOGoSrv) Close() (err error) { func (n *NEOGoSrv) Close() (err error) {
...@@ -580,11 +581,11 @@ func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv ...@@ -580,11 +581,11 @@ func withNEO(t *testing.T, f func(t *testing.T, nsrv NEOSrv, ndrv *Client), optv
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
defer func() { defer func() {
if t.Failed() { if t.Failed() {
logContent, err := nsrv.LogContent() logTail, err := nsrv.LogTail()
if err != nil { if err != nil {
t.Logf("logContent returned err: %s", err) t.Logf("LogTail failed: %s", err)
} else { } else {
t.Logf("NEO log content:\n\n%s", logContent) t.Logf("NEO log tail:\n\n%s", logTail)
} }
} }
}() }()
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
from neo.scripts.neolog import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment