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

[Tests-Only] Add k6 tests for deleting and downloading a file #959

Closed
wants to merge 6 commits into from

Conversation

dpakach
Copy link
Contributor

@dpakach dpakach commented Nov 26, 2020

Add simple K6 tests for

  1. download 100 files simultaneously with 100 Virtual Users
  2. delete 100 files simultaneously with 100 Virtual Users

the number of iterations and VUs can be changed on the test file easily

@dpakach dpakach requested a review from fschade November 26, 2020 11:23
@dpakach dpakach marked this pull request as ready for review November 26, 2020 11:23
@dpakach dpakach self-assigned this Nov 26, 2020
@dpakach dpakach requested a review from phil-davis November 26, 2020 11:24
@dpakach
Copy link
Contributor Author

dpakach commented Nov 26, 2020

@fschade, I have added tests for some simple file operations, I noticed that in the existing tests the created files were not being cleaned up, so I have added that too. currently, all the "VU"'s on the tests are basically the same user (i.e. einstein) sending requests simultaneously, I guess, next, we will have to implement creating different user accounts for different VUs and send request from different user accounts. What do you think, am I on the right track?

tests/k6/src/test-issue-162.ts Outdated Show resolved Hide resolved
tests/k6/src/test-download.ts Show resolved Hide resolved
tests/k6/src/test-delete-file.ts Show resolved Hide resolved
Copy link
Contributor

@fschade fschade left a comment

Choose a reason for hiding this comment

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

found some smaller things, not mandetory but nice to have :)

tests/k6/src/test-delete-file.ts Outdated Show resolved Hide resolved
tests/k6/src/test-download.ts Outdated Show resolved Hide resolved
check(res, {
// status could be either 204(if file was created) of 404(if file was not uploaded)
'status is 204 or 404': () => [204, 404].includes(res.status),
Copy link
Contributor

Choose a reason for hiding this comment

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

in my opinion we should check the 204 and 404 individually and not within one check. Why do we expect 404 at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fschade , when trying with large number of users, the upload requests fail, so some file are not created.
For. eg when trying with 500 vus and 100 iterations I get

 ✗ status is 201
     ↳  78% — ✓ 785 / ✗ 215

Also I could not get the list of failed uploads here from default function, which would be easier.
checking each of them separately still gives error on one of the checks so cant do that either

tests/k6/src/test-delete-file.ts Outdated Show resolved Hide resolved
tests/k6/src/test-delete-file.ts Outdated Show resolved Hide resolved
for (let vu=1; vu <= options.vus; vu++) {
for (let iter=0; iter < options.iterations/options.vus; iter++) {
const res = api.uploadFile(defaults.accounts.einstein, files['kb_50.jpg'], `deletefile_${vu}_${iter}.jpg`)
check(res, {
Copy link
Contributor

Choose a reason for hiding this comment

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

if something goes wrong here it doesnt break and the default export still will run. it could be better do do a breacking check here.

https://k6.io/docs/javascript-api/k6/fail-err

console.log("setup for delete")
for (let vu=1; vu <= options.vus; vu++) {
for (let iter=0; iter < options.iterations/options.vus; iter++) {
const res = api.uploadFile(defaults.accounts.einstein, files['kb_50.jpg'], `deletefile_${vu}_${iter}.jpg`)
Copy link
Contributor

Choose a reason for hiding this comment

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

its easier for later refference to keep the filenames in a shared hash. this whay we can loop over it in future test steps.

// 1. init code

export function setup() {
  const images: string[];
  ...
  return {images} 
}

export default function (data) {
  data.images.forEach(i => console.log(i))
}

export function teardown(data) {
  data.images.forEach(i => console.log(i))
}

@dpakach dpakach force-pushed the k6-tests branch 2 times, most recently from e2c980b to 4db4cfb Compare November 27, 2020 06:28
@phil-davis
Copy link
Contributor

@dpakach there are conflicts. Needs a rebase...

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@phil-davis
Copy link
Contributor

@dpakach more conflicts
what is the status of this PR?
I know that @fschade committed some combinations of "benchmark" tests.

@dpakach
Copy link
Contributor Author

dpakach commented Dec 9, 2020

Many of these tests have been covered in #983, I'll do other tests on a different PR. So closing this for now

@dpakach dpakach closed this Dec 9, 2020
@dpakach dpakach deleted the k6-tests branch January 25, 2021 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants