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

Query: Running files as part of webhook instead of embedded script #15

Open
AshDerTest opened this issue Feb 24, 2022 · 4 comments
Open

Comments

@AshDerTest
Copy link
Contributor

Hi

Just a query with regards to the current webhook, is it possible to run predefined js scripts as part of the webhook or is tis limited to running embedded script in the canary yaml?

Current k6 setup:
Main file below to import methods from other files (current example has 1 other file but can be expanded to include more)

//imports
import { test1 } from "./test1.js";

//setup

export const options = {
    vus: 1,
    duration: '30s',
    iterations: 1,
    thresholds: {
    requests: ['count < 100'],
    },
    };

  export default function() {
      test1();
  }

second file test1.js

import http from 'k6/http';
  import { sleep, check } from 'k6';
  import { Counter } from 'k6/metrics';
  
  export const requests = new Counter('http_reqs');

  export default function test1() {
  
  const res = http.get('http://{{ include "test.fullname" . }}-canary.{{- .Release.Namespace }}:{{ .Values.service.port }}');
  
  sleep(1);
  
  const checkRes = check(res, {
  status is 200': (r) => r.status === 200
  });
  }

Not sure if this is a limitation on flagger, helm or is possible to be catered for in the webhook?

@julienduchesne
Copy link
Member

The webhook has to have access to the files. The solution I've thought of is to allow bundling scripts within config maps: #7. It's not done yet though because we are having good success with single files (even extremely large ones)

@AshDerTest
Copy link
Contributor Author

Any idea if or timeline you are looking at to implement this?
Reason I ask is that we have the k6 tests running in pipeline (using the multiple fiiles) and attempting not to duplicate this and paste into single script against flagger during deployment.

@julienduchesne
Copy link
Member

julienduchesne commented Feb 28, 2022

import http from 'k6/http';
import { sleep, check } from 'k6';
import { Counter } from 'k6/metrics';

export const requests = new Counter('http_reqs');

export default function test1() {

const res = http.get('http://{{ include "test.fullname" . }}-canary.{{- .Release.Namespace }}:{{ .Values.service.port }}');

sleep(1);

const checkRes = check(res, {
status is 200': (r) => r.status === 200
});
}

I'm not planning on implementing this soon. Reasons being:

  1. We have some pretty long scripts currently and haven't hit any kind of length limit in the payload yet
  2. It's possible to use a tool like rollup.js to combine js scripts into a single file, if need be

Though, I am open to contributions on this if you'd like to open a PR

@genofire
Copy link

i believe the easies way is to store "./test1.js" into an extra layer of the Containerfile.

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

No branches or pull requests

3 participants