Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lisa Casino
slapos.toolbox
Commits
525cd5f9
Commit
525cd5f9
authored
Aug 20, 2021
by
Lisa Casino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug test
parent
a1554b87
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
14 deletions
+36
-14
slapos/test/promise/data/folder_disk_test.sql
slapos/test/promise/data/folder_disk_test.sql
+14
-14
slapos/test/promise/plugin/test_monitor_partition_space.py
slapos/test/promise/plugin/test_monitor_partition_space.py
+22
-0
No files found.
slapos/test/promise/data/folder_disk_test.sql
View file @
525cd5f9
BEGIN
TRANSACTION
;
BEGIN
TRANSACTION
;
CREATE
TABLE
disk
(
partition
text
,
used
text
,
free
text
,
mountpoint
text
,
date
text
,
time
text
,
reported
integer
NULL
DEFAULT
0
);
CREATE
TABLE
disk
(
partition
text
,
used
text
,
free
text
,
mountpoint
text
,
date
text
,
time
text
,
reported
integer
NULL
DEFAULT
0
);
CREATE
TABLE
folder
(
partition
text
,
disk_used
real
,
date
text
,
time
text
,
reported
integer
NULL
DEFAULT
0
);
CREATE
TABLE
folder
(
partition
text
,
disk_used
real
,
date
text
,
time
text
,
reported
integer
NULL
DEFAULT
0
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159220666368'
,
'288948396032'
,
'/'
,
'2017-10-02'
,
'09:17:01'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159220666368'
,
'288948396032'
,
'/'
,
'2017-10-02'
,
'09:17:01'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159237537792'
,
'288931524608'
,
'/'
,
'2017-10-02'
,
'09:18:01'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159237537792'
,
'288931524608'
,
'/'
,
'2017-10-02'
,
'09:18:01'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159238090752'
,
'288930971648'
,
'/'
,
'2017-10-02'
,
'09:19:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159238090752'
,
'288930971648'
,
'/'
,
'2017-10-02'
,
'09:19:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159241568256'
,
'288927494144'
,
'/'
,
'2017-10-02'
,
'09:20:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159241568256'
,
'288927494144'
,
'/'
,
'2017-10-02'
,
'09:20:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159242719232'
,
'288926343168'
,
'/'
,
'2017-10-02'
,
'09:21:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159242719232'
,
'288926343168'
,
'/'
,
'2017-10-02'
,
'09:21:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159196176384'
,
'288972886016'
,
'/'
,
'2017-10-02'
,
'09:22:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159196176384'
,
'288972886016'
,
'/'
,
'2017-10-02'
,
'09:22:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159300747264'
,
'288868315136'
,
'/'
,
'2017-10-02'
,
'09:23:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159300747264'
,
'288868315136'
,
'/'
,
'2017-10-02'
,
'09:23:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159294308352'
,
'288874754048'
,
'/'
,
'2017-10-02'
,
'09:24:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159294308352'
,
'288874754048'
,
'/'
,
'2017-10-02'
,
'09:24:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159328468992'
,
'288840593408'
,
'/'
,
'2017-10-02'
,
'09:25:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159328468992'
,
'288840593408'
,
'/'
,
'2017-10-02'
,
'09:25:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159384883200'
,
'288784179200'
,
'/'
,
'2017-10-02'
,
'09:26:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159384883200'
,
'288784179200'
,
'/'
,
'2017-10-02'
,
'09:26:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159429677056'
,
'288739385344'
,
'/'
,
'2017-10-02'
,
'09:27:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159429677056'
,
'288739385344'
,
'/'
,
'2017-10-02'
,
'09:27:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159444549632'
,
'288724512768'
,
'/'
,
'2017-10-02'
,
'09:28:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159444549632'
,
'288724512768'
,
'/'
,
'2017-10-02'
,
'09:28:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159472902144'
,
'288696160256'
,
'/'
,
'2017-10-02'
,
'09:29:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159472902144'
,
'288696160256'
,
'/'
,
'2017-10-02'
,
'09:29:02'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
/dev/vda2
'
,
'159476805632'
,
'288692256768'
,
'/'
,
'2017-10-02'
,
'09:30:03'
,
1
);
INSERT
INTO
"disk"
VALUES
(
'
disk_partition_name
'
,
'159476805632'
,
'288692256768'
,
'/'
,
'2017-10-02'
,
'09:30:03'
,
1
);
INSERT
INTO
"folder"
VALUES
(
'slapuser0'
,
21883255
.
0
,
'2017-09-18'
,
'09:30:20'
,
1
);
INSERT
INTO
"folder"
VALUES
(
'slapuser0'
,
21883255
.
0
,
'2017-09-18'
,
'09:30:20'
,
1
);
INSERT
INTO
"folder"
VALUES
(
'slapuser0'
,
24071580
.
5
,
'2017-09-19'
,
'09:30:11'
,
1
);
INSERT
INTO
"folder"
VALUES
(
'slapuser0'
,
24071580
.
5
,
'2017-09-19'
,
'09:30:11'
,
1
);
INSERT
INTO
"folder"
VALUES
(
'slapuser0'
,
23196250
.
3
,
'2017-09-20'
,
'09:30:08'
,
1
);
INSERT
INTO
"folder"
VALUES
(
'slapuser0'
,
23196250
.
3
,
'2017-09-20'
,
'09:30:08'
,
1
);
...
...
slapos/test/promise/plugin/test_monitor_partition_space.py
View file @
525cd5f9
...
@@ -29,6 +29,7 @@ from slapos.test.promise.plugin import TestPromisePluginMixin
...
@@ -29,6 +29,7 @@ from slapos.test.promise.plugin import TestPromisePluginMixin
from
slapos.grid.promise
import
PromiseError
from
slapos.grid.promise
import
PromiseError
import
os
import
os
import
sqlite3
import
sqlite3
import
psutil
from
slapos.grid.promise
import
PromiseError
from
slapos.grid.promise
import
PromiseError
class
TestMonitorPartitionSpace
(
TestPromisePluginMixin
):
class
TestMonitorPartitionSpace
(
TestPromisePluginMixin
):
...
@@ -40,13 +41,34 @@ class TestMonitorPartitionSpace(TestPromisePluginMixin):
...
@@ -40,13 +41,34 @@ class TestMonitorPartitionSpace(TestPromisePluginMixin):
self
.
db_file
=
'/tmp/collector.db'
self
.
db_file
=
'/tmp/collector.db'
print
(
self
.
partition_dir
)
print
(
self
.
partition_id
)
# get disk partition name
disk_partition
=
""
path
=
os
.
path
.
join
(
self
.
partition_dir
,
""
)
+
"extrafolder"
partitions
=
psutil
.
disk_partitions
()
while
path
is
not
'/'
:
if
not
disk_partition
:
path
=
os
.
path
.
dirname
(
path
)
else
:
break
for
p
in
partitions
:
if
p
.
mountpoint
==
path
:
disk_partition
=
p
.
device
break
# populate db
# populate db
self
.
conn
=
sqlite3
.
connect
(
self
.
db_file
)
self
.
conn
=
sqlite3
.
connect
(
self
.
db_file
)
f
=
open
(
self
.
base_path
+
"/folder_disk_test.sql"
)
f
=
open
(
self
.
base_path
+
"/folder_disk_test.sql"
)
sql
=
f
.
read
()
sql
=
f
.
read
()
# replace every disk_partition_name string with disk partition name
sql
=
sql
.
replace
(
'disk_partition_name'
,
disk_partition
)
self
.
conn
.
executescript
(
sql
)
self
.
conn
.
executescript
(
sql
)
self
.
conn
.
close
()
self
.
conn
.
close
()
print
(
self
.
partition_dir
)
self
.
promise_name
=
"monitor-partition-space.py"
self
.
promise_name
=
"monitor-partition-space.py"
content
=
"""from slapos.promise.plugin.monitor_partition_space import RunPromise
content
=
"""from slapos.promise.plugin.monitor_partition_space import RunPromise
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment