Skip to content

Commit

Permalink
- Modify the lock used in statistics data store struct
Browse files Browse the repository at this point in the history
- Improve coverage of code
- Upgrade version to 1.6
- README updated
  • Loading branch information
xuri committed Nov 25, 2016
1 parent a8be9a3 commit c44f6b4
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 8 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@

[![Build Status](https://travis-ci.org/Luxurioust/aurora.svg?branch=master)](https://travis-ci.org/Luxurioust/aurora)
[![Code Coverage](https://codecov.io/gh/Luxurioust/aurora/branch/master/graph/badge.svg)](https://codecov.io/gh/Luxurioust/aurora)
[![Downloads](https://img.shields.io/github/downloads/Luxurioust/aurora/total.svg)](https://github.com/Luxurioust/aurora/releases)
[![Go Report Card](https://goreportcard.com/badge/github.com/Luxurioust/aurora)](https://goreportcard.com/report/github.com/Luxurioust/aurora)
[![GoDoc](https://godoc.org/github.com/Luxurioust/aurora?status.svg)](https://godoc.org/github.com/Luxurioust/aurora)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/Luxurioust/aurora/blob/master/LICENSE)
[![Release](https://img.shields.io/github/release/Luxurioust/aurora.svg?label=Release)](https://github.com/Luxurioust/aurora/releases)

## Overview

aurora is a web-based Beanstalk queue server console written in Go and works on macOS, Linux and Windows machines. Main idea behind using Go for backend development is to utilize ability of the compiler to produce zero-dependency binaries for multiple platforms. aurora was created as an attempt to build very simple and portable application to work with local or remote Beanstalk server.

[See application screenshots](https://github.com/Luxurioust/aurora/wiki)

## Features

- Cross-platform support macOS/Linux/Windows 32/64-bit
Expand Down
2 changes: 1 addition & 1 deletion aurora.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
servers = []
listen = "127.0.0.1:3000"
version = 1.5
version = 1.6

[auth]
enabled = false
Expand Down
30 changes: 29 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
bstk = "127.0.0.1:11300"
configFileWithSampleJobs = `servers = []
listen = "127.0.0.1:3000"
version = 1.4
version = 1.5
[auth]
enabled = false
Expand Down Expand Up @@ -322,6 +322,26 @@ func TestAddSample(t *testing.T) {
}
}

func TestEditSample(t *testing.T) {
once.Do(testSetup)
req, err := http.NewRequest("GET", server+`/sample?action=editSample&key=d44782912092260cec11275b73f78434`, nil)
if err != nil {
t.Log(err)
}
cookie := http.Cookie{Name: "beansServers", Value: `127.0.0.1%3A11300%3B127.0.0.1%3A11300%3B127.0.0.1%3A11301%3B`}
req.AddCookie(&cookie)
var client = &http.Client{}
_, err = client.Do(req)
if err != nil {
t.Log(err)
}
}

func TestGetServerTubes(t *testing.T) {
once.Do(testSetup)
getServerTubes("")
}

func TestPrettyJSON(t *testing.T) {
once.Do(testSetup)
prettyJSON([]byte(`{}`))
Expand All @@ -333,6 +353,12 @@ func TestBase64Decode(t *testing.T) {
base64Decode(`test-%?s`)
}

func TestDropEditSettings(t *testing.T) {
once.Do(testSetup)
selfConf.IsEnabledBase64Decode = 1
dropEditSettings()
}

func TestRemoveServerInConfig(t *testing.T) {
once.Do(testSetup)
removeServerInConfig(bstk)
Expand Down Expand Up @@ -456,6 +482,8 @@ func TestStatistic(t *testing.T) {
defer resp.Body.Close()
statisticCashier("not_int", "", []string{})
statisticCashier("1", "not_int", []string{})
selfConf.StatisticsFrequency = -1
tplStatisticEdit("")
t.SkipNow()
}

Expand Down
2 changes: 1 addition & 1 deletion sampleJobUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func newSample(server string, f url.Values, w http.ResponseWriter, r *http.Reque
http.Redirect(w, r, "/sample?action=manageSamples", 301)
}

// newSample provide method to update a sample job.
// editSample provide method to update a sample job.
func editSample(server string, f url.Values, key string, w http.ResponseWriter, r *http.Request) {
deleteSamples(key)
newSample(server, f, w, r)
Expand Down
2 changes: 2 additions & 0 deletions statisticsUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func statisticAgent(server string, tube string) error {
func statisticWaitress(server string, tube string) string {
var buf, b, s, l bytes.Buffer
b.WriteString(`{`)
statisticsData.RLock()
for _, field := range statisticsFields {
for k := range field {
b.WriteString(`"`)
Expand All @@ -185,6 +186,7 @@ func statisticWaitress(server string, tube string) string {
b.WriteString(`],`)
}
}
statisticsData.RUnlock()
buf.WriteString(strings.TrimSuffix(b.String(), `,`))
buf.WriteString(`}`)
return buf.String()
Expand Down
4 changes: 2 additions & 2 deletions structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// Define the default configuration and HTML header template.
const (
ConfigFileTemplate = "servers = []\r\nlisten = \"127.0.0.1:3000\"\r\nversion = 1.5\r\n\r\n[auth]\r\nenabled = false\r\npassword = \"password\"\r\nusername = \"admin\"\r\n\r\n[sample]\r\nstorage = \"{}\""
ConfigFileTemplate = "servers = []\r\nlisten = \"127.0.0.1:3000\"\r\nversion = 1.6\r\n\r\n[auth]\r\nenabled = false\r\npassword = \"password\"\r\nusername = \"admin\"\r\n\r\n[sample]\r\nstorage = \"{}\""
DefaultDelay = 0
DefaultPriority = 1024 // most urgent: 0, least urgent: 4294967295.
DefaultTTR = 60 // 1 minute
Expand All @@ -19,7 +19,7 @@ const (
TplLinks = `<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"> Links <span class="caret"></span></a><ul class="dropdown-menu"><li><a href="https://github.com/kr/beanstalkd">Beanstalk (GitHub)</a></li><li><a href="https://github.com/Luxurioust/aurora">Aurora (GitHub)</a></li></ul></li>`
TplNoScript = `<noscript><div class="container"><div class="alert alert-danger" role="alert">Aurora beanstalk console requires JavaScript supports, please refresh after enable browser JavaScript support.</div></div></noscript>`
UpdateURL = `https://api.github.com/repos/Luxurioust/aurora/tags`
Version = 1.5
Version = 1.6
)

// Define server and tube stats fields.
Expand Down
3 changes: 1 addition & 2 deletions tplTube.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ func tplTube(content string, server string, tube string) string {
buf.WriteString(TplHead)
buf.WriteString(`<body>`)
buf.WriteString(TplNoScript)
buf.WriteString(`<div class="navbar navbar-fixed-top navbar-default" role="navigation"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="/">Beanstalk console</a></div>
<div class="collapse navbar-collapse"><ul class="nav navbar-nav">`)
buf.WriteString(`<div class="navbar navbar-fixed-top navbar-default" role="navigation"><div class="container"><div class="navbar-header"><button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="/">Beanstalk console</a></div><div class="collapse navbar-collapse"><ul class="nav navbar-nav">`)
buf.WriteString(dropDownServer(server))
buf.WriteString(dropDownTube(server, tube))
buf.WriteString(`</ul><ul class="nav navbar-nav navbar-right"><li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Toolbox <span class="caret"></span></a><ul class="dropdown-menu"><li><a href="#filter" role="button" data-toggle="modal">Filter columns</a></li><li><a href="./sample?action=manageSamples" role="button">Manage samples</a></li><li><a href="./statistics?action=preference" role="button">Statistics preference</a></li><li class="divider"></li><li><a href="#settings" role="button" data-toggle="modal">Edit settings</a></li></ul></li>`)
Expand Down

0 comments on commit c44f6b4

Please sign in to comment.