load-testing - 如何停止在 K6 中复制脚本?
问题描述
我必须在 K6 中为一个应用程序编写大约 20 个不同的脚本。而且这些脚本中的大多数都包含常见的功能,如登录、选择一些选项等......
那么有没有更好的方法来编写 K6 脚本而不复制这些常用功能呢?我们可以在某处实现通用方法并在默认函数或类似的函数中执行它吗?
解决方案
您可以编写自己的模块包含常用功能,然后导入它们:
$ cat index.js
import { hello_world } from './modules/module.js';
export default function() {
hello_world();
}
$ cat module.js
export function hello_world() {
console.log("Hello world");
}
你可以在这里阅读更多细节。
推荐阅读
- ignite - 点燃节点无法加入集群,无限期等待协调器响应
- r - 错误:找到包 'StanHeaders' 2.18.1,但 'rstan' 需要 > 2.18.1
- regex - 正则表达式 - 删除除单个空格以外的特殊字符
- c# - 如何修复无法从 UiThread 上的 EditText.SetText 中的包裹中读取输入通道文件描述符
- type-conversion - 将 arma::mat 邻接矩阵转换为 C (Rcpp) 中的 igraph 图
- css - 如何使用媒体查询将 div 的固定宽度更改为响应式扩展潜水?
- variables - 如何在另一个类中使用一个类的变量?
- java - 使用 AlarmManager 设置一些通知并取消其中一个
- javascript - 可以从html5或者flash player中获取值吗?(百家乐机器人)
- kubernetes - 调整 Kubernetes Job 行为,保留 kubernetes pod 日志