Skip to content

Commit

Permalink
Merge pull request #230 from fingerprintjs/rc
Browse files Browse the repository at this point in the history
Release v1.4.1-rc.2
  • Loading branch information
TheUnderScorer authored Jun 25, 2024
2 parents 1bd77f0 + 60ba821 commit 6c3b657
Show file tree
Hide file tree
Showing 26 changed files with 2,043 additions and 1,952 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
name: Build project and run CI checks
uses: fingerprintjs/dx-team-toolkit/.github/workflows/build-typescript-project.yml@v1
with:
nodeVersion: 16
nodeVersion: 18
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-workspace-root-check=true
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
## [1.4.1-rc.2](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/compare/v1.4.1-rc.1...v1.4.1-rc.2) (2024-06-20)


### Bug Fixes

* fix broken mgmt function when using Node20 runtime ([a22e351](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/a22e3517dec67dc0b8bbf5c0755560ee23ba3b20))

## [1.4.1-rc.2](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/compare/v1.4.1-rc.1...v1.4.1-rc.2) (2024-06-20)


### Bug Fixes

* fix broken mgmt function when using Node20 runtime ([a22e351](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/a22e3517dec67dc0b8bbf5c0755560ee23ba3b20))

## [1.4.1-rc.1](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/compare/v1.4.0...v1.4.1-rc.1) (2024-06-19)


### Bug Fixes

* don't use `host` header for determining request url ([639602e](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/639602e06beae4433a06f32357d6ccdd4488486d))
* omit cookies when sending request to CDN ([c7f3783](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/c7f3783280ed4c87d33e938bc19446c3c408f14f))
* preserve query parameters for agent request ([49eb9c7](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/49eb9c7fd1ed51baae67ac652fc085fbc3c7e7bf))
* provide correct fpjs-proxy-forwarded-host header when using frontdoor ([341094f](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/341094f7b3f8ba3e67b88503b90089ce189b94e2))
* rely only on non-spoofable `x-azure-socketip` for resolving client ip ([7f818ca](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/7f818ca38e9ffd6d6b88e7757be1da66d8c9581b))
* remove cookies for browser cache requests ([4329da6](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/4329da66fdba1b152f7195b8eaca259c2c34860b))
* set cookies to undefined if _iidt cookie is not present in ingress request ([554b1e6](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/554b1e6876bf0bb8fb1f0fe445fc5875a27126d7))
* simplify cookie parsing ([37852fd](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/37852fd1a27f685413730fa5f6b92d71a8207fd3))
* strip port from client ip ([0ccf5a2](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/0ccf5a218badba417a704136b521a89f34724c01))
* use x-azure-socketip first for resolving client ip ([4e0db7b](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/4e0db7b07530c2542130e87a0cefc78350a5bebf))


### Build System

* **deps:** bump @azure/identity from 4.0.1 to 4.2.1 ([d6bad44](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/commit/d6bad442dfa95af4fc89baca8a636f580daeeed5))

## [1.4.0](https://github.com/fingerprintjs/fingerprint-pro-azure-integration/compare/v1.3.0...v1.4.0) (2024-04-08)


Expand Down
111 changes: 57 additions & 54 deletions azure-pipelines-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,63 @@ pool:
variables:
TAG: $[replace(variables['Build.SourceBranch'], 'refs/tags/', '')]

steps:
- script: echo $TAG
displayName: 'Output tag'
env:
TAG: $(TAG)
- script: npm install pnpm@8 -g && pnpm install && pnpm exec playwright install
displayName: 'Install dependencies'
- script: pnpm exec ts-node scripts/downloadGithubReleasePackage.ts
displayName: 'Download release artifact from GitHub'
env:
TAG: $(TAG)
- script: pnpm build:example-website
displayName: 'Build website'
env:
VITE_API_KEY: $(API_KEY)
VITE_ENDPOINT: $(VITE_ENDPOINT)
VITE_SCRIPT_URL_PATTERN: $(VITE_SCRIPT_URL_PATTERN)
NODE_OPTIONS: "--max_old_space_size=16384"
jobs:
- job: rc_e2e
timeoutInMinutes: 120
steps:
- script: echo $TAG
displayName: 'Output tag'
env:
TAG: $(TAG)
- script: npm install pnpm@8 -g && pnpm install && pnpm exec playwright install
displayName: 'Install dependencies'
- script: pnpm exec ts-node scripts/downloadGithubReleasePackage.ts
displayName: 'Download release artifact from GitHub'
env:
TAG: $(TAG)
- script: pnpm build:example-website
displayName: 'Build website'
env:
VITE_API_KEY: $(API_KEY)
VITE_ENDPOINT: $(VITE_ENDPOINT)
VITE_SCRIPT_URL_PATTERN: $(VITE_SCRIPT_URL_PATTERN)
NODE_OPTIONS: "--max_old_space_size=16384"

- task: AzureCLI@2
displayName: 'Deploy infrastructure'
env:
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME)
AZURE_STORAGE_CONTAINER_NAME: $(AZURE_STORAGE_CONTAINER_NAME)
AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
FPJS_PRE_SHARED_SECRET: $(FPJS_PRE_SHARED_SECRET)
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'pnpm e2e-deploy-infra'
- task: AzureCLI@2
displayName: 'Deploy infrastructure'
env:
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME)
AZURE_STORAGE_CONTAINER_NAME: $(AZURE_STORAGE_CONTAINER_NAME)
AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
FPJS_PRE_SHARED_SECRET: $(FPJS_PRE_SHARED_SECRET)
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'pnpm e2e-deploy-infra'

- task: AzureCLI@2
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'pnpm test:e2e'
displayName: 'Run e2e tests'
env:
CI: 'true'
- task: AzureCLI@2
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'pnpm test:e2e'
displayName: 'Run e2e tests'
env:
CI: 'true'

- task: AzureCLI@2
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'pnpm e2e-destroy-infra'
displayName: 'Destroy infrastructure'
condition: always()
env:
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME)
AZURE_STORAGE_CONTAINER_NAME: $(AZURE_STORAGE_CONTAINER_NAME)
AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
FPJS_PRE_SHARED_SECRET: $(FPJS_PRE_SHARED_SECRET)
- task: AzureCLI@2
inputs:
azureSubscription: 'azure-proxy-integration-e2e-tests'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: 'pnpm e2e-destroy-infra'
displayName: 'Destroy infrastructure'
condition: always()
env:
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME)
AZURE_STORAGE_CONTAINER_NAME: $(AZURE_STORAGE_CONTAINER_NAME)
AZURE_STORAGE_RESOURCE_GROUP: $(AZURE_STORAGE_RESOURCE_GROUP)
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
FPJS_PRE_SHARED_SECRET: $(FPJS_PRE_SHARED_SECRET)
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pool:

jobs:
- job: mockE2E
timeoutInMinutes: 120
steps:
- script: npm install pnpm@8 -g && pnpm install && pnpm exec playwright install
displayName: 'Install dependencies'
Expand Down Expand Up @@ -79,6 +80,7 @@ jobs:


- job: E2E
timeoutInMinutes: 120
steps:
- script: npm install pnpm@8 -g && pnpm install && npx playwright install
displayName: 'Install dependencies'
Expand Down
15 changes: 12 additions & 3 deletions e2e/infra/frontdoor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { KnownSessionAffinityEnabledState } from '@azure/arm-frontdoor'
import invariant from 'tiny-invariant'
import { ExponentialBackoff, handleAll, retry } from 'cockatiel'
import { wait } from '../../shared/wait'

export interface ProvisionFrontDoorParams {
resourceGroup: string
Expand Down Expand Up @@ -155,6 +156,9 @@ export async function provisionFrontDoor({
}
}

// 10 minutes
const ADDITIONAL_WAIT = 600_000

async function waitForFrontDoor(url: string) {
console.info('Waiting for front door to be ready...', url)

Expand All @@ -166,7 +170,7 @@ async function waitForFrontDoor(url: string) {
maxAttempts: 40,
})

return policy.execute(async ({ attempt }) => {
await policy.execute(async ({ attempt }) => {
if (attempt > 1) {
console.info(`Attempt ${attempt}...`)
}
Expand All @@ -181,7 +185,12 @@ async function waitForFrontDoor(url: string) {
if (text.includes('Page not found')) {
throw new Error('Page not found')
}

console.log('Frontdoor is ready!')
})

console.info(
`Frontdoor is ready! Waiting additional ${ADDITIONAL_WAIT / 1000} seconds to make sure it is fully operational...`
)

// Wait additional ADDITIONAL_WAIT ms, to make sure that frontdoor is fully ready. Otherwise it might cause flaky tests.
await wait(ADDITIONAL_WAIT)
}
1 change: 0 additions & 1 deletion e2e/infra/infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export async function deployE2EInfrastructure({
return {
waitForFrontDoor,
testInfo: {
resourceGroup,
frontdoorUrl,
functionAppUrl: `https://${functionAppHost}`,
websiteUrl: website.url,
Expand Down
8 changes: 5 additions & 3 deletions e2e/infra/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createResourceGroup, removeResourceGroup } from '../resourceGroup'
import { writeTestInfo } from '../../shared/testInfo'
import { addTestInfo, initTestInfo } from '../../shared/testInfo'
import { deployE2EInfrastructure, DeployE2EInfrastructureOptions, DeployE2EInfrastructureResult } from '../infra'
import { destroyTestInfo } from '../destroyTestInfo'

Expand All @@ -10,6 +10,8 @@ function getId() {
async function main() {
const resourceGroup = await createResourceGroup()

initTestInfo(resourceGroup)

const results: DeployE2EInfrastructureResult[] = []

try {
Expand All @@ -32,11 +34,11 @@ async function main() {
const result = await deployE2EInfrastructure(variant)

results.push(result)

addTestInfo(result.testInfo)
}

await Promise.all(results.map((r) => r.waitForFrontDoor()))

writeTestInfo(results.map((r) => r.testInfo))
} catch (error) {
for (const result of results) {
await destroyTestInfo(result.testInfo)
Expand Down
8 changes: 2 additions & 6 deletions e2e/infra/scripts/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ import { destroyTestInfo } from '../destroyTestInfo'
async function main() {
const testInfo = readTestInfo()

const resourceGroups = new Set(testInfo.map((t) => t.resourceGroup))

for (const info of testInfo) {
for (const info of testInfo.tests) {
await destroyTestInfo(info)
}

for (const resourceGroup of resourceGroups) {
await removeResourceGroup(resourceGroup)
}
await removeResourceGroup(testInfo.resourceGroup)

deleteTestInfo()
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const config: Config = {
expect: {
timeout: isCi ? 100_000 : 30_000,
},
projects: testInfo.map((info) => ({
projects: testInfo.tests.map((info) => ({
use: {
name: info.frontdoorUrl,
baseURL: info.frontdoorUrl,
Expand Down
34 changes: 30 additions & 4 deletions e2e/scripts/mockTests.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { execSync } from 'child_process'
import { readTestInfo } from '../shared/testInfo'
import pkg from '../../package.json'
import { ExponentialBackoff, handleAll, retry } from 'cockatiel'

async function main() {
async function doMockTests() {
let hasError = false
const testInfo = readTestInfo()

Expand All @@ -11,18 +13,24 @@ async function main() {
throw new Error('API_URL is not set')
}

for (const info of testInfo) {
for (const info of testInfo.tests) {
const agentPath = `${info.routePrefix}/${info.agentDownloadPath}`
const resultPath = `${info.routePrefix}/${info.getResultPath}`
const host = info.functionAppUrl
const host = info.frontdoorUrl

const agentUrl = new URL(host)
agentUrl.pathname = agentPath

const resultUrl = new URL(host)
resultUrl.pathname = resultPath

console.info('Running mock server for', host)
console.info('Agent download path:', agentPath)
console.info('Get result path:', resultPath)

try {
execSync(
`npm exec -y "git+https://github.com/fingerprintjs/dx-team-mock-for-proxy-integrations-e2e-tests.git" -- --api-url="https://${apiUrl}" --host="${host}" --cdn-proxy-path="${agentPath}" --ingress-proxy-path="${resultPath}"`,
`npm exec -y "git+https://github.com/fingerprintjs/dx-team-mock-for-proxy-integrations-e2e-tests.git" -- --api-url="https://${apiUrl}" --cdn-proxy-url="${agentUrl.toString()}" --ingress-proxy-url="${resultUrl.toString()}" --traffic-name="fingerprint-pro-azure" --integration-version=${pkg.version}`,
{
stdio: 'inherit',
}
Expand All @@ -35,6 +43,24 @@ async function main() {
}

if (hasError) {
throw new Error('One or more tests failed')
}
}

async function main() {
const policy = retry(handleAll, {
backoff: new ExponentialBackoff({
// 5 minutes
maxDelay: 1000 * 60 * 5,
}),
maxAttempts: 5,
})

try {
await policy.execute(doMockTests)
} catch (e) {
console.error(e)

process.exit(1)
}
}
Expand Down
29 changes: 26 additions & 3 deletions e2e/shared/testInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as fs from 'fs'
import path from 'path'

export interface TestInfo {
resourceGroup: string
functionAppUrl: string
websiteUrl: string
frontdoorUrl: string
Expand All @@ -13,13 +12,37 @@ export interface TestInfo {
routePrefix: string
}

export interface TestMetadata {
resourceGroup: string
tests: TestInfo[]
}

const filePath = path.join(__dirname, '..', 'test-info.json')

export function writeTestInfo(info: TestInfo[]) {
export function initTestInfo(resourceGroup: string) {
if (fs.existsSync(filePath)) {
throw new Error('Test info file already exists')
}

writeTestInfo({
tests: [],
resourceGroup,
})
}

export function addTestInfo(testInfo: TestInfo) {
const infos = readTestInfo()

infos.tests.push(testInfo)

writeTestInfo(infos)
}

export function writeTestInfo(info: TestMetadata) {
fs.writeFileSync(filePath, JSON.stringify(info))
}

export function readTestInfo(): TestInfo[] {
export function readTestInfo(): TestMetadata {
if (!fs.existsSync(filePath)) {
throw new Error('Test info file does not exist')
}
Expand Down
Loading

0 comments on commit 6c3b657

Please sign in to comment.