Update the user guide and script about performance test
[pti/o2.git] / tests / locust / ocloud.py
1 # Copyright (C) 2021 Wind River Systems, Inc.
2 #
3 #  Licensed under the Apache License, Version 2.0 (the "License");
4 #  you may not use this file except in compliance with the License.
5 #  You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #  Unless required by applicable law or agreed to in writing, software
10 #  distributed under the License is distributed on an "AS IS" BASIS,
11 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #  See the License for the specific language governing permissions and
13 #  limitations under the License.
14
15 import os
16 from locust import HttpUser, task, constant
17
18 # bearer_token="Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IkJJb3A2V2JSb29nNjR2YnpzOE12VXpzRHJVNjVSLUp1dWhZX2kzV0hjc2cifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6InNtby10b2tlbi1xNjcyZyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJzbW8iLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIwNmQzNDY1Ny0yZGFlLTQyNDItODMzMC05OTI4MjFmYzk0N2UiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6ZGVmYXVsdDpzbW8ifQ.PbDAaLwi4OdQ4CZUFa1TC2vP0IWJqTP2ECmv287uHCho4vpZU63pkS2SgdtbDHLbPK29wZKJ1q9mqv4fci2WdJ7w87sfbHT1dcC8VzfAq7aQ4Rx6xRtsnTmerWqgsXYF_JqpfpHQFVO2stkV5zvg902J5Yco09xez0V6tIGNNORyBXc0SrQ7nuyMoH4gxAunfE_nFB5bQd9dfJnD7gHdDmh2v0HzKEnOV2KUJVhVLGnXZRJmYq1hoDc9YrJRoXmGucescnMDqUh0t8bwVG5a0BQZlLcc1y7i3WXUWPbXsmJ-7RN2_jYERUlS70SmOfaKNSC-t2BvGuh1lmF6yQaoKA"
19 bearer_token="Bearer "+os.environ.get("SMO_TOKEN_DATA", "")
20
21 class QuickstartUser(HttpUser):
22     wait_time = constant(0)
23
24     @task
25     def ocloud(self):
26         self.client.get("/o2ims-infrastructureInventory/v1/")
27
28     @task
29     def resource(self):
30         resp = self.client.get(
31             "/o2ims-infrastructureInventory/v1/resourcePools")
32         json_resp_dict = resp.json()
33         self.client.get(
34             "/o2ims-infrastructureInventory/v1/resourcePools/%s/resources" %
35             json_resp_dict[0]['resourcePoolId'])
36
37     @task
38     def dms(self):
39         self.client.get("/o2ims-infrastructureInventory/v1/deploymentManagers")
40
41     def on_start(self):
42         self.client.headers = {
43             'Authorization':bearer_token
44         }
45         self.client.verify = False