Skip to content

Commit e52cd32

Browse files
[test optimization] Fix flakiness in agentless log submission tests (#7602)
1 parent 87707fd commit e52cd32

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

.github/workflows/test-optimization.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ jobs:
4747
with:
4848
version: ${{ matrix.version }}
4949
- uses: ./.github/actions/install
50-
- name: Get latest Playwright version
50+
- name: Get Playwright version from versions package.json
5151
id: playwright-version
5252
run: |
53-
PLAYWRIGHT_VERSION=$(npm view @playwright/test version)
53+
PLAYWRIGHT_VERSION=$(node -p "require('./packages/dd-trace/test/plugins/versions/package.json').dependencies['@playwright/test']")
5454
echo "version=$PLAYWRIGHT_VERSION" >> $GITHUB_OUTPUT
55-
echo "Latest Playwright version: $PLAYWRIGHT_VERSION"
55+
echo "Playwright version: $PLAYWRIGHT_VERSION"
5656
- name: Cache Playwright browsers
5757
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
5858
with:

integration-tests/ci-visibility/automatic-log-submission.spec.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,23 @@ describe('test optimization automatic log submission', () => {
2727
'@playwright/test',
2828
], true)
2929

30-
before(done => {
30+
before(async () => {
3131
cwd = sandboxCwd()
3232
const { NODE_OPTIONS, ...restOfEnv } = process.env
3333
// Install chromium (configured in integration-tests/playwright.config.js)
3434
// *Be advised*: this means that we'll only be using chromium for this test suite
35-
execSync('npx playwright install --with-deps chromium', { cwd, env: restOfEnv, stdio: 'inherit' })
36-
webAppServer.listen(0, () => {
37-
const address = webAppServer.address()
38-
if (!address || typeof address === 'string') {
39-
return done(new Error('Failed to determine web app server port'))
40-
}
41-
webAppPort = address.port
42-
done()
35+
// Must run in before hook: sandbox is created at test time so workflow can't install
36+
execSync('npx playwright install chromium', { cwd, env: restOfEnv, stdio: 'inherit' })
37+
await new Promise((resolve, reject) => {
38+
webAppServer.listen(0, () => {
39+
const address = webAppServer.address()
40+
if (!address || typeof address === 'string') {
41+
reject(new Error('Failed to determine web app server port'))
42+
return
43+
}
44+
webAppPort = address.port
45+
resolve()
46+
})
4347
})
4448
})
4549

0 commit comments

Comments
 (0)