-
-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: test migration backward compatibility (#5492)
## About the changes This PR will validate that our current migrations are backward compatible with the latest stable release of Unleash. It will do so by starting a database, applying the latest migrations, and then starting a docker container with the last stable unleash release and running UI tests against it. There's a risk that the current version of UI tests will not work with the previous version of our UI. Because of that we copied the previous version of cypress tests (https://github.com/Unleash/unleash/tree/5.6/frontend/cypress) into oss folder and removed the ones that are enterprise only. We can discuss a better way of doing this to avoid having to maintain this folder always in sync with the previous version of Unleash This action will only run when there are changes in migrations or to cypress tests.
- Loading branch information
1 parent
02451ba
commit 9f3648d
Showing
7 changed files
with
132 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Test db migrations | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
paths: | ||
- 'src/migrations/**' | ||
- '.github/workflows/validate-migrations.yaml' | ||
- 'test-migrations/**' | ||
- 'frontend/cypress' | ||
workflow_dispatch: | ||
jobs: | ||
test-migrations: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js 18.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
cache: 'yarn' | ||
- name: Start database | ||
working-directory: test-migrations | ||
run: docker compose up db -d --wait -t 90 | ||
- name: Start stable version of Unleash | ||
working-directory: test-migrations | ||
run: docker compose up unleash -d --wait -t 90 | ||
# add some data with terraform | ||
- name: Apply migrations | ||
env: | ||
DATABASE_URL: postgres://postgres:unleash@localhost:5432/unleash | ||
DATABASE_SSL: false | ||
run: | | ||
yarn install --frozen-lockfile --ignore-scripts | ||
yarn db-migrate up | ||
# run ui tests against previous version of Unleash | ||
- name: Run Cypress | ||
uses: cypress-io/github-action@v5 | ||
with: | ||
working-directory: frontend | ||
env: AUTH_USER=admin,AUTH_PASSWORD=unleash4all | ||
config: baseUrl=http://localhost:4242 | ||
spec: cypress/oss/**/*.spec.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
///<reference path="../../global.d.ts" /> | ||
|
||
describe('feature', () => { | ||
const randomId = String(Math.random()).split('.')[1]; | ||
const featureToggleName = `unleash-e2e-${randomId}`; | ||
|
||
before(() => { | ||
cy.runBefore(); | ||
}); | ||
|
||
after(() => { | ||
cy.deleteFeature_API(featureToggleName); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.login_UI(); | ||
cy.visit('/features'); | ||
}); | ||
|
||
it('can create a feature toggle', () => { | ||
cy.createFeature_UI(featureToggleName, true, 'default', true); | ||
cy.url().should('include', featureToggleName); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
version: "3.9" | ||
services: | ||
# The Unleash server waits for the migrations to be applied by waiting on the | ||
# migrations container to be healthy. | ||
unleash: | ||
image: unleashorg/unleash-server:latest # this is the latest stable release | ||
pull_policy: "always" | ||
ports: | ||
- "4242:4242" | ||
environment: | ||
DATABASE_URL: "postgres://postgres:unleash@db/unleash" | ||
DATABASE_SSL: "false" | ||
LOG_LEVEL: "debug" | ||
INIT_ADMIN_API_TOKENS: "*:*.unleash-insecure-admin-api-token" | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
healthcheck: | ||
test: wget --no-verbose --tries=1 --spider http://localhost:4242/health || exit 1 | ||
interval: 1s | ||
timeout: 1m | ||
retries: 5 | ||
start_period: 15s | ||
|
||
db: | ||
ports: | ||
- "5432:5432" | ||
expose: | ||
- "5432" | ||
image: postgres:16 | ||
environment: | ||
POSTGRES_DB: "unleash" | ||
# trust incoming connections blindly (DON'T DO THIS IN PRODUCTION!) | ||
POSTGRES_HOST_AUTH_METHOD: "trust" | ||
healthcheck: | ||
test: | ||
[ | ||
"CMD", | ||
"pg_isready", | ||
"--username=postgres", | ||
"--host=127.0.0.1", | ||
"--port=5432", | ||
] | ||
interval: 2s | ||
timeout: 1m | ||
retries: 5 | ||
start_period: 10s |