Skip to content

Fix for https://github.com/Nordstrom/artillery-plugin-aws-sigv4/issues/13 #14

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

Closed
wants to merge 2 commits into from

Conversation

galvinhsiu
Copy link

Due to changes in artillery in the linked issue above, templating needs to be run prior to the calculation of the AWS V4 signature. The current newest stable branch of artillery triggers beforeRequest prior to template / variable substitution.

Took the changes from the artillery core (engine_util) and moved over the relevant functions to make it work. Ran through tests again execute-api and confirmed that the generated signatures are correct.

@erikerikson
Copy link
Contributor

You would need to satisfy the linter but copying artillery implementation into this tool doesn't seem like the right solution here. @hassy has a set of issues that his breaking changes have caused. I have escalated that issue out of the deprecated artillery-core repository into an issue on the main artillery repository.

@galvinhsiu
Copy link
Author

@erikerikson agreed that if this can be fixed on artillery-core this would be the more ideal fix (beforeTemplate callback?).

Fixed the linter issues, will keep this PR open until artillery-core has been patched.

@erikerikson
Copy link
Contributor

Thank you very much for offering this contribution. It is much appreciated!

Sorry for the state of things.

@kenshih
Copy link

kenshih commented May 17, 2019

hello!
Just checking in, I've noticed what I think is the same problem with this plugin.
Is the PR still under consideration or ready to be merged, perhaps?
Hope this finds you well!
Ken

@gwsii
Copy link
Contributor

gwsii commented May 20, 2019

@kenshih I've not had the time myself to look at this specific issue, but perhaps the changes in version 0.4.0 might resolve this as there was a move from artillery-core to our private branch of artillery which may properly pre-process these variables?

@vadivelselvaraj
Copy link

vadivelselvaraj commented Aug 1, 2019

@galvinhsiu I tried using your PR for my below template(where template vars are within the json section. Note: The issue happens for template vars within json, body or url sections) and it works only for 3 requests out of 60 that got fired. So, I guess the only way to properly fix this issue is to do the pre-processing in artillery-core.

config:
  plugins:
    aws-sigv4:
      serviceName: sagemaker
    cloudwatch:
      namespace: "sagemaker-map-example-loadtest"
  target: https://runtime.sagemaker.us-west-2.amazonaws.com
  phases:
    - duration: 10
      arrivalRate: 2
      rampTo: 6
      name: Warmup
    - duration: 10
      arrivalRate: 6
      rampTo: 8
      name: Max Load
scenarios:
  - name: Invoke Sagemaker endpoint with random args
    flow:
      - post:
          beforeRequest: addAmazonSignatureV4
          headers:
            content-type: application/json
          url: /endpoints/Endpoint-fKDldNe2mm4J/invocations
          json:
            hotel_cluster_id: "{{ $randomNumber(1, 20) }}"
            top_n: 5

My repo with your PR changes: https://github.com/vadivelselvaraj/artillery-plugin-aws-sigv4. I'd to use git+https://github.com/vadivelselvaraj/artillery-plugin-aws-sigv4.git in my package.json to pull my version of artillery-plugin-aws-sigv4 .

@gwsii Do you know when the pre-processing logic would be included in the public version of artillery-core?

@vadivelselvaraj
Copy link

Just found that artillery-core is no more and that's been merged to artillery when the monorepo conversion happened. I think a clean fix would be to add another stage called afterTemplateVarsSubstitution so that I don't break the current test cases as well as handle this as a one-off scenario. Will do this in my private fork here -- https://github.com/vadivelselvaraj/artillery

@vadivelselvaraj
Copy link

Added the afterTemplateVarsSubstitution feature in https://github.com/vadivelselvaraj/artillery. If anyone's looking out to try that out, feel free to add "artillery": "git+https://github.com/vadivelselvaraj/artillery.git#048ef80f86217ec05016f4964ae1bcd078e571ce", to the dependencies section of the package.json

An example script would be the below.

config:
  plugins:
    aws-sigv4:
      serviceName: sagemaker
    cloudwatch:
      namespace: "sagemaker-map-example-loadtest"
  target: https://runtime.sagemaker.us-west-2.amazonaws.com
  phases:
    - duration: 10
      arrivalRate: 2
      rampTo: 6
      name: Warmup
    - duration: 10
      arrivalRate: 6
      rampTo: 8
      name: Max Load
scenarios:
  - name: Invoke Sagemaker endpoint with random args
    flow:
      - post:
          afterTemplateVarsSubstitution: addAmazonSignatureV4
          headers:
            content-type: application/json
          url: /endpoints/Endpoint-fKDldNe2mm4J/invocations
          json:
            hotel_cluster_id: "{{ $randomNumber(1, 20) }}"
            top_n: 5

@venumadhavn
Copy link

afterTemplateVarsSubstitution

Hi, Did you have to have the instance aws profile creds to run the above. I have instance profile creds but getting an error "Missing Authentication Token"

@gwsii
Copy link
Contributor

gwsii commented Sep 11, 2020

Closing this MR as there is another one which fixes #13

@gwsii gwsii closed this Sep 11, 2020
@trademark18
Copy link

I was unable to get anything to work until using @vadivelselvaraj fork of artillery. It seems like the related PR's have been closed without merging. I assume it's an issue with artillery itself since I was able to use the regular latest (v0.0.5) of this plugin.

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.

8 participants