-
Notifications
You must be signed in to change notification settings - Fork 527
/
Copy pathmessaging_service_test.py
177 lines (160 loc) · 6.55 KB
/
messaging_service_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
"""Tests for messaging_service.py.
This is the common interface used by the benchmark VM to run the benchmark.
"""
import unittest
from unittest import mock
from perfkitbenchmarker import messaging_service
from perfkitbenchmarker import virtual_machine
from tests import pkb_common_test_case
MESSAGING_SERVICE_DATA_DIR = 'messaging_service_scripts'
class DummyMessagingService(messaging_service.BaseMessagingService):
CLOUD = 'dummy'
def _InstallCloudClients(self):
pass
def Run(self, *args, **kwargs):
pass
def _Create(self, *args, **kwargs):
pass
def _Delete(self, *args, **kwargs):
pass
class MessagingServiceTest(pkb_common_test_case.PkbCommonTestCase):
def setUp(self):
super().setUp()
self.client = mock.create_autospec(
virtual_machine.BaseVirtualMachine, instance=True
)
self.messaging_service = DummyMessagingService()
self.messaging_service.client_vm = self.client
@mock.patch.object(DummyMessagingService, '_InstallCloudClients')
@mock.patch.object(DummyMessagingService, '_InstallCommonClientPackages')
def testPrepareClientVm(
self, install_cloud_clients_mock, install_common_client_packages_mock
):
self.messaging_service.PrepareClientVm()
install_cloud_clients_mock.assert_called_once_with()
install_common_client_packages_mock.assert_called_once_with()
def testPrepareBasicVmClient(self):
self.messaging_service._InstallCommonClientPackages()
self.client.assert_has_calls([
mock.call.RemoteCommand('sudo pip3 install absl-py numpy'),
mock.call.RemoteCommand(
'mkdir -p ~/perfkitbenchmarker/scripts/messaging_service_scripts'
),
mock.call.RemoteCommand(
"find ~/perfkitbenchmarker -type d -exec touch '{}/__init__.py' \\;"
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/__init__.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/__init__.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/app.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/app.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/client.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/client.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/errors.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/errors.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/log_utils.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/log_utils.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/runners.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/runners.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/e2e/__init__.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e/__init__.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/e2e/latency_runner.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e/latency_runner.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/e2e/main_process.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e/main_process.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/e2e/protocol.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e/protocol.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/e2e/publisher.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e/publisher.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/e2e/receiver.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e/receiver.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/e2e/streaming_pull_receiver.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e/streaming_pull_receiver.py',
),
mock.call.RemoteCommand(
'mkdir -p'
' ~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e'
),
mock.call.PushDataFile(
'messaging_service_scripts/common/e2e/worker_utils.py',
'~/perfkitbenchmarker/scripts/messaging_service_scripts/common/e2e/worker_utils.py',
),
])
if __name__ == '__main__':
unittest.main()