Skip to content

Commit

Permalink
test: Add slow query E2E test (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
YiniXu9506 authored Jan 17, 2022
1 parent 5fb4cd3 commit ea838ed
Show file tree
Hide file tree
Showing 19 changed files with 382 additions and 46 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
backend_ut:
name: Backend Unit Test
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down Expand Up @@ -113,11 +113,8 @@ jobs:
${{ runner.os }}-tiup
- name: Install and run TiUP in the background
run: |
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source /home/runner/.profile
tiup update playground
source /home/runner/.profile
tiup playground ${{ matrix.tidb_version }} --tiflash=0 &
chmod u+x scripts/start_tiup.sh
scripts/start_tiup.sh ${{ matrix.tidb_version }}
- name: Build UI
run: |
make ui
Expand Down Expand Up @@ -155,6 +152,13 @@ jobs:
SERVER_URL: http://127.0.0.1:12333/dashboard/
CI: true
FEATURE_VERSION: ${{ matrix.feature_version }}
TIDB_VERSION: ${{ matrix.tidb_version }}
- name: Archive Test Results
if: always()
run: |
cat ui/start_tiup.log
echo "==============="
cat ui/wait_tiup.log
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ run:

test_e2e_compat_features:
cd ui &&\
yarn run:e2e-test:compat-features --env FEATURE_VERSION=$(FEATURE_VERSION)
yarn run:e2e-test:compat-features --env FEATURE_VERSION=$(FEATURE_VERSION) TIDB_VERSION=$(TIDB_VERSION)

test_e2e_common_features:
cd ui &&\
yarn run:e2e-test:common-features
yarn run:e2e-test:common-features TIDB_VERSION=$(TIDB_VERSION)

test_e2e: test_e2e_compat_features test_e2e_common_features
26 changes: 26 additions & 0 deletions scripts/start_tiup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -ex
tidb_version=$1
mode=$2

TIUP_BIN_DIR=$HOME/.tiup/bin/tiup

if [ $mode = "restart" ]; then
# get process id
pid=$(ps -ef | grep -v start_tiup | grep tiup | grep -v grep | awk '{print $2}')

for id in $pid
do
# kill tiup-playground
echo "killing $id"
kill -9 $id;
done
else
echo "install tiup"
# Install TiUP
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
$TIUP_BIN_DIR update playground
fi

# Run Tiup
$TIUP_BIN_DIR playground ${tidb_version} --tiflash=0 &> start_tiup.log &
1 change: 1 addition & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cypress/screeshots
cypress/integration/1-getting-started
cypress/integration/2-advanced-examples
.nyc_output
*.log

# production
build/
Expand Down
11 changes: 8 additions & 3 deletions ui/cypress.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
{
"defaultCommandTimeout": 60000,
"defaultCommandTimeout": 120000,
"responseTimeout": 60000,
"requestTimeout": 60000,
"screenshotOnRunFailure": false,
"video": false,
"env": {
"FEATURE_VERSION": "6.0.0"
}
"FEATURE_VERSION": "6.0.0",
"TIDB_VERSION": "nightly"
},
"experimentalSessionSupport": true,
"viewportWidth": 1500,
"viewportHeight": 1000
}
3 changes: 2 additions & 1 deletion ui/cypress/fixtures/uri.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"root": "/",
"login": "/signin",
"overview": "/overview"
"overview": "/overview",
"slow_query": "/slow_query"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('Login session', () => {
it('Redirect to sigin page when user not login', function () {
cy.visit(this.uri.overview)
expect(localStorage.getItem('dashboard_auth_token')).to.be.null
cy.url().should('include', `${this.uri.login}`)
cy.url().should('include', this.uri.login)
})

// Use fake token to indicate session expired.
Expand All @@ -19,7 +19,7 @@ describe('Login session', () => {
localStorage.setItem('dashboard_auth_token', 'invalid_auth_token')
cy.visit(this.uri.overview)

cy.url().should('include', `${this.uri.login}`)
cy.url().should('include', this.uri.login)
cy.get('.ant-message').should('be.visible')
cy.get('.ant-message-error > span:last-child').should(
'has.text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ describe('User Login', () => {
if (Cypress.env('FEATURE_VERSION') === '6.0.0') {
// Create user test
before(() => {
let query = "DROP USER IF EXISTS 'test'@'%'"
let password = ''
cy.task('queryDB', { query, password })
let queryData = {
query: 'DROP USER IF EXISTS "test"@"%"',
}
cy.task('queryDB', { ...queryData })

query = "CREATE USER 'test'@'%' IDENTIFIED BY 'test_pwd'"
cy.task('queryDB', { query, password })
queryData = {
query: "CREATE USER 'test'@'%' IDENTIFIED BY 'test_pwd'",
}

query = "GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' WITH GRANT OPTION"
cy.task('queryDB', { query, password })
cy.task('queryDB', { ...queryData })

queryData = {
query: "GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' WITH GRANT OPTION",
}
cy.task('queryDB', { ...queryData })
})

// Run before each test
Expand All @@ -38,7 +44,7 @@ describe('User Login', () => {
it('nonRoot user with correct password', function () {
cy.get('[data-e2e=signin_username_input]').clear().type('test')
cy.get('[data-e2e="signin_password_input"]').type('test_pwd{enter}')
cy.url().should('include', `${this.uri.overview}`)
cy.url().should('include', this.uri.overview)
})

it('nonRoot user with incorrect password', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Root User Login', () => {
it('root login with no pwd', function () {
cy.get('[data-e2e=signin_username_input]').should('have.value', 'root')
cy.get('[data-e2e=signin_submit]').click()
cy.url().should('include', `${this.uri.overview}`)
cy.url().should('include', this.uri.overview)
})

it('remember last succeeded login username', () => {
Expand All @@ -40,16 +40,19 @@ describe('Root User Login', () => {

it('root login with correct pwd', function () {
// set password for root
let query = "SET PASSWORD FOR 'root'@'%' = 'root_pwd'"
let password = ''
cy.task('queryDB', { query, password })
let queryData = {
query: 'SET PASSWORD FOR "root"@"%" = "root_pwd"',
}
cy.task('queryDB', { ...queryData })

cy.get('[data-e2e="signin_password_input"]').type('root_pwd{enter}')
cy.url().should('include', `${this.uri.overview}`)
cy.url().should('include', this.uri.overview)

// set empty password for root
query = "SET PASSWORD FOR 'root'@'%' = ''"
password = 'root_pwd'
cy.task('queryDB', { query, password })
queryData = {
query: 'SET PASSWORD FOR "root"@"%" = ""',
password: 'root_pwd',
}
cy.task('queryDB', { ...queryData })
})
})
Loading

0 comments on commit ea838ed

Please sign in to comment.