Commit 525cd5f9 authored by Lisa Casino's avatar Lisa Casino

debug test

parent a1554b87
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);
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment