Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Aurora
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zandor Smith
Aurora
Commits
a8be9a3b
Commit
a8be9a3b
authored
8 years ago
by
Ri Xu
Browse files
Options
Downloads
Patches
Plain Diff
Modify the lock granularity used in statistics data store struct and improve coverage of code.
parent
888d5a9a
No related branches found
Branches containing commit
Tags
1.5
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main_test.go
+56
-1
56 additions, 1 deletion
main_test.go
statisticsUtils.go
+2
-4
2 additions, 4 deletions
statisticsUtils.go
structs.go
+13
-62
13 additions, 62 deletions
structs.go
with
71 additions
and
67 deletions
main_test.go
+
56
−
1
View file @
a8be9a3b
...
...
@@ -119,6 +119,31 @@ func TestIndex(t *testing.T) {
if
err
!=
nil
{
t
.
Log
(
err
)
}
resp
,
err
=
http
.
PostForm
(
server
+
"/tube?server="
+
bstk
+
"&action=addSample"
,
url
.
Values
{
"tube"
:
{
"aurora_test"
},
"addsamplejobid"
:
{
"1"
},
"addsamplename"
:
{
""
},
"tubes[aurora_test]"
:
{
"1"
}})
if
err
!=
nil
{
t
.
Log
(
err
)
}
resp
,
err
=
http
.
PostForm
(
server
+
"/tube?server="
+
bstk
+
"&action=addSample"
,
url
.
Values
{
"tube"
:
{
"default"
},
"addsamplejobid"
:
{
"1"
},
"addsamplename"
:
{
"sample_1"
},
"tubes[aurora_test]"
:
{
"1"
}})
if
err
!=
nil
{
t
.
Log
(
err
)
}
resp
,
err
=
http
.
PostForm
(
server
+
"/tube?server=not_exist_server_addr&action=addSample"
,
url
.
Values
{
"tube"
:
{
"aurora_test"
},
"addsamplejobid"
:
{
"1"
},
"addsamplename"
:
{
"sample_2"
},
"tubes[default]"
:
{
"1"
}})
if
err
!=
nil
{
t
.
Log
(
err
)
}
resp
,
err
=
http
.
PostForm
(
server
+
"/tube?server="
+
bstk
+
"&action=addSample"
,
url
.
Values
{
"tube"
:
{
"aurora_test"
},
"addsamplejobid"
:
{
""
},
"addsamplename"
:
{
"sample_2"
},
"tubes[aurora_test]"
:
{
"1"
}})
if
err
!=
nil
{
t
.
Log
(
err
)
}
resp
,
err
=
http
.
PostForm
(
server
+
"/tube?server="
+
bstk
+
"&action=addSample"
,
url
.
Values
{
"tube"
:
{
"aurora_test"
},
"addsamplejobid"
:
{
"not_int"
},
"addsamplename"
:
{
"sample_2"
},
"tubes[aurora_test]"
:
{
"1"
}})
if
err
!=
nil
{
t
.
Log
(
err
)
}
for
_
,
v
:=
range
urls
{
req
,
err
:=
http
.
NewRequest
(
"GET"
,
server
+
v
,
nil
)
if
err
!=
nil
{
...
...
@@ -305,7 +330,7 @@ func TestPrettyJSON(t *testing.T) {
func
TestBase64Decode
(
t
*
testing
.
T
)
{
once
.
Do
(
testSetup
)
base64Decode
(
`dGVzdA==`
)
base64Decode
(
`test`
)
base64Decode
(
`test
-%?s
`
)
}
func
TestRemoveServerInConfig
(
t
*
testing
.
T
)
{
...
...
@@ -327,10 +352,40 @@ func TestAddSampleTube(t *testing.T) {
once
.
Do
(
testSetup
)
addSampleTube
(
`aurora_test_2`
,
`test`
)
getSampleJobList
()
getSampleJobNameByKey
(
`97ec882fd75855dfa1b4bd00d4a367d4`
)
loadSample
(
``
,
`default`
,
`97ec882fd75855dfa1b4bd00d4a367d4`
)
loadSample
(
bstk
,
`default`
,
`97ec882fd75855dfa1b4bd00d4a367d4`
)
deleteSamples
(
`97ec882fd75855dfa1b4bd00d4a367d4`
)
}
func
TestBasicAuth
(
t
*
testing
.
T
)
{
once
.
Do
(
testSetup
)
var
err
error
var
req
*
http
.
Request
var
client
=
&
http
.
Client
{}
pubConf
.
Auth
.
Enabled
=
true
http
.
HandleFunc
(
"/test"
,
basicAuth
(
handlerMain
))
req
,
err
=
http
.
NewRequest
(
"GET"
,
server
+
"/test"
,
nil
)
if
err
!=
nil
{
t
.
Log
(
err
)
}
client
=
&
http
.
Client
{}
_
,
err
=
client
.
Do
(
req
)
if
err
!=
nil
{
t
.
Log
(
err
)
}
req
,
err
=
http
.
NewRequest
(
"GET"
,
server
+
"/test"
,
nil
)
if
err
!=
nil
{
t
.
Log
(
err
)
}
req
.
SetBasicAuth
(
`admin`
,
`password`
)
client
=
&
http
.
Client
{}
_
,
err
=
client
.
Do
(
req
)
if
err
!=
nil
{
t
.
Log
(
err
)
}
}
func
TestDeleteSamples
(
t
*
testing
.
T
)
{
once
.
Do
(
testSetup
)
deleteSamples
(
``
)
...
...
This diff is collapsed.
Click to expand it.
statisticsUtils.go
+
2
−
4
View file @
a8be9a3b
...
...
@@ -100,7 +100,6 @@ func statistic() {
case
<-
notify
:
break
NOTIFY
case
<-
tick
:
statisticsData
.
Lock
()
for
k
,
v
:=
range
statisticsData
.
Server
{
for
t
:=
range
v
{
if
selfConf
.
StatisticsCollection
==
0
{
...
...
@@ -112,7 +111,6 @@ func statistic() {
}
}
}
statisticsData
.
Unlock
()
}
}
}
...
...
@@ -141,6 +139,7 @@ func statisticAgent(server string, tube string) error {
if
err
!=
nil
{
continue
}
statisticsData
.
Lock
()
_
,
ok
:=
statisticsData
.
Server
[
server
][
tube
][
k
]
if
!
ok
{
statisticsData
.
Server
[
server
][
tube
][
k
]
=
list
.
New
()
...
...
@@ -150,6 +149,7 @@ func statisticAgent(server string, tube string) error {
statisticsData
.
Server
[
server
][
tube
][
k
]
.
Remove
(
front
)
}
statisticsData
.
Server
[
server
][
tube
][
k
]
.
PushFront
([]
int
{
t
.
Year
(),
int
(
t
.
Month
()),
t
.
Day
(),
t
.
Hour
(),
t
.
Minute
(),
t
.
Second
(),
stats
})
statisticsData
.
Unlock
()
}
}
bstkConn
.
Close
()
...
...
@@ -160,7 +160,6 @@ func statisticAgent(server string, tube string) error {
func
statisticWaitress
(
server
string
,
tube
string
)
string
{
var
buf
,
b
,
s
,
l
bytes
.
Buffer
b
.
WriteString
(
`{`
)
statisticsData
.
Lock
()
for
_
,
field
:=
range
statisticsFields
{
for
k
:=
range
field
{
b
.
WriteString
(
`"`
)
...
...
@@ -186,7 +185,6 @@ func statisticWaitress(server string, tube string) string {
b
.
WriteString
(
`],`
)
}
}
statisticsData
.
Unlock
()
buf
.
WriteString
(
strings
.
TrimSuffix
(
b
.
String
(),
`,`
))
buf
.
WriteString
(
`}`
)
return
buf
.
String
()
...
...
This diff is collapsed.
Click to expand it.
structs.go
+
13
−
62
View file @
a8be9a3b
...
...
@@ -15,74 +15,25 @@ const (
DefaultPriority
=
1024
// most urgent: 0, least urgent: 4294967295.
DefaultTTR
=
60
// 1 minute
DefaultTubePauseSeconds
=
3600
TplHead
=
`<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--[if IE]>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<![endif]-->
<meta name="description" content="Beanstalk Console">
<meta name="keywords" content="Beanstalk Console, beanstalk, console">
<meta content="always" name="referrer">
<meta name="language" content="en-US">
<meta name="category" content="Tools">
<meta name="summary" content="Beanstalk Console">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link rel="copyright" href="http://www.opensource.org/licenses/mit-license.php"/>
<link rel="icon" sizes="32x32" href="./images/aurora-32x32.ico">
<link rel="apple-touch-icon-precomposed" sizes="180x180" href="./images/apple-touch-icon-180x180-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="./images/apple-touch-icon-152x152-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="./images/apple-touch-icon-144x144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="./images/apple-touch-icon-120x120-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="./images/apple-touch-icon-114x114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="./images/apple-touch-icon-76x76-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="./images/apple-touch-icon-72x72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="./images/apple-touch-icon-precomposed-57x57.png">
<title>Beanstalk Console</title>
<!-- Bootstrap core CSS -->
<link href="./assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="./css/customer.css" rel="stylesheet">
<link href="./highlight/styles/magula.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="./js/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="./js/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>`
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
TplHead
=
`<head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]--><meta name="description" content="Beanstalk Console"><meta name="keywords" content="Beanstalk Console, beanstalk, console"><meta content="always" name="referrer"><meta name="language" content="en-US"><meta name="category" content="Tools"><meta name="summary" content="Beanstalk Console"><meta name="apple-mobile-web-app-capable" content="yes"/><link rel="copyright" href="http://www.opensource.org/licenses/mit-license.php"/><link rel="icon" sizes="32x32" href="./images/aurora-32x32.ico"><link rel="apple-touch-icon-precomposed" sizes="180x180" href="./images/apple-touch-icon-180x180-precomposed.png"><link rel="apple-touch-icon-precomposed" sizes="152x152" href="./images/apple-touch-icon-152x152-precomposed.png"><link rel="apple-touch-icon-precomposed" sizes="144x144" href="./images/apple-touch-icon-144x144-precomposed.png"><link rel="apple-touch-icon-precomposed" sizes="120x120" href="./images/apple-touch-icon-120x120-precomposed.png"><link rel="apple-touch-icon-precomposed" sizes="114x114" href="./images/apple-touch-icon-114x114-precomposed.png"><link rel="apple-touch-icon-precomposed" sizes="76x76" href="./images/apple-touch-icon-76x76-precomposed.png"><link rel="apple-touch-icon-precomposed" sizes="72x72" href="./images/apple-touch-icon-72x72-precomposed.png"><link rel="apple-touch-icon-precomposed" href="./images/apple-touch-icon-precomposed-57x57.png"><title>Beanstalk Console</title><!-- Bootstrap core CSS --><link href="./assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"><link href="./css/customer.css" rel="stylesheet"><link href="./highlight/styles/magula.css" rel="stylesheet"><!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries --><!--[if lt IE 9]><script src="./js/libs/html5shiv/3.7.0/html5shiv.js"></script><script src="./js/libs/respond.js/1.4.2/respond.min.js"></script><![endif]--></head>`
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
)
// Define server and tube stats fields.
var
(
ConfigFile
=
`.`
+
string
(
os
.
PathSeparator
)
+
`aurora.toml`
// Stdout is the io.Writer to which executed commands write standard output.
Stdout
io
.
Writer
=
os
.
Stdout
// Stderr is the io.Writer to which executed commands write standard error.
Stderr
io
.
Writer
=
os
.
Stderr
pubConf
PubConfig
selfConf
SelfConf
sampleJobs
SampleJobs
statisticsDataServer
=
make
(
map
[
string
]
map
[
string
]
map
[
string
]
*
list
.
List
)
statisticsData
=
StatisticsData
{
new
(
sync
.
RWMutex
),
statisticsDataServer
,
}
notify
=
make
(
chan
bool
,
1
)
updateInfo
=
"uncheck"
selfConf
SelfConf
Stderr
io
.
Writer
=
os
.
Stderr
// Stderr is the io.Writer to which executed commands write standard error.
Stdout
io
.
Writer
=
os
.
Stdout
// Stdout is the io.Writer to which executed commands write standard output.
ConfigFile
=
`.`
+
string
(
os
.
PathSeparator
)
+
`aurora.toml`
statisticsData
=
StatisticsData
{
new
(
sync
.
RWMutex
),
statisticsDataServer
}
statisticsDataServer
=
make
(
map
[
string
]
map
[
string
]
map
[
string
]
*
list
.
List
)
notify
=
make
(
chan
bool
,
1
)
updateInfo
=
"uncheck"
// Server filter columns.
binlogStatsGroups
=
[]
map
[
string
]
string
{
map
[
string
]
string
{
"binlog-current-index"
:
"the index of the current binlog file being written to. If binlog is not active this value will be 0"
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment