From 36d59ede07dc6ec82f98412c1e865393337cf5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=2E=20Mert=20Y=C4=B1ld=C4=B1ran?= Date: Wed, 11 May 2022 03:14:01 -0700 Subject: [PATCH] Fix acceptance tests failures caused by fetch 50 and a race in the tests (#1074) * #run_acceptance_tests * Wait 4 seconds after filter submission #run_acceptance_tests * Revert "Wait 4 seconds after filter submission #run_acceptance_tests" This reverts commit 3c20ccfcec752dae564a4a6b3f3eccf1cbd9212b. * Upgrade Basenine version to `v0.8.2` #run_acceptance_tests * #run_acceptance_tests * Revert "Revert "Wait 4 seconds after filter submission #run_acceptance_tests"" This reverts commit f0c595150d02b73c1e6b454b88985d6b419e4cb1. * Reduce the delay to 2 seconds #run_acceptance_tests * Use `cy.wait()` instead of `setTimeout` * #run_acceptance_tests * Increase it to 4 seconds #run_acceptance_tests * #run_acceptance_tests * Wait for a second and pause the stream to preserve the DOM #run_acceptance_tests * Wait in a better place #run_acceptance_tests * Wait `pause-icon` to disappear #run_acceptance_tests * Wait one more second #run_acceptance_tests * Fix `setup.sh` * #run_acceptance_tests * Fix the place of `npm i` call * #run_acceptance_tests * Fix the other workflow as well #run_acceptance_tests * Fix the workflows once more * #run_acceptance_tests * Don't ignore `*/cypress/support` #run_acceptance_tests * Do `npm i` in `setup.sh` #run_acceptance_tests * Wait for at least 4 seconds #run_acceptance_tests * #run_acceptance_tests * Fix #run_acceptance_tests * Comment #run_acceptance_tests * Fix `{alt+enter}` to `{ctrl+enter}` and update the `checkFilter` and `deeperCheck` method signatures #run_acceptance_tests * #run_acceptance_tests * #run_acceptance_tests * Extract it to a function #run_acceptance_tests * Remove `cypress-wait-until` * Revert `.gitignore` #run_acceptance_tests --- .gitignore | 2 +- Dockerfile | 4 +- .../cypress/integration/tests/UiTest.js | 59 +++++++++++-------- agent/go.mod | 2 +- agent/go.sum | 4 +- .../TrafficViewer/TrafficViewer.tsx | 15 +++-- 6 files changed, 51 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 80ee94b3a..4169c6803 100644 --- a/.gitignore +++ b/.gitignore @@ -55,4 +55,4 @@ tap/extensions/*/expect *.editorconfig # Ignore *.log files -*.log \ No newline at end of file +*.log diff --git a/Dockerfile b/Dockerfile index 4923cc9ae..16f3dd8cd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -94,8 +94,8 @@ RUN go build -ldflags="-extldflags=-static -s -w \ -X 'github.com/up9inc/mizu/agent/pkg/version.Ver=${VER}'" -o mizuagent . # Download Basenine executable, verify the sha1sum -ADD https://github.com/up9inc/basenine/releases/download/v0.8.1/basenine_linux_${GOARCH} ./basenine_linux_${GOARCH} -ADD https://github.com/up9inc/basenine/releases/download/v0.8.1/basenine_linux_${GOARCH}.sha256 ./basenine_linux_${GOARCH}.sha256 +ADD https://github.com/up9inc/basenine/releases/download/v0.8.2/basenine_linux_${GOARCH} ./basenine_linux_${GOARCH} +ADD https://github.com/up9inc/basenine/releases/download/v0.8.2/basenine_linux_${GOARCH}.sha256 ./basenine_linux_${GOARCH}.sha256 RUN shasum -a 256 -c basenine_linux_"${GOARCH}".sha256 && \ chmod +x ./basenine_linux_"${GOARCH}" && \ diff --git a/acceptanceTests/cypress/integration/tests/UiTest.js b/acceptanceTests/cypress/integration/tests/UiTest.js index 6b9de5069..70bb39096 100644 --- a/acceptanceTests/cypress/integration/tests/UiTest.js +++ b/acceptanceTests/cypress/integration/tests/UiTest.js @@ -65,70 +65,70 @@ it('right side sanity test', function () { checkIllegalFilter('invalid filter'); checkFilter({ - name: 'http', + filter: 'http', leftSidePath: '> :nth-child(1) > :nth-child(1)', leftSideExpectedText: 'HTTP', rightSidePath: '[title=HTTP]', rightSideExpectedText: 'Hypertext Transfer Protocol -- HTTP/1.1', - applyByEnter: true + applyByCtrlEnter: true }); checkFilter({ - name: 'response.status == 200', + filter: 'response.status == 200', leftSidePath: '[title="Status Code"]', leftSideExpectedText: '200', rightSidePath: '> :nth-child(2) [title="Status Code"]', rightSideExpectedText: '200', - applyByEnter: false + applyByCtrlEnter: false }); if (Cypress.env('shouldCheckSrcAndDest')) { serviceMapCheck(); checkFilter({ - name: 'src.name == ""', + filter: 'src.name == ""', leftSidePath: '[title="Source Name"]', leftSideExpectedText: '[Unresolved]', rightSidePath: '> :nth-child(2) [title="Source Name"]', rightSideExpectedText: '[Unresolved]', - applyByEnter: false + applyByCtrlEnter: false }); checkFilter({ - name: `dst.name == "httpbin.mizu-tests"`, + filter: `dst.name == "httpbin.mizu-tests"`, leftSidePath: '> :nth-child(3) > :nth-child(2) > :nth-child(3) > :nth-child(2)', leftSideExpectedText: 'httpbin.mizu-tests', rightSidePath: '> :nth-child(2) > :nth-child(2) > :nth-child(2) > :nth-child(3) > :nth-child(2)', rightSideExpectedText: 'httpbin.mizu-tests', - applyByEnter: false + applyByCtrlEnter: false }); } checkFilter({ - name: 'request.method == "GET"', + filter: 'request.method == "GET"', leftSidePath: '> :nth-child(3) > :nth-child(1) > :nth-child(1) > :nth-child(2)', leftSideExpectedText: 'GET', rightSidePath: '> :nth-child(2) > :nth-child(2) > :nth-child(1) > :nth-child(1) > :nth-child(2)', rightSideExpectedText: 'GET', - applyByEnter: true + applyByCtrlEnter: true }); checkFilter({ - name: 'request.path == "/get"', + filter: 'request.path == "/get"', leftSidePath: '> :nth-child(3) > :nth-child(1) > :nth-child(2) > :nth-child(2)', leftSideExpectedText: '/get', rightSidePath: '> :nth-child(2) > :nth-child(2) > :nth-child(1) > :nth-child(2) > :nth-child(2)', rightSideExpectedText: '/get', - applyByEnter: false + applyByCtrlEnter: false }); checkFilter({ - name: 'src.ip == "127.0.0.1"', + filter: 'src.ip == "127.0.0.1"', leftSidePath: '[title="Source IP"]', leftSideExpectedText: '127.0.0.1', rightSidePath: '> :nth-child(2) [title="Source IP"]', rightSideExpectedText: '127.0.0.1', - applyByEnter: false + applyByCtrlEnter: false }); checkFilterNoResults('request.method == "POST"'); @@ -182,17 +182,19 @@ function checkIllegalFilter(illegalFilterName) { function checkFilter(filterDetails) { const { - name, + filter, leftSidePath, rightSidePath, rightSideExpectedText, leftSideExpectedText, - applyByEnter + applyByCtrlEnter } = filterDetails; const entriesForDeeperCheck = 5; - it(`checking the filter: ${name}`, function () { + it(`checking the filter: ${filter}`, function () { + waitForFetch50AndPause(); + cy.get('#total-entries').should('not.have.text', '0').then(number => { const totalEntries = number.text(); @@ -200,21 +202,23 @@ function checkFilter(filterDetails) { const element = elem[0]; const entryId = getEntryId(element.id); // checks the hover on the last entry (the only one in DOM at the beginning) - leftOnHoverCheck(entryId, leftSidePath, name); + leftOnHoverCheck(entryId, leftSidePath, filter); cy.get('.w-tc-editor-text').clear(); // applying the filter with alt+enter or with the button - cy.get('.w-tc-editor-text').type(`${name}${applyByEnter ? '{alt+enter}' : ''}`); + cy.get('.w-tc-editor-text').type(`${filter}${applyByCtrlEnter ? '{ctrl+enter}' : ''}`); cy.get('.w-tc-editor').should('have.attr', 'style').and('include', Cypress.env('greenFilterColor')); - if (!applyByEnter) + if (!applyByCtrlEnter) cy.get('[type="submit"]').click(); + waitForFetch50AndPause(); + // only one entry in DOM after filtering, checking all checks on it leftTextCheck(entryId, leftSidePath, leftSideExpectedText); - leftOnHoverCheck(entryId, leftSidePath, name); + leftOnHoverCheck(entryId, leftSidePath, filter); rightTextCheck(rightSidePath, rightSideExpectedText); - rightOnHoverCheck(rightSidePath, name); + rightOnHoverCheck(rightSidePath, filter); checkRightSideResponseBody(); }); @@ -228,7 +232,7 @@ function checkFilter(filterDetails) { }); // making the other 3 checks on the first X entries (longer time for each check) - deeperCheck(leftSidePath, rightSidePath, name, leftSideExpectedText, rightSideExpectedText, entriesForDeeperCheck); + deeperCheck(leftSidePath, rightSidePath, filter, rightSideExpectedText, entriesForDeeperCheck); // reloading then waiting for the entries number to load resizeToNormalMizu(); @@ -238,7 +242,14 @@ function checkFilter(filterDetails) { }); } -function deeperCheck(leftSidePath, rightSidePath, filterName, leftSideExpectedText, rightSideExpectedText, entriesNumToCheck) { +function waitForFetch50AndPause() { + // wait half a second and pause the stream to preserve the DOM + cy.wait(500); + cy.get('#pause-icon').click(); + cy.get('#pause-icon').should('not.be.visible'); +} + +function deeperCheck(leftSidePath, rightSidePath, filterName, rightSideExpectedText, entriesNumToCheck) { cy.get(`#list [id^=entry]`).each((element, index) => { if (index < entriesNumToCheck) { const entryId = getEntryId(element[0].id); diff --git a/agent/go.mod b/agent/go.mod index 37ba205a8..1f7dae7c8 100644 --- a/agent/go.mod +++ b/agent/go.mod @@ -20,7 +20,7 @@ require ( github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/orcaman/concurrent-map v1.0.0 github.com/stretchr/testify v1.7.0 - github.com/up9inc/basenine/client/go v0.0.0-20220508080324-c66c4e1b9337 + github.com/up9inc/basenine/client/go v0.0.0-20220509204026-c37adfc587f4 github.com/up9inc/mizu/logger v0.0.0 github.com/up9inc/mizu/shared v0.0.0 github.com/up9inc/mizu/tap v0.0.0 diff --git a/agent/go.sum b/agent/go.sum index a8a3bbdfc..4b78e088d 100644 --- a/agent/go.sum +++ b/agent/go.sum @@ -683,8 +683,8 @@ github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ= github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw= -github.com/up9inc/basenine/client/go v0.0.0-20220508080324-c66c4e1b9337 h1:eRXRZnojrZyhbiSuGHl0EPvFtWvx1ZMrsY/bSoBzYNE= -github.com/up9inc/basenine/client/go v0.0.0-20220508080324-c66c4e1b9337/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI= +github.com/up9inc/basenine/client/go v0.0.0-20220509204026-c37adfc587f4 h1:nNOrU1HVH0fnaG7GNhxCc8kNPVL035Iix7ihUF6lZT8= +github.com/up9inc/basenine/client/go v0.0.0-20220509204026-c37adfc587f4/go.mod h1:SvJGPoa/6erhUQV7kvHBwM/0x5LyO6XaG2lUaCaKiUI= github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg= github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/wI2L/jsondiff v0.1.1 h1:r2TkoEet7E4JMO5+s1RCY2R0LrNPNHY6hbDeow2hRHw= diff --git a/ui-common/src/components/TrafficViewer/TrafficViewer.tsx b/ui-common/src/components/TrafficViewer/TrafficViewer.tsx index f1eef2124..0506c62a6 100644 --- a/ui-common/src/components/TrafficViewer/TrafficViewer.tsx +++ b/ui-common/src/components/TrafficViewer/TrafficViewer.tsx @@ -245,13 +245,18 @@ export const TrafficViewer: React.FC = ({ {tappingStatus && isShowStatusBar && }
- pause - pause + play + src={playIcon} + onClick={toggleConnection}/>
{getConnectionTitle()} {getConnectionIndicator()}