Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Support For URL Grouping? #114

Closed
dvngnt opened this issue Jun 24, 2021 · 15 comments
Closed

Support For URL Grouping? #114

dvngnt opened this issue Jun 24, 2021 · 15 comments

Comments

@dvngnt
Copy link

dvngnt commented Jun 24, 2021

There are instances where identical requests or similar requests should be grouped, e.g., Logging in.
I'm not aware of a way to add this metadata to postman or a converted script, but It would be a great QoL feature for running k6 in the cloud.

image

image

@thim81
Copy link
Contributor

thim81 commented Jun 26, 2021

In postman, you can define folders or tags. Is this a sufficient “grouping” manner?

@thim81
Copy link
Contributor

thim81 commented Jun 28, 2021

@dvngnt If you use the folders in Postman, postman-to-k6 will generate the script in "groups" based on the folders.

CleanShot 2021-06-28 at 14 38 07@2x

@dvngnt
Copy link
Author

dvngnt commented Jun 28, 2021

Thanks for the solutions @thim81 ; I didn't know about the folder to group option. This will be useful when the requests are consecutive.

The other instance I was thinking about is say I have requests A, B, C. Requests A and C should be grouped, but not B. Is it possible to surround A and C with the same group value for k6 to aggregate?

@thim81
Copy link
Contributor

thim81 commented Jun 28, 2021

If you organise them like that in Postman, they will be grouped like that in K6.

the postman-to-k6 package converts your Postman collection into a K6 script.

If you use --seperate parameter (https://github.com/k6io/postman-to-k6#separate)

The package will create seperate scripts per postman request, in seperate files.
In the K6 script file you can find the references to each individual request and this will allow you play around with the order as you wish.

@simskij did a great job when creating this package since it is really powerful and flexible for converting your postman to K6.

@dvngnt
Copy link
Author

dvngnt commented Jun 28, 2021

@thim81 I'm currently working with the split output. I see that it's possible to surround requests with a group inside the default function. This is a workable solution Thank you!, but it might more modular for the data to live in the request itself.

Do you know if it's possible to add that tag/group to the individual request.js file something like https://k6.io/docs/using-k6/http-requests/#url-grouping

@thim81
Copy link
Contributor

thim81 commented Jun 28, 2021

Could you share what you want to do with it? So that I can beter understand the use-case?

Is the tagging for reporting purposes? Or for something else?

@dvngnt
Copy link
Author

dvngnt commented Jun 28, 2021

The application I'm testing has a few APIs that will call every 30 sec. It's the exact same request so I duplicate the request in postman and place it throughout the collection. When I covert the collection to a k6 script, it would be cool to have that duplicated request be a part of its own group.

One possible way might be surrounding the call with a group whenever the request is called, but it might be more efficient to add that group or tag to the request itself. so the actual k6 script is cleaner.

The next step would include removing the duplicate requests.js and just call the first one, but that's a separate code cleaning issue.

@dvngnt
Copy link
Author

dvngnt commented Jun 29, 2021

@thim81 folders kinda work, but if you have the same request multiple folders they get grouped together, and maybe on one level they should, but it would be nice to have a tag that works across groups for metrics.

@thim81
Copy link
Contributor

thim81 commented Jun 29, 2021

@dvngnt Since postman-to-k6 is based on the Postman collection data, what would you use within the Postman collection to base your tag.name on?

Lets take this example:
CleanShot 2021-06-29 at 09 13 12
CleanShot 2021-06-29 at 09 13 34

What would you expect as K6 tag:

http.get(`http://example.com/crm/leads?raw=true&cursor=&limit=20`, {
    tags: { name: '?????' },
  });

We have in Postman the following info available:

  • Folder name (Leads)
  • Request name (List Leads)
  • Request path ({{baseUrl}}/crm/leads?raw=true&cursor=&limit=20)

There is no option to "tag" a request with metadata in Postman, so we have to find a useful convention.

Request name or request path seem very logical, resulting in a K6 tag like so:

http.get(`http://example.com/crm/leads?raw=true&cursor=&limit=20`, {
    tags: { name: 'List Leads' },
  });

@dvngnt
Copy link
Author

dvngnt commented Jun 30, 2021

@thim81 good point, postman doesn't have a great tagging solution for k6 to plug into.

I'm managing with the folder solution.

Thanks

@dvngnt dvngnt closed this as completed Jun 30, 2021
@thim81
Copy link
Contributor

thim81 commented Jun 30, 2021

@dvngnt I m looking to create a PR to have some sort or K6 tag generation in place in K6, for reporting grouping.

Your use-case was more around request organisation? Or also for reporting?

@dvngnt
Copy link
Author

dvngnt commented Jul 1, 2021

@thim81 i would say more for reporting. Groups and folders seem to work well for organizations.

There are times where a request might be /user/userId where id is some unique integer and k6 complains about too many metrics and will suggest URL grouping. Which I don't believe folders will solve.

@thim81
Copy link
Contributor

thim81 commented Jul 1, 2021

@dvngnt it matches with my reporting use-case.

would you consider any of the following info available in Postman, as useful for a k6 reporting tag?

  • Folder name (Leads)
  • Request name (List Leads)
  • Request path ({{baseUrl}}/crm/leads?raw=true&cursor=&limit=20)

or something else?

@dvngnt
Copy link
Author

dvngnt commented Jul 2, 2021

@thim81 I'm thinking the request name is the most useful. I think by default users will give a request a name before creating a folder.

@thim81
Copy link
Contributor

thim81 commented Sep 18, 2021

@dvngnt

In the meantime, I faced the same issue and some others (#125). After some thought, I found a way and created a PR and a forked NPM package version that contains the feature to set K6 request tags. Have a look at readme: https://www.npmjs.com/package/@apideck/postman-to-k6#k6-request-tag that explains how to use it.

Replace in your packages.json:

"dependencies": {
    "postman-to-k6": "^1.5.0"
  }

to

"dependencies": {
    "@apideck/postman-to-k6": "^1.8.0"
  }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants