小编Ale*_*kin的帖子

如果POST数据较大,则GCP HTTP负载平衡器将返回502错误

我们有一个API服务器,正在使用HTTP负载平衡器。我们发现,如果HTTP请求的数据很大,则L7负载平衡器将返回502错误。

我们已经确认,在不使用负载均衡器的情况下访问API时,它可以工作(直接访问API服务器。)

这个问题可能是类似的问题。HTTP负载平衡器削减了大型请求正文的一部分

有人说使用L4网络负载平衡器是一种可能的解决方案,但由于某些原因,例如基于URL的负载平衡和跨区域负载平衡,我们不希望使用它。

// Response OK (data size is 1024)
curl -H "Content-Type: application/json" -X POST -d '{"xx": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}' https://xxxxxxxxxxxxxxx.com/xx/xxxxxxxxxxxx/xxxxxxxxx

// Response NG (data size is 1025)
curl -H "Content-Type: application/json" -X POST -d '{"xx": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}' https://xxxxxxxxxxxxxxx.com/xx/xxxxxxxxxxxx/xxxxxxxxx
Run Code Online (Sandbox Code Playgroud)

LB对发布数据的大小似乎有一些限制。测试显示限制约为1024个字节。


更新1

@chaintng 救了我。链接的帖子上有人说,如果帖子数据超过1024字节,则会curl添加"Expect: 100-continue Header"

// Response NG (data size is 1025. without "Expect: ")
curl -H "Content-Type: application/json" -X POST -d '{"xx": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"}' https://xxxxxxxxxxxxxxx.com/xx/xxxxxxxxxxxx/xxxxxxxxx

// Response OK (data size is 1025. with "Expect: ") …
Run Code Online (Sandbox Code Playgroud)

google-app-engine google-cloud-platform google-cloud-http-load-balancer

5
推荐指数
1
解决办法
1444
查看次数

Testcafe Vue选择器无法获取Vue组件

我正在使用Testcafe Vue选择器在Vue应用程序上执行e2e测试,但看起来我无法抓住我的任何组件:

1) An error occurred in getVue code:

      TypeError: Cannot read property '__vue__' of undefined
Run Code Online (Sandbox Code Playgroud)

这是我创建的样本测试:

import VueSelector from "testcafe-vue-selectors";
import { Selector } from 'testcafe';

fixture `Getting Started`
    .page `http://localhost:8081/`;

test('test totalValue format', async t => {
    const totalValue = VueSelector("total-value");

    await t
        .click("#total-value-toggle-format")
        .expect(totalValue.getVue(({ props }) => props.formatProperty)).eql(null)
});
Run Code Online (Sandbox Code Playgroud)

我的组件树的结构如下:

Root
|___App
    |___Hello
        |___TotalValue
Run Code Online (Sandbox Code Playgroud)

然后像这样导入组件:

  "total-value": TotalValue,
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?

编辑:这是我测试组件的页面

<template>
    <div class="hello">
        <div class="component-wrapper">
              <total-value
                  :value="totalValueValue"
                  :formatProperty="computedFormatNumber">
              </total-value>
        </div>
    </div>
</template>

<script>   
import TotalValue from "../../core/TotalValue";

export …
Run Code Online (Sandbox Code Playgroud)

javascript testing automated-tests vue.js testcafe

5
推荐指数
1
解决办法
439
查看次数

使用async / await将参数传递给函数

我正在尝试将参数传递给使用异步/等待的函数。我已经像这样定义了我的功能

// common.js

export const myAsyncFunc = async (t, textA, textB) => {
  await t
    .typeText('#input-1', textA)
    .typeText('#input-2', textB);
};
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试将此函数导入另一个文件时,t由于以下原因,我无法传递它t is not defined

// index.js

import { myAsyncFunc } from './common'

myAsyncFunc(t, textA, textB)
Run Code Online (Sandbox Code Playgroud)

是否可以通过async / await 传递我textAtextB参数(可能通过curring或其他方式)?

编辑:因此,这正在作为测试咖啡馆库的一部分运行。看起来好像t来自何时testcafe chrome client/__tests__/运行,而不是导入到common.js文件中。

javascript testing asynchronous async-await testcafe

5
推荐指数
1
解决办法
6421
查看次数

条件测试绕过Testcafe弹出窗口

我正在使用testcafe在电子商务页面中运行一些测试,但是随机弹出会破坏该测试。当它出现在窗口中时,Testcafe无法单击下一个选择器并继续进行测试,然后失败。

目前,我正在使用.js文件来保存选择器,例如:

    import { Selector } from 'testcafe';

    export default class Checkout {
        constructor () {
            //address
            this.addressName = Selector('input#CC-checkoutCepAddressBook-sfirstname');
            this.addressLastname = Selector('input#CC-checkoutCepAddressBook-slastname');

//Rest of selectors...
}
Run Code Online (Sandbox Code Playgroud)

然后,将它们导入另一个.js并声明测试,例如函数:

import { ClientFunction } from 'testcafe';
import { Selector } from 'testcafe';
import Fixture from '../../../DesktopModel/Chrome/fixture.js';
import Home from '../../../DesktopModel/Chrome/home.js';
import Cart from '../../../DesktopModel/Chrome/cart.js';
...
const fixtureUrlBase = new Fixture();
const home = new Home();
const pdp = new Pdp();
const cart = new Cart();
...

export async function checkoutLoggedBoleto(t) {

await …
Run Code Online (Sandbox Code Playgroud)

testing automated-tests conditional-statements e2e-testing testcafe

5
推荐指数
1
解决办法
839
查看次数

甚至跨浏览器一一执行测试

我正在用testcafe针对不支持并发的测试后端编写E2E测试,即,如果两个测试并行执行,则测试后端会崩溃。

当我仅针对一个浏览器进行测试时,测试将按顺序执行。但是,当我指定多个浏览器时,测试将按浏览器顺序运行,但是测试会同时在每个浏览器中启动。

我希望testcafe首先在一个浏览器中执行所有测试,然后打开下一个浏览器并在其中执行所有测试,依此类推。

这可能吗?

javascript testing automated-tests typescript testcafe

5
推荐指数
1
解决办法
268
查看次数

Testcafe .presskey 用于多次按下

我正在尝试编写 TestCafe Javascript 来测试使用键盘作为唯一导航的网页(即“选项卡”)。

TestCafe 运行这些测试,但它们运行得非常快(最多 5 秒),屏幕上没有任何反应。所以我想知道它是否真的有效。

最重要的是,我试图找到一种方法来干掉我的代码。从我在文档中读到的内容来看,每次我想要按下一个键时,我都需要调用 .pressKey('tab')。如果我需要连续点击“tab”5 次,我的代码中有 5 行。有没有办法消除这种不必要的重复?

谢谢!

javascript testing automated-tests e2e-testing testcafe

5
推荐指数
1
解决办法
880
查看次数

在gitlab CI中运行testcafe失败

我正在尝试在gitlab的CI管道中运行端到端测试(使用testcafe)。但是我遇到以下错误:

ERROR The Firefox 52.0.0 / Linux 0.0.0 browser disconnected. This problem may appear when a browser hangs or is closed, or due to network issues.
Run Code Online (Sandbox Code Playgroud)

我的.gitlab-ci.yml如下:

stages:
  - test

before_script:
    - apt-get update -yqqq
    - apt-get install -y xvfb
    - apt-get install iceweasel -yqq
    - Xvfb :99 -ac &
    - export DISPLAY=:99

test-frontend:  
  image: node:7.7.4
  stage: test
  script: 
    - npm install
    - npm install -g testcafe@0.19.2
    - testcafe --list-browsers
    - testcafe firefox e2etests/tests/login.test.js
  tags:
    - vue
Run Code Online (Sandbox Code Playgroud)

因此,基本上,我将节点docker映像用于测试“阶段”并安装xvfb以“显示”浏览器。

输出ci gitlab: …

automated-tests gitlab testcafe

5
推荐指数
1
解决办法
648
查看次数

Testcafe 无法识别 React

我正在尝试运行我的第一个 testcafe 测试,但它被证明是艰巨的。

testcafe -e chrome client/routes/Lookup/components/testcafe/lookup-test.js

SyntaxError: client/routes/Lookup/components/Lookup.js: Unexpected token (60:8)
  58 |     if (error.status && error.status !== 404) {
  59 |       return (
> 60 |         <NetworkIssues code={error.status} />
     |         ^
  61 |       );
  62 |     }
  63 |
at Object.<anonymous> (client/routes/Lookup/components/testcafe/lookup-test.js:1:1)
Run Code Online (Sandbox Code Playgroud)

查找-test.js

import Lookup from '../Lookup';
import React from 'react';
import { waitForReact } from 'testcafe-react-selectors';


fixture('Lookup Component').page('http://localhost:3000/web/lookup').beforeEach(async () => {
  await waitForReact();
});

test('foo', async (x) => {
  await x
    .typeText('customerName', '07450118811')
    .expect('customerName.value').contains('07450118811');
});
Run Code Online (Sandbox Code Playgroud)

我的代码没有任何错误。它编译并运行良好,并通过了我所有的笑话和酶单元测试。但是我在网上找不到任何有关此的指导。如您所见,忽略错误标志无效。

干杯。

javascript automated-tests reactjs e2e-testing testcafe

5
推荐指数
1
解决办法
873
查看次数

如果某项测试失败,是否有办法保释套件?

我进行了一项测试,如果测试失败,则表明该应用程序存在较大问题。如果一项测试失败,那么运行其余测试将毫无意义。

如果单个测试失败,是否有办法保全套件,但如果该测试通过,则运行所有测试?

web-testing functional-testing e2e-testing testcafe

5
推荐指数
1
解决办法
229
查看次数

如何在regex .match()断言中插入变量?

我想在正则表达式断言中添加一个变量“ example”。

const example = Selector('xyz');

await t.expect(getLocation()).match(/^https:\/\/int-.*.example.com\/en\/example\/-\/  ** HERE SHOULD BE INSERTED A VARIABLE, 'example' ** \/$/)
Run Code Online (Sandbox Code Playgroud)

我该怎么办?

regex automated-tests web-testing e2e-testing testcafe

5
推荐指数
1
解决办法
106
查看次数