Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unstable
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
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
PROINFODATA
unstable
Commits
d6c80b5d
Commit
d6c80b5d
authored
12 years ago
by
Rafael De Lima Prado
Browse files
Options
Downloads
Patches
Plain Diff
Improved proinfo_test to fail some machines
Signed-off-by:
Rafael de Lima Prado
<
rlp09@inf.ufpr.br
>
parent
e548962d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
database/test/proinfo_inventory.py
+25
-10
25 additions, 10 deletions
database/test/proinfo_inventory.py
with
25 additions
and
10 deletions
database/test/proinfo_inventory.py
+
25
−
10
View file @
d6c80b5d
...
@@ -8,7 +8,9 @@ import unittest
...
@@ -8,7 +8,9 @@ import unittest
# TODO: Unit tests
# TODO: Unit tests
MACHINE_PEAK
=
10000
MACHINE_PEAK
=
10000
DAYS
=
3
DAYS
=
4
NUM_REMOVE_MACHINE
=
5
FIRST_MAC_REMOVE
=
2
MACHINE_DOUBLE_COMM_RATIO
=
0.12
MACHINE_DOUBLE_COMM_RATIO
=
0.12
MACHINE_MULTI_COMM_RATIO
=
0.02
MACHINE_MULTI_COMM_RATIO
=
0.02
MACHINE_DECREASE_RATIO
=
1.1
MACHINE_DECREASE_RATIO
=
1.1
...
@@ -35,7 +37,7 @@ WHERE i.macaddr = %s AND s.id = i.sch_id AND s.inep = %s''', (mac, INEP))
...
@@ -35,7 +37,7 @@ WHERE i.macaddr = %s AND s.id = i.sch_id AND s.inep = %s''', (mac, INEP))
def
insert_data
(
cur
):
def
insert_data
(
cur
):
for
day
in
range
(
DAYS
):
for
day
in
range
(
DAYS
):
machines
=
machine_increase
(
day
)
machines
=
machine_increase
(
day
+
1
)
refresh_machines
(
machines
,
day
,
cur
)
refresh_machines
(
machines
,
day
,
cur
)
return
max_machine
(
machines
,
DAYS
-
1
)
return
max_machine
(
machines
,
DAYS
-
1
)
...
@@ -52,18 +54,31 @@ def gen_macaddress(integer):
...
@@ -52,18 +54,31 @@ def gen_macaddress(integer):
p4
=
(
integer
&
2147483647
)
>>
24
p4
=
(
integer
&
2147483647
)
>>
24
return
"
00:00:
"
+
toHex
(
p4
)
+
"
:
"
+
toHex
(
p3
)
+
"
:
"
+
toHex
(
p2
)
+
"
:
"
+
toHex
(
p1
)
return
"
00:00:
"
+
toHex
(
p4
)
+
"
:
"
+
toHex
(
p3
)
+
"
:
"
+
toHex
(
p2
)
+
"
:
"
+
toHex
(
p1
)
def
refresh_machines
(
machines
,
day
,
cur
):
def
insert_machine
(
machine
,
day
,
cur
,
contact
):
contact
=
INITIAL_DATE
+
timedelta
(
days
=
day
)
macaddr
=
gen_macaddress
(
machine
)
for
i
in
updated_machines
(
machines
,
day
):
macaddr
=
gen_macaddress
(
i
)
# print "Mac {0}".format(macaddr)
# print "Mac {0}".format(macaddr)
if
i
<
MULTI_HD_TOTAL
:
if
machine
<
MULTI_HD_TOTAL
:
cur
.
execute
(
TEMPLATE
,
(
contact
,
macaddr
,
HD_MODEL
,
HD_SIZE
,
HD_USED
,
HD_EXTRA
))
cur
.
execute
(
TEMPLATE
,
(
contact
,
macaddr
,
HD_MODEL
,
HD_SIZE
,
HD_USED
,
HD_EXTRA
))
else
:
else
:
cur
.
execute
(
TEMPLATE
,
(
contact
,
macaddr
,
None
,
None
,
None
,
0
))
cur
.
execute
(
TEMPLATE
,
(
contact
,
macaddr
,
None
,
None
,
None
,
0
))
def
fail_machines
(
machine
,
day
):
if
machine
>=
FIRST_MAC_REMOVE
+
day
and
machine
<
FIRST_MAC_REMOVE
+
NUM_REMOVE_MACHINE
+
day
:
return
0
else
:
return
1
def
refresh_machines
(
machines
,
day
,
cur
):
contact
=
INITIAL_DATE
+
timedelta
(
days
=
day
)
for
i
in
updated_machines
(
machines
,
day
):
if
day
%
2
==
0
:
insert_machine
(
i
,
day
,
cur
,
contact
)
elif
fail_machines
(
i
,
day
):
insert_machine
(
i
,
day
,
cur
,
contact
)
def
max_machine
(
machines
,
day
):
def
max_machine
(
machines
,
day
):
return
intround
(
machines
/
(
MACHINE_DECREASE_RATIO
*
(
day
+
1
))
)
return
intround
(
machines
)
def
intround
(
f
):
def
intround
(
f
):
return
int
(
round
(
f
))
return
int
(
round
(
f
))
...
@@ -90,7 +105,7 @@ def get_connection(dbname, user):
...
@@ -90,7 +105,7 @@ def get_connection(dbname, user):
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
if
len
(
sys
.
argv
)
!=
3
:
if
len
(
sys
.
argv
)
!=
3
:
sys
.
exit
(
"
Usage: {0} <database> <user>
"
.
format
(
sys
.
argv
[
0
])
)
sys
.
exit
(
"
How to use: test_migration <database> <user>
"
)
connection
=
get_connection
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
connection
=
get_connection
(
sys
.
argv
[
1
],
sys
.
argv
[
2
])
cur
=
connection
.
cursor
()
cur
=
connection
.
cursor
()
count
=
insert_data
(
cur
)
count
=
insert_data
(
cur
)
...
...
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