github.com/cozy/cozy-stack@v0.0.0-20240603063001-31110fa4cae1/tests/system/README.md (about) 1 # Tools for system tests 2 3 ## Install 4 5 ```sh 6 apt install ruby ruby-dev 7 gem install bundler 8 cd cozy-stack 9 go install 10 cd tests/system 11 bundle install 12 npm install -g @bitwarden/cli@1.16.0 13 ``` 14 15 Optional: install `MailHog` 16 17 18 ## Automated tests 19 20 To launch an automated scenario of tests: 21 22 ```sh 23 bundle exec ruby tests/push_folder.rb -v 24 ``` 25 26 The tests clean the logs and databases from the previous runs when they start, 27 but does no cleaning on exit. You can inspect them to find what can have gone 28 wrong for example. If you just want to clean those because you have finish 29 your testing sessions, you can run this command: 30 31 ```sh 32 bundle exec ruby clean.rb 33 ``` 34 35 You can also run the tests in parallel with: 36 37 ```sh 38 go run parallel-runner.go -n 3 -fail-fast 39 ``` 40 41 42 ## Interactive mode 43 44 It's possible to do manual tests and to use the tools in an interactive mode 45 to setup the sharing, create and update documents, etc. 46 47 ```sh 48 bundle exec ./console.rb 49 ``` 50 51 Example of session: 52 53 ```ruby 54 b = Bootstrap.push_folder 55 ap b.sharing 56 b.open 57 b.accept 58 b.recipients.first.open 59 ``` 60 61 ## Compare trees 62 63 It can be useful for debugging to compare tree with a visual representation. 64 You can generate an image with this ruby code: 65 66 ```ruby 67 Debug.visualize_tree [inst, inst_recipient], sharing 68 ``` 69 70 ## Swift 71 72 It's complicated to launch the tests with Swift, but it's possible to simulate 73 it with swifttest: 74 75 ```sh 76 $ go run ./tests/swift 77 $ cd tests/system 78 $ export COZY_SWIFTTEST=1 79 $ bundle exec ruby tests/sharing_push_folder.rb 80 ``` 81 82 ## REST Client 83 84 The Ruby library used for making HTTP requests is [REST 85 Client](https://github.com/rest-client/rest-client). It can be told to log 86 requests by setting an environment variable: 87 88 ```sh 89 $ export RESTCLIENT_LOG=stdout 90 ``` 91 92 ## Logs 93 94 The log files for the stack are kept inside the `tmp/` directory. You can use 95 [lnav](http://lnav.org/) tool to view them. The log format of cozy-stack can 96 installed with: 97 98 ```sh 99 lnav -i cozy-stack/scripts/lnav_cozy_log.json 100 ```