diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..373a487 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +## 0.1.1 / 2019-08-27 +[Changed] LiteSpeedReport.Version to string from float64 + +## 0.1.0 / 2019-08-27 + +Initial release diff --git a/VERSION b/VERSION index 6e8bf73..17e51c3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0 +0.1.1 diff --git a/pkg/rtreport/parse.go b/pkg/rtreport/parse.go index a44d1a9..6c961d2 100644 --- a/pkg/rtreport/parse.go +++ b/pkg/rtreport/parse.go @@ -34,7 +34,7 @@ func NewLineParser(lineTxt string) LineParser { type versionLine string -// VERSION: LiteSpeed Web Server/Enterprise/x.x +// VERSION: LiteSpeed Web Server/Enterprise/x.x.x to x.x.x func (v versionLine) parse(report *LiteSpeedReport) { lineText := string(v) if len(lineText) < 10 { @@ -42,7 +42,7 @@ func (v versionLine) parse(report *LiteSpeedReport) { return } s := strings.Split(lineText, "/") - report.Version, report.error = strconv.ParseFloat(s[len(s)-1], 64) + report.Version = s[len(s)-1] } type uptimeLine string diff --git a/pkg/rtreport/parse_test.go b/pkg/rtreport/parse_test.go index 85c0640..f013835 100644 --- a/pkg/rtreport/parse_test.go +++ b/pkg/rtreport/parse_test.go @@ -67,21 +67,21 @@ func Test_versionLine_parse(t *testing.T) { name string v versionLine args LiteSpeedReport - want float64 + want string wantErr bool }{ { name: "ok", - v: versionLine("VERSION: LiteSpeed Web Server/Enterprise/5.8"), + v: versionLine("VERSION: LiteSpeed Web Server/Enterprise/5.8.1"), args: LiteSpeedReport{}, - want: 5.8, + want: "5.8.1", wantErr: false, }, { name: "ng", v: versionLine("5.8"), args: LiteSpeedReport{}, - want: 0, + want: "", wantErr: true, }, } diff --git a/pkg/rtreport/rtreport.go b/pkg/rtreport/rtreport.go index a6b70e1..30ffe04 100644 --- a/pkg/rtreport/rtreport.go +++ b/pkg/rtreport/rtreport.go @@ -44,7 +44,7 @@ const ( // LiteSpeedReport type LiteSpeedReport struct { error error - Version float64 + Version string Uptime float64 NetworkReport map[string]float64 ConnectionReport map[string]float64 diff --git a/pkg/rtreport/rtreport_test.go b/pkg/rtreport/rtreport_test.go index 1901414..cdc2a27 100644 --- a/pkg/rtreport/rtreport_test.go +++ b/pkg/rtreport/rtreport_test.go @@ -22,7 +22,7 @@ func Test_sum(t *testing.T) { args: args{ a: &LiteSpeedReport{ Uptime: 123, - Version: 5.4, + Version: "5.4", NetworkReport: map[string]float64{"BPS_IN": 123, "BPS_OUT": 713819, "SSL_BPS_IN": 136, "SSL_BPS_OUT": 891290}, ConnectionReport: map[string]float64{"MAXCONN": 10000, "MAXSSL_CONN": 5000, "PLAINCONN": 2331, "AVAILCONN": 7669, "IDLECONN": 0, "SSLCONN": 5, "AVAILSSL": 4995}, RequestReports: map[string]map[string]float64{ @@ -39,7 +39,7 @@ func Test_sum(t *testing.T) { }, b: &LiteSpeedReport{ Uptime: 123, - Version: 5.4, + Version: "5.4", NetworkReport: map[string]float64{"BPS_IN": 21213, "BPS_OUT": 343819, "SSL_BPS_IN": 123363, "SSL_BPS_OUT": 913290}, ConnectionReport: map[string]float64{"MAXCONN": 10000, "MAXSSL_CONN": 5000, "PLAINCONN": 1000, "AVAILCONN": 9000, "IDLECONN": 1, "SSLCONN": 100, "AVAILSSL": 4900}, RequestReports: map[string]map[string]float64{ @@ -56,7 +56,7 @@ func Test_sum(t *testing.T) { }, want: &LiteSpeedReport{ Uptime: 123, - Version: 5.4, + Version: "5.4", NetworkReport: map[string]float64{"BPS_IN": 21336, "BPS_OUT": 1057638, "SSL_BPS_IN": 123499, "SSL_BPS_OUT": 1804580}, ConnectionReport: map[string]float64{"MAXCONN": 20000, "MAXSSL_CONN": 10000, "PLAINCONN": 3331, "AVAILCONN": 16669, "IDLECONN": 1, "SSLCONN": 105, "AVAILSSL": 9895}, RequestReports: map[string]map[string]float64{ @@ -94,7 +94,7 @@ func Test_load(t *testing.T) { name: "ok", args: "../test/data/load/.rtreport", want: &LiteSpeedReport{ - Version: 5.4, + Version: "5.4", Uptime: 56070, NetworkReport: map[string]float64{"BPS_IN": 1, "BPS_OUT": 2, "SSL_BPS_IN": 3, "SSL_BPS_OUT": 4}, ConnectionReport: map[string]float64{"MAXCONN": 10000, "MAXSSL_CONN": 5000, "PLAINCONN": 0, "AVAILCONN": 10000, "IDLECONN": 0, "SSLCONN": 0, "AVAILSSL": 5000}, @@ -129,7 +129,7 @@ func TestNew(t *testing.T) { name: "ok", args: "../test/data/new", want: &LiteSpeedReport{ - Version: 5.4, + Version: "5.4", Uptime: 56070, NetworkReport: map[string]float64{"BPS_IN": 2, "BPS_OUT": 4, "SSL_BPS_IN": 6, "SSL_BPS_OUT": 8}, ConnectionReport: map[string]float64{"MAXCONN": 20000, "MAXSSL_CONN": 10000, "PLAINCONN": 0, "AVAILCONN": 20000, "IDLECONN": 0, "SSLCONN": 0, "AVAILSSL": 10000},