Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License """ import json import locust.events from locust import HttpLocust, TaskSet, task import uuid from resources import Resources # Resource types initialization should be independent of any client activity global resources resources = Resources() Resources.add_resource_types(Resources.create_resource_types()) class AgentLifeCycle(TaskSet): def on_start(self): global feed self.feed_id = "feed-" + str(uuid.uuid4()) feed = self.feed_id print "New Agent [%s]" % self.feed_id, self.agent_resources = resources.create_large_inventory(self.feed_id) with self.client.post("/import", json.dumps(self.agent_resources), headers=resources.get_headers()) as response: print "Agent [%s] - full auto-discovery" % self.feed_id @task def deploy_app(self): with self.client.post("/import",
limitations under the License """ import json from locust import HttpLocust, TaskSet, task import uuid from resources import Resources # Inventory base url # [todo] This should be defined from environment properties global inventory_url inventory_url = 'http://localhost:8080/hawkular/inventory' # Resource types initialization should be independent of any client activity global resources resources = Resources() Resources.add_resource_types(inventory_url, Resources.create_resource_types()) global headers headers = {'Content-type': 'application/json', 'Accept': 'application/json'} class AgentLifeCycle(TaskSet): def on_start(self): self.feed_id = "feed-" + str(uuid.uuid4()) print "New Agent [%s]" % self.feed_id, # Simulating 1 server with 99 children resources each one with 20 metrics, so 100 resources per agent self.agent_resources = resources.create_large_inventory(self.feed_id, 1, 99, 20) self.client.post("/import", json.dumps(self.agent_resources), headers=headers) print "Agent [%s] - full auto-discovery" % self.feed_id, @task def deploy_app(self):