A set of scripts generating fake-data and testdata for a new mDIS instance.
### Synopsis
A set of scripts generating fake-data and testdata for a new mDIS instance.
Written in Javascript for the Node Platform (v14+).
For details: read [USAGE.md](USAGE.md)
### .sh and .js Scripts available
There is a set of shellscripts in the `bin/` subdirectory. They are just simple wrappers for the js Files. Each Shell scripts load the node v14 for you.
You can call the JavaScript files directly as well, but then you have to make sure that you are using Node 14+.
Enter this into line 1 of config.js, or export it as a shell environment variable `token`:
`export token=eQv809NUzP4447eD3Ws4dBwCOFvf0E8I`.
## USAGE
Written in Javascript for the Node Platform v14+
You must use node v14 because the JS code internaly uses the `?.` 'optional chaining' operator as a shortcut for definedness of nested object properties.
### Inserting fake data
First, look at the `bin/` subdirectory to execute Shell scripts, or enter the `src/`subdirectory to execute Node scripts.
For regular usage, call the scripts from the parent directory.
### Debugging
First, cd into the `bin/` subdirectory to execute Shell scripts,
or enter the `src/`subdirectory to execute Node scripts.
To enable debugging with the Chrome Developer Tools, open any shellscript `bin/api_caller*.sh`, comment out the line
Usually the `program` table is not necessary to automate. This can be done by hand. The table has only 3 columns.
#### Inserting a Fake Expedition
To insert a single new expedition, call the script without arguments:
`bin/api-caller-expedition.sh`
The script does not take arguments.
Change the line
`num_expeditions=1`
accordingly, if you want to add more than 1 expedition.
#### Inserting a Fake Site
To insert a single new site, call the script without arguments:
`bin/api-caller-sites.sh`
The script does not take arguments.
Do not change the line
`num_sites=1` if you want to add more than 1 site.
Instead, you must change file `src/site-inserter.js`.
Change the lines
`let num_sites_to_insert = 1` and
`let expedition_id = 6`
accordingly, if you want to add any sites to that expedition.
You can get the expedition id from the expedition form or from an SQL query.
#### Inserting a Fake Hole
To insert a single new hole, call the script without arguments:
`bin/api-caller-hole.sh`
Do *not* change the line
`num_holes=1` if you want to add more than 1 site.
Instead, you must change file `src/hole-inserter.js`. In there, change the lines
`let num_holes_to_insert = 1` and
`let site_id = 6`
accordingly, if you want to add any holes to that site.
You can get the site id from the site form or from an SQL query.
#### Inserting a Fake Core
To insert a single new core, call the script with arguments `-n`, `-e`, `-s`, `-h`:
`bin/api-caller-cores.sh -n 2 -e 2`
Alternatively, change the file `src/core-inserter.js`. In there, change the `declare` lines
`declare e=11`
accordingly, if you want to add any cores to that expedition.
You can get the ids from the respective forms or from an SQL query.
##### Troubleshooting
Error `Data Validation Failed`:
Copy the returned JSON structure and insert it into Postman, test the API response. The HTTP response will be easier to work with, and the error message will be more verbose.
#### Inserting a Fake Section
Creating new sections is a complex operation.
...
...
@@ -32,10 +120,10 @@ There are two scripts to execute,
1.`api-caller-core-section-find.sh`,
1.`api-caller-core-section-insert.sh`.
The first writes a JSON file with fake data. The second script reads that file and uploads it to mDIS. The benefit of this two-step approach is tha you can have a look at the data before it actually gets created inside mDIS.
The first writes a JSON file with fake data. The second script reads that file and uploads it to mDIS. The benefit of this two-step approach is that you can have a look at the data before it actually gets created inside mDIS.
```sh
cd bin
cd bin# important
./api-caller-core-section-find.sh
./api-caller-core-section-insert.sh
...
...
@@ -56,7 +144,7 @@ Script 2:
```sh
# looks for file section_counts.json in same directory, and processes it.