test_facility_level2producer.py 3 KB
Newer Older
Wei Shoulin's avatar
c3  
Wei Shoulin committed
1
2
import unittest

Wei Shoulin's avatar
brick    
Wei Shoulin committed
3
from csst_dfs_api.facility.level2producer import Level2ProducerApi
Wei Shoulin's avatar
c3  
Wei Shoulin committed
4

Wei Shoulin's avatar
brick    
Wei Shoulin committed
5
class FacilityLevel2ProducerTestCase(unittest.TestCase):
Wei Shoulin's avatar
c3  
Wei Shoulin committed
6
7

    def setUp(self):
Wei Shoulin's avatar
brick    
Wei Shoulin committed
8
        self.api = Level2ProducerApi()
Wei Shoulin's avatar
c3  
Wei Shoulin committed
9

Wei Shoulin's avatar
Wei Shoulin committed
10
11
12
13
    def test_register(self):
        rec = self.api.register(name='Test2', 
            gitlink='http://github.com/xxx/xxx',
            paramfiles='/opt/csst/param1.ini',
Wei Shoulin's avatar
Wei Shoulin committed
14
            image='centos:7',
Wei Shoulin's avatar
Wei Shoulin committed
15
16
17
18
            priority = 3,
            pre_producers=[1,2] )
        print('register:', rec)

Wei Shoulin's avatar
c3  
Wei Shoulin committed
19
    def test_find(self):
Wei Shoulin's avatar
Wei Shoulin committed
20
        recs = self.api.find(key="Te")
Wei Shoulin's avatar
c3  
Wei Shoulin committed
21
22
23
        print('find:', recs)

    def test_get(self):
Wei Shoulin's avatar
Wei Shoulin committed
24
        rec = self.api.get(id=10)
Wei Shoulin's avatar
c3  
Wei Shoulin committed
25
26
        print('get:', rec)

Wei Shoulin's avatar
Wei Shoulin committed
27
28
29
30
31
32
33
34
35
36
37
38
39
    def test_find_nexts(self):
        recs = self.api.find_nexts(id=1)
        print('find_nexts:', recs)

    def test_find_start(self):
        recs = self.api.find_start(key="Te")
        print('find_start:', recs)

    def test_update(self):
        recs = self.api.update(
            id=2,
            name = "start2",
            gitlink = "http://github.com/xxx/xxx",
Wei Shoulin's avatar
Wei Shoulin committed
40
            image = "centos:8",
Wei Shoulin's avatar
Wei Shoulin committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
            paramfiles='/opt/csst/param1.ini',
            priority = 3,
            pre_producers=[1,3]
        )
        print('test_update:', recs)

    def test_delete(self):
        recs = self.api.delete(
            id=11
        )
        print('test_delete:', recs)

    def test_new_job(self):
        recs = self.api.new_job(
Wei Shoulin's avatar
Wei Shoulin committed
55
56
            name = "start2-1-1-",
            dag = "{'start':'1'}"
Wei Shoulin's avatar
Wei Shoulin committed
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
        )
        print('new_job:', recs)

    def test_get_job(self):
        recs = self.api.get_job(
            id = 2
        )
        print('get_job:', recs)     

    def test_update_job(self):
        recs = self.api.update_job(
            id = 2,
            dag = "222",
            status = 2
        )
        print('update_job:', recs) 

    def test_new_running(self):
        recs = self.api.new_running(
            job_id = 2,
            producer_id = 2,
            brick_id = 2,
            start_time = '2022-04-22 13:13:13'
        )
        print('new_running:', recs)

    def test_get_running(self):
        recs = self.api.get_running(
            id = 2
        )
        print('get_running:', recs)

    def test_update_running(self):
        recs = self.api.update_running(
            id = 3,
            job_id = 2,
            producer_id = 2,
            brick_id = 2,
            start_time = '2022-04-22 13:13:13',
            end_time = '2022-04-22 15:13:13',
            prc_status = 1,
            prc_result = 'OK'
        )
        print('update_running:', recs)
Wei Shoulin's avatar
c3  
Wei Shoulin committed
101

Wei Shoulin's avatar
Wei Shoulin committed
102
103
104
105
106
107
108
    def test_find_running(self):
        recs = self.api.find_running(
            job_id = 2,
            producer_id = 2,
            brick_id = 2,
            create_time = ('2022-04-22 10:13:13','2022-04-22 23:13:13')
        )
Wei Shoulin's avatar
graph    
Wei Shoulin committed
109
110
111
112
113
        print('find_running:', recs)

    def test_make_graph(self):
        graph_id_edges = self.api.make_graph(
            start_producer_id = 2,
Wei Shoulin's avatar
Wei Shoulin committed
114
            fig_path = 'graph11.png'
Wei Shoulin's avatar
graph    
Wei Shoulin committed
115
116
        )
        print('graph_id_edges:', graph_id_edges)