-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Run/import scripts by URL #152
Comments
This is my proposed implementation for this. When a user does one of the following: import { name } from "path"; $ k6 run [path] There are currently two separate behaviors. On the commandline:
If it's an import:
What I want to do is make this a single, unified behavior:
(Note: all fetching of URLs will be over HTTPS.) Non-local imports will be written relative to the root of the virtual filesystem, e.g.: There should be a way to cache downloaded scripts, but I don't think it should be the default - we're just loading JS files, primarily off various CDNs, the load time shouldn't be much worse than loading an average web page. |
Questions to start with: q1: Wouldn't 3.iv already be covered by 2.i or 2.ii? q2: 3.i A lot of execution in most controlled corporate environments do simply not allow network traffic like that or limit in other ways (bandwidth, request, limited authorization and so on). Wouldn't this lead to scripts "breaking" and needing refactoring so dependencies are always locally loaded? It's probably not an issue we can (or will want to) solve but awareness can change the order of precedence. q3: 3.i & 3.iv Assuming limited public network access it will fail accessing a predefined provider (how are they predefined, ordered and documented?) it will fall back (in order of precedence) to local loading. But executing the same script with public network access at a later time will result in executing different code and can yield vastly different results. So can I override default order of precedence to always make sure I get a known (local or network) resource loaded? q4: Will this be valid for cloud execution? I.e. can a cloud executed script load resources from the network? If so - consider the case that 1000's of tests are executed daily with 10.000's load generators all loading "themostusedstandardlibraryfork6" from let's say github. A couple of weeks of 10k+ daily downloads of the same thing using the same identity from the same place (cloud execution) I suspect it would be raising a lot of interesting flags for the providers. Worst case to the extent execution from the cloud is blacklisted. Cloud execution will also have to take into consideration network usage effects (including costs). |
Ah, case 2 refers specifically local files, so it's the distinction between importing "./jquery.js" and "code.jquery.com/jquery.js". But networks with limited access is an interesting point. We respect proxies from the environment by default, but I kinda want some way of caching remote resources too, I'm just not sure what the best way to do so would be. Caching by default, and offering some way to fetch up-to-date resources? A manual It shouldn't cause a problem for distributed execution though - assuming we go with my proposed implementation (#140), we'd share a single virtual filesystem between all nodes through a key-value store of some description. |
I really like this solution. I'm sure there will be roadblocks somewhere, but it seems very powerful without being hard to understand. I just have a couple of minor questions:
|
Oh, I forgot to reply, but:
|
Some thoughts regarding importing URL resources in the scripts. K6 user will write ES6 code. I think users will expect the import API to mimic the current ES6 import API.
Perhaps, I don’t have enough info but right now, I don’t agree on mixin the import ES6 API with a I am trying to understand how it will work and would like to ask some questions:
http://exploringjs.com/es6/ch_modules.html If you clarify these questions, I could reason more in this subject. But at this moment, I think, it would be better to have different API syntax for different modules (ES6 vs AMD or Browser global) and/or actions (importing vs loader). Quick proposal:
|
@liclac; now, how can I import local ES6 modules? Giving a GoError: Get https://lib/print?_k6=1: dial tcp: lookup lib: no such host
I also tried to place the module file at
GoError: Get https://print?_k6=1: dial tcp: lookup print: no such host |
@liclac Please, could you tell me if the above error is something I am doing wrong or a possible bug. Running like |
import print from "./lib/print.js" |
@liclac Using current master, it doesn't work. I tried another example under samples/REST_API_testsuite/
Should I open a new issue? |
Ah, sorry, I keep glossing this over because it's closed - yeah, please open a new issue |
@ppcano Could you link to the new issue please? Also getting this error. |
@Stumblor This issue was already fixed. You may likely receive the error because of a syntax error. The Modules documentation article has been recently published; it describes the feature, APIs, and examples. There is a related open issue Transforming libraries takes a long time Feedback is appreciated! |
Hi @ppcano - thanks for getting back. Yes I've read both of those. My syntax is: Also tried And All result in variations of:
(........ directory structure omitted, but contains Z:\ so should be file location, not url) I'm using 0.14.0 of the windows 64bit build. |
OH, I see, it's making a faulty assumption that the path separator is always /, but on Windows, it's \, leading it to construct faulty paths. Could you make a new issue about this? |
Sure will do |
Sorry to write in a closed issue, but is this taking into consideration Node.js modules? I have just opened an issue (#360) |
Something we talked about last week is to allow you to do something like:
As well as:
Being able to import stuff from URLs is one of my favorite Go features, and I'm 100% behind introducing it to k6. #136 was a prerequisite for doing this in a sane way, I'd like to get #137 done first as well to get an easier point of integration + avoid duplicating work.
The catch of this is that we'd pretty much have to kill the JS runner, unless we want to change the syntax for it to something like
k6 run GET http://example.com/
… but honestly, I personally wouldn't miss it.The text was updated successfully, but these errors were encountered: