-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add apisix e2e environment (api7#3)
- Loading branch information
Showing
14 changed files
with
252 additions
and
711 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,39 @@ | ||
name: E2E | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
apisix: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# Setup backend environment | ||
- name: Setup Apache APISIX | ||
working-directory: ./apps/cli-e2e/assets/apisix | ||
run: | | ||
docker compose up -d | ||
sleep 10 | ||
# Build and test ADC CLI | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 'lts/*' | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: latest | ||
- name: Build ADC | ||
run: | | ||
pnpm install | ||
npx nx build cli | ||
node --experimental-sea-config apps/cli/node-sea.json | ||
cp $(command -v node) adc | ||
npx postject adc NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 | ||
# Run ADC tests | ||
- name: Run E2E tests | ||
run: npx nx run cli-e2e:e2e --test-file apps/cli-e2e/src/apisix |
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,9 @@ | ||
deployment: | ||
admin: | ||
allow_admin: | ||
- 0.0.0.0/0 | ||
etcd: | ||
host: | ||
- "http://etcd:2379" | ||
prefix: "/apisix" | ||
timeout: 30 |
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,19 @@ | ||
version: '3' | ||
services: | ||
etcd: | ||
image: bitnami/etcd:3.5.11 | ||
environment: | ||
ALLOW_NONE_AUTHENTICATION: 'yes' | ||
ETCD_ADVERTISE_CLIENT_URLS: 'http://etcd:2379' | ||
ETCD_LISTEN_CLIENT_URLS: 'http://0.0.0.0:2379' | ||
ports: | ||
- '2379:2379/tcp' | ||
apisix: | ||
image: apache/apisix:3.8.0-debian | ||
depends_on: | ||
- etcd | ||
volumes: | ||
- ./apisix-config.yaml:/usr/local/apisix/conf/config.yaml:ro | ||
ports: | ||
- '9080:9080/tcp' | ||
- '9180:9180/tcp' |
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,35 @@ | ||
import { execSync } from 'node:child_process'; | ||
|
||
describe('Ping command', () => { | ||
it('Ensure ping command is exist', async () => { | ||
const out = execSync(`./adc help ping`).toString('utf8'); | ||
expect(out).toContain('Usage: adc ping [options]'); | ||
}); | ||
|
||
it('Use ping command (with correct token)', () => { | ||
const out = execSync( | ||
'./adc ping --token edd1c9f034335f136f87ad84b625c8f1', | ||
).toString('utf8'); | ||
expect(out).toContain('Connected to backend successfully!'); | ||
}); | ||
|
||
it('Use ping command (with incorrect token)', () => { | ||
try { | ||
execSync('./adc ping --token incorrent-token'); | ||
} catch (err) { | ||
expect(err.output.toString('utf8')).toContain( | ||
'Failed to ping backend, AxiosError: Request failed with status code 401', | ||
); | ||
} | ||
}); | ||
|
||
it('Use ping command (with incorrect server address)', () => { | ||
try { | ||
execSync('./adc ping --token token --server http://127.0.0.1:9999'); | ||
} catch (err) { | ||
expect(err.output.toString('utf8')).toContain( | ||
'Failed to ping backend, Error: connect ECONNREFUSED 127.0.0.1:9999', | ||
); | ||
} | ||
}); | ||
}); |
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,4 @@ | ||
{ | ||
"main": "dist/apps/cli/main.js", | ||
"output": "sea-prep.blob" | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { setupCommands } from './app/command'; | ||
|
||
import { AppModule } from './app/app.module'; | ||
// hide nodejs sea warning | ||
process.removeAllListeners('warning'); | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.createApplicationContext(AppModule, { | ||
logger: false, | ||
}); | ||
await app.close(); | ||
await setupCommands().parseAsync(process.argv); | ||
} | ||
|
||
bootstrap(); |
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
Oops, something went wrong.