Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Locust tests - initial changes for #412 #611

Merged
merged 1 commit into from
Mar 8, 2019

Conversation

pm7h
Copy link
Contributor

@pm7h pm7h commented Feb 21, 2019

Adding Locust tests. We are also working on adding load tests using the e2e framework (#573) but these tests provide a convenient way to run a quick test with very high load.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: b83762d3-1ae2-479b-a580-fad363844987

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-7b0f32f

@markmandel
Copy link
Member

Sorry - the reopening of a previously closed PR made funny things happen - so you've got a few messages.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 8207771e-9203-4f7d-8e2e-91362bb98d29

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 49546ec7-2057-4434-b6f1-cfb1837abe50

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a9ae3734-2e40-40c9-98df-5f5954eb68f6

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-2c0a887

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a97f968f-d5c4-4584-8e2d-10d474abb45d

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-cde3053

@markmandel markmandel added kind/feature New features for Agones area/tests Unit tests, e2e tests, anything to make sure things don't break area/performance Anything to do with Agones being slow, or making it go faster. labels Feb 21, 2019
To run load tests using Locust on your local machine:

```
docker build -t locust-files .
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add the kubectl proxy & command

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


```
docker build -t locust-files .
docker run --rm --network="host" -e "TARGET_HOST=http://127.0.0.1:8001" locust-files:latest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity are you running on linux ? Last time I checked network host on MacOS wasn't working.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Yes, I was running on Linux.

I'm thinking to add to the documentation that for macOS and Windows we can use the special DNS name host.docker.internal. Does that sound good?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this to the README. Please let me know if it is sufficient.

Copy link
Collaborator

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think it would be better with a single image.

# TAKEN FROM: https://github.com/GoogleCloudPlatform/distributed-load-testing-using-kubernetes/blob/master/docker-image/locust-tasks/run.s

LOCUST="/usr/local/bin/locust"
LOCUS_OPTS="-f locustfile.py --host=$TARGET_HOST"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use a single image and with the entrypoint script your could switch from one plan to another(either via a flag or env).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean a single Dockerfile for both tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the Dockerfile and the structure so that we have a single image. It's more flat and more readable now. Thanks for the suggestion.

test/load/gameserver-allocation/locust-files/locustfile.py Outdated Show resolved Hide resolved
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 212a9e0a-d879-40ae-af40-3cf3e60071c8

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-39ca930

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: a3cc9957-4b29-47dd-b610-7b4ac6b4cf29

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

```

The above will build a Docker container to install Locust, Grafana, and Graphite and will configure
them. The test uses the HTTP proxy on the local machine to access the k8s API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious: is this not going to limit the perceived performance in some way (I would imagine proxy is probably not optimized for speed)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, it might. I will improve that in future iterations.

RUN pip install locustio
EXPOSE 8089 5557 5558

RUN mkdir /etc/service/locust
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: /etc is typically for configuration files, not for executables

how about /opt/locust/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't work. The image that I am using in this Dockerfile (https://hub.docker.com/r/hopsoft/graphite-statsd) is built from phusion which requires specific configuration when a new daemon is added. This includes an executable that runs the daemon to the /etc/service/ directory: https://github.com/phusion/baseimage-docker#adding-additional-daemons

def scaleUpFleet(self):
# Create a fleet.
initial_size = 1
start_time = time.time()
Copy link
Contributor

@jkowalski jkowalski Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: format 'payload' as multiline? or perhaps put those things in JSON files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatted as multiline for now. I will later move these to JSON files but not in this PR since it needs some parsing to build the payload.

RUN pip install locustio
EXPOSE 8089 5557 5558

RUN mkdir /etc/service/locust
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here about /etc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: e65724a4-9f73-444d-9f76-d47ebccbfe2b

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-7a34cd9

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 734702be-07a4-4e94-bc16-1033b4212456

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-09b2443

Copy link
Collaborator

@aLekSer aLekSer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, there are some crucial and not so crucial pep8 violations. Please run pep8 util.

response = self.client.put(selfLink, data=json.dumps(payload), headers=headers)
self.waitForScaling(selfLink, 0)
total_time = int((time.time() - start_time) * 1000)
events.request_success.fire(request_type="fleet_scaling_down", name="fleet_scaling_down", response_time=total_time, response_length=0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pm7h Can you please run pep8 util on your python code. For instance this lines too long:
E501 line too long (132 > 79 characters)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pm7h

break
if (total_time > DEADLINE):
print "Fleet did not scale up in time"
events.request_success.fire(request_type="fleet_scaling_timeout", name="fleet_scaling_timeout", response_time=total_time * 1000, response_length=0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above:
E501 line too long (152 > 79 characters)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

}
headers = {'content-type': 'application/json'}
response = self.client.post("/apis/stable.agones.dev/v1alpha1/namespaces/default/fleets", data=json.dumps(payload), headers=headers)
response_json = response.json()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run pep8. Install it using pip install pep8.
E111 indentation is not a multiple of four

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

response = self.client.get(selfLink)
response_json = response.json()
status = response_json.get('status')
if status != None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E711 comparison to None should be 'if cond is not None:'

Suggested change
if status != None:
if status is not None:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

break
elif (game_server_state == "UnAllocated"):
total_time = int((time.time() - start_time) * 1000)
events.request_success.fire(request_type="GameServerUnAllocated", name="GameServerUnAllocated", response_time=total_time, response_length=0)
Copy link
Collaborator

@aLekSer aLekSer Feb 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in the other file. This file violates pep8 stadard. Line is too long, should be split into multiple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Thanks.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: d0d50340-f204-4eed-8601-5f889e5b4320

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-5cabfcb

Copy link
Collaborator

@aLekSer aLekSer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pm7h ,
Tested these two files with pycodestyle also (pep8 util seems to be deprecated), now them are fine.

@markmandel
Copy link
Member

markmandel commented Mar 7, 2019

Noticed this sitting here for a while - tbh, I was waiting on either @Kuqd or @jkowalski to approve this - since they are working on performance way more than me 😄

Happy to download and take it for a spin if nobody is going to jump on this?

Adding Locust tests.

Adding command to start k8s proxy to the READMe file.

Changing the Dockerfile and the directories so that we have a single
image and a more flat sctucture.

Small improvements to Python files for better readability.

Fixed indentation.

Fixed pep8 errors.
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 6d376c50-d087-43ff-9e1a-5374c260e027

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-7aef695

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 7fcbf20c-00e4-4308-ad14-54b56339b457

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/611/head:pr_611 && git checkout pr_611
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.9.0-ec6a49e

@jkowalski jkowalski merged commit 8002ed8 into googleforgames:master Mar 8, 2019
@markmandel markmandel added this to the 0.9.0 milestone Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/performance Anything to do with Agones being slow, or making it go faster. area/tests Unit tests, e2e tests, anything to make sure things don't break kind/feature New features for Agones
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants