Fix integration markdown errors for linter
[integration.git] / test / mocks / datafilecollector-testharness / simulator-group / README.md
1 # Introduction
2
3 The purpose of the "simulator-group" is to run all containers in one go with specified behavior.
4 Mainly this is needed for CSIT tests and for auto test but can be used also for manual testing of dfc both as an java-app
5 or as a manually started container. Instead of running the simulators manually as described below the auto-test cases
6 can be executed together with a java-app or a manaully started container.
7
8 In general these steps are needed to run the simulator group and dfc
9
10 1. Build the simulator images
11 2. Edit simulator env variables (to adapt the behavior of simulators)
12 3. Configure consul
13 4. Start the simulator monitor (to view the simulator stats)
14 5. Start the simulators
15 6. Start dfc
16
17 # Overview of the simulators.
18
19 There are 5 different types of simulators. For futher details, see the README.md in each simulator dir.
20
21 1. The MR simulator emits fileready events, upon poll requests, with new and historice file references
22    It is possible to configire the change identifier and file prefixes for these identifiers and for which consumer groups
23    these change identifier shall be generated. It is also possible to configure the number of events and files to generate and
24    from which ftp servers the files shall be fetched from.
25 2. The DR simulator handles the publish queries (to check if a file has previously been published) and the
26    actual publish request (which results in a redirect to the DR REDIR simulator. It keeps a 'db' of published files updated by the DR REDIR simulator.
27    It is possible to configure 1 or more feeds along with the accepted filename prefixes for each feed. It is also possible
28    to configure the responses for the publish queries and publish requests.
29 3. The DR REDIR simulator handles the redirect request for publish from the DR simulator. All accepted files will be stored as and empty
30    file with a file name concatenated from the published file name + file size + feed id.
31    It is possible to configure 1 or more feeds along with the accepted filename prefixes for each feed. It is also possible
32    to configure the responses for the publish requests.
33 4. The SFTP simulator(s) handles the ftp download requests. 5 of these simulators are always started and in the MR sim it is
34    possible to configure the distrubution of files over these 5 servers (from 1 up to 5 severs). At start of the server, the server is
35    populated with files to download.
36 5. The FTPS simulator(s) is the same as the SFTP except that it using the FTPS protocol.
37
38 # Build the simulator images
39
40 Run the script `prepare-images.sh` to build the docker images for MR, DR and FTPS servers.
41
42 # Edit simulator env variables
43
44 ## Summary of scripts and files
45
46 - `consul_config.sh` - Convert a json config file to work with dfc when manually started as java-app or container and then add that json to Consul.
47 - `dfc-internal-stats.sh` - Periodically extract jvm data and dfc internal data and print to console/file.
48 - `docker-compose-setup.sh` - Sets environment variables for the simulators and start the simulators with that settings.
49 - `docker-compose-template.yml` - A docker compose template with environment variables setting. Used for producing a docker-compose file to defined the simulator containers.
50 - `prepare-images.sh` - Script to build all needed simulator images.
51 - `setup-ftp-files-for-image.sh` - Script executed in the ftp server to create files for download.
52 - `sim-monitor-start.sh` - Script to install needed packages and start the simulator monitor.
53 - `sim-monitor.js` - The source file the simulator monitor.
54 - `simulators-kill.sh` - Script to kill all the simulators
55 - `simulators-start.sh` - Script to start all the simulators. All env variables need to be set prior to executing the script.
56
57 ## Preparation
58
59 Do the manual steps to prepare the simulator images:
60
61 - Build the mr-sim image.
62 - cd ../mr-sim
63 - Run the docker build command to build the image for the MR simulator: 'docker build -t mrsim:latest .'
64 - cd ../dr-sim
65 - Run the docker build command to build the image for the DR simulators: \`docker build -t drsim_common:latest .'
66 - cd ../ftps-sftp-server
67 - Check the README.md in ftps-sftp-server dir in case the cert need to be updated.
68 - Run the docker build command to build the image for the DR simulators: \`docker build -t ftps_vsftpd:latest -f Dockerfile-ftps .'
69
70 ## Execution
71
72 Edit the `docker-compose-setup.sh` (or create a copy) to setup the env variables to the desired test behavior for each simulators.
73 See each simulator to find a description of the available settings (DR_TC, DR_REDIR_TC and MR_TC).
74 The following env variables shall be set (example values).
75 Note that NUM_FTPFILES and NUM_PNFS controls the number of ftp files created in the ftp servers.
76 A total of NUM_FTPFILES \* NUM_PNFS ftp files will be created in each ftp server (4 files in the below example).
77 Large settings will be time consuming at start of the servers.
78 Note that the number of files must match the number of file references emitted from the MR sim.
79
80 DR_TC="--tc normal"           #Normal behavior of the DR sim
81
82 DR_REDIR_TC="--tc normal"     #Normal behavior of the DR redirect sim
83
84 MR_TC="--tc100"               #One 1 MB file in one event, once.
85
86 BC_TC=""                      #Not in use yet
87
88 NUM_FTPFILES="2"              #Two file for each PNF
89
90 NUM_PNFS="2"                  #Two PNFs
91
92 To minimize the number of ftp file creation, the following two variables can be configured in the same file.
93 FILE_SIZE="1MB"               #File size for FTP file (1KB, 1MB, 5MB, 50MB or ALL)
94 FTP_TYPE="SFTP"               #Type of FTP files to generate (SFTP, FTPS or ALL)
95
96 If `FTP_TYPE` is set to `ALL`, both ftp servers will be populated with the same files. If set to `SFTP` or `FTPS` then only the server serving that protocol will be populated with files.
97
98 Run the script `docker-compose-setup.sh`to create a docker-compose with the desired settings. The desired setting
99 in the script need to be manually adapted to for each specific simulator behavior according to the above. Check each simulator for available
100 parameters.
101 All simulators will be started with the generated docker-compose.yml file
102
103 To generate ftp url with IP different from localhost, set SFTP_SIM_IP and/or FTPS_SIM_IP env variables to the addreses of the ftp servers before starting. 
104 So farm, this only works when the simulator python script is started from the command line.
105
106 Kill all the containers with `simulators-kill.se`
107
108 `simulators_start.sh` is for CSIT test and requires the env variables for test setting to be present in the shell.
109
110 `setup-ftp-files.for-image.sh` is for CSIT and executed when the ftp servers are started from the docker-compose-setup.sh\`.
111
112 To make DFC to be able to connect to the simulator containers, DFC need to run in host mode.
113 Start DFC by the following cmd: `docker run -d --network="host" --name dfc_app <dfc-image> `
114
115 `<dfc-image>` could be either the locally built image `onap/org.onap.dcaegen2.collectors.datafile.datafile-app-server`
116 or the one in nexus `nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.datafile.datafile-app-server`.
117
118 # Start the simulator monitor
119
120 Start the simulator monitor server with `node sim-monitor.js` on the cmd line and the open a browser with the url `localhost:9999/mon`
121 to see the statisics page with data from DFC(ss), MR sim, DR sim and DR redir sim.
122 If needed run 'npm install express' first