Skip to content

Commit c8ebf73

Browse files
fix derived dataset datablock tests and add apitests into the actions
1 parent f35ec33 commit c8ebf73

File tree

9 files changed

+151
-268
lines changed

9 files changed

+151
-268
lines changed

.github/workflows/test-build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ jobs:
2020
docker-compose up --build --exit-code-from scicat-backend
2121
docker-compose down
2222
23+
24+
apitests:
25+
name: API tests
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v3
30+
31+
- name: API tests
32+
run: |
33+
cp CI/ESS/docker-compose.api.yaml docker-compose.yaml
34+
docker-compose down --remove-orphans
35+
docker-compose pull
36+
docker-compose up --build --exit-code-from scicat-backend
37+
docker-compose down
38+
2339
e2etests:
2440
name: E2E Tests
2541
runs-on: ubuntu-latest

CI/ESS/Dockerfile.api.test

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM node:16-alpine
2+
3+
RUN apk update && apk upgrade && \
4+
apk add --no-cache git
5+
6+
ENV PORT 3000
7+
EXPOSE 3000
8+
9+
# Prepare app directory
10+
WORKDIR /home/node/app
11+
COPY package*.json /home/node/app/
12+
13+
# set up local user to avoid running as root
14+
RUN chown -R node:node /home/node/app
15+
USER node
16+
17+
# Install our packages
18+
RUN npm ci --omit=optional
19+
20+
# Copy the rest of our application, node_modules is ignored via .dockerignore
21+
COPY --chown=node:node . /home/node/app
22+
COPY --chown=node:node CI/ESS/wait-api.sh /home/node/app/
23+
24+
# Start the app
25+
CMD ["./wait-api.sh"]

CI/ESS/docker-compose.api.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3"
2+
services:
3+
mongodb:
4+
image: "bitnami/mongodb:4.0"
5+
scicat-backend:
6+
build:
7+
context: .
8+
dockerfile: CI/ESS/Dockerfile.api.test
9+
depends_on:
10+
- mongodb

CI/ESS/wait-api.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
# wait for mongo container to come up
3+
sleep 15
4+
npm run test:api:mocha

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"test:watch": "jest --watch",
2222
"test:cov": "jest --coverage",
2323
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
24-
"test:e2e": "jest --config ./test/jest-e2e.json",
25-
"test:e2e:mocha": "mocha --timeout=60000 --reporter spec --exit",
24+
"test:api": "jest --config ./test/jest-e2e.json",
25+
"test:api:mocha": "mocha --timeout=60000 --reporter spec --exit",
2626
"prepare:local": "docker-compose -f CI/E2E/docker-compose-local.yaml up -d && cp functionalAccounts.json.example functionalAccounts.json"
2727
},
2828
"dependencies": {

src/datasets/schemas/dataset.schema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,31 +118,31 @@ export class Dataset extends Ownable {
118118
description:
119119
"Total size of all source files contained in source folder on disk when unpacked",
120120
})
121-
@Prop({ type: Number, index: true })
121+
@Prop({ type: Number, index: true, default: 0 })
122122
size: number;
123123

124124
@ApiProperty({
125125
type: Number,
126126
description:
127127
"Total size of all datablock package files created for this dataset",
128128
})
129-
@Prop()
129+
@Prop({ default: 0 })
130130
packedSize: number;
131131

132132
@ApiProperty({
133133
type: Number,
134134
description:
135135
"Total number of lines in filelisting of all OrigDatablocks for this dataset",
136136
})
137-
@Prop()
137+
@Prop({ default: 0 })
138138
numberOfFiles: number;
139139

140140
@ApiProperty({
141141
type: Number,
142142
description:
143143
"Total number of lines in filelisting of all Datablocks for this dataset",
144144
})
145-
@Prop()
145+
@Prop({ default: 0 })
146146
numberOfFilesArchived: number;
147147

148148
@ApiProperty({

status-tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
- in a second terminal run the tests and save results in temporary file
2222
```bash
23-
> npm run test:e2e:mocha >>~/scicat-backend-nestjs-tests.txt 2>&1
23+
> npm run test:api:mocha >>~/scicat-backend-nestjs-tests.txt 2>&1
2424
```
2525

2626
- run awk script on results file

0 commit comments

Comments
 (0)