Skip to content

Commit b124c7f

Browse files
committed
test(bats): add smoke test
also prep DB for e2e test
1 parent 29f22ce commit b124c7f

File tree

4 files changed

+67
-7
lines changed

4 files changed

+67
-7
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- exist-version: 6.2.0
1414
java-version: 17
1515
- exist-version: latest
16-
java-version: 11
16+
java-version: 8
1717

1818
runs-on: ${{ matrix.os }}
1919
steps:
@@ -24,6 +24,10 @@ jobs:
2424
distribution: temurin
2525
cache: maven
2626
java-version: ${{ matrix.java-version }}
27+
- name: Install Test Dependencies
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y bats
2731
- name: Maven Build
2832
run: mvn clean package
2933

@@ -37,17 +41,20 @@ jobs:
3741
- name: Start exist-ci containers
3842
run: |
3943
docker run -dit -p 8080:8080 -v ${{ github.workspace }}/target:/exist/autodeploy \
40-
--name exist --rm --health-interval=2s --health-start-period=4s \
44+
--name exist --rm --health-interval=1s --health-start-period=1s \
4145
duncdrum/existdb:${{ matrix.exist-version }}
4246
4347
- name: wait for install to finish
4448
timeout-minutes: 5
4549
run: |
4650
while ! docker logs exist | grep -q "Server has started"; \
47-
do sleep 2s; \
51+
do sleep 4s; \
4852
done
4953
50-
# Test
54+
# Test
55+
- name: Run smoke test
56+
run: bats --tap src/test/bats/*.bats
57+
5158
- name: Run e2e test
5259
run: npx cypress run
5360

src/main/xar-resources/modules/reindex.xql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ xquery version "3.1";
22

33
import module namespace docs="http://exist-db.org/xquery/docs" at "scan.xql";
44
import module namespace config="http://exist-db.org/xquery/apps/config" at "config.xqm";
5+
import module namespace sm="http://exist-db.org/xquery/securitymanager";
56

67
declare option exist:serialize "method=json media-type=application/javascript";
78

src/test/bats/smoke-test.bats

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env bats
2+
3+
# Basic start-up and connection tests
4+
# These tests expect a running container at port 8080 with the name "exist"
5+
6+
@test "container jvm responds from client" {
7+
run docker exec exist java -version
8+
[ "$status" -eq 0 ]
9+
}
10+
11+
@test "container can be reached via http" {
12+
result=$(curl -Is http://127.0.0.1:8080/ | grep -o 'Jetty')
13+
[ "$result" == 'Jetty' ]
14+
}
15+
16+
@test "container reports healthy to docker" {
17+
result=$(docker ps | grep -c 'healthy')
18+
[ "$result" -eq 1 ]
19+
}
20+
21+
@test "logs show clean start" {
22+
result=$(docker logs exist | grep -o 'Server has started')
23+
[ "$result" == 'Server has started' ]
24+
}
25+
26+
# Make sure the package has been deployed
27+
@test "logs show package deployment" {
28+
result=$(docker logs exist | grep -om 1 'http://exist-db.org/apps/fundocs')
29+
[ "$result" == 'http://exist-db.org/apps/fundocs' ]
30+
}
31+
32+
@test "logs are error free" {
33+
result=$(docker logs exist | grep -ow -c 'ERROR' || true)
34+
[ "$result" -eq 0 ]
35+
}
36+
37+
@test "no fatalities in logs" {
38+
result=$(docker logs exist | grep -ow -c 'FATAL' || true)
39+
[ "$result" -eq 0 ]
40+
}
41+
42+
# Check for cgroup config warning
43+
@test "check logs for cgroup file warning" {
44+
result=$(docker logs exist | grep -ow -c 'Unable to open cgroup memory limit file' || true )
45+
[ "$result" -eq 0 ]
46+
}
47+
48+
@test "Reindex db" {
49+
run curl -s -u 'admin:' 'http://127.0.0.1:8080/exist/rest/db/apps/fundocs/modules/reindex.xql'
50+
[ "$status" -eq 0 ]
51+
echo '# ' $output >&3
52+
}

src/test/cypress/integration/fundoc_spec.cy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
context('Function Documentation', () => {
55
beforeEach(() => {
66
cy.visit('')
7-
// TODO: Generate index in beforeAll
87
})
8+
99
describe('landing page', () => {
10-
it.only('should contain major parts', () => {
10+
it('should contain major parts', () => {
1111
cy.get('.navbar')
1212
.contains('Home')
1313
cy.get('h1')
@@ -36,7 +36,7 @@ context('Function Documentation', () => {
3636
.should('exist')
3737
})
3838
})
39-
39+
4040
describe('browse', () => {
4141
it('should find local modules', () => {
4242
cy.get('#browse')

0 commit comments

Comments
 (0)