738f30ab7bb281abb28252244da4ed9924de0de4
[releng.git] / utils / test / result_collection_api / update / README.md
1 Welcome to TESTAPI Update!
2 ========================
3
4
5 This file is used to describe how testapi update works
6
7 ----------
8 How to use
9 ---------------
10
11 #### <i class="icon-file"></i> backup mongodb
12
13 arguments:
14 : -u/--url: Mongo DB URL, default = mongodb://127.0.0.1:27017/
15 the backup output will be put under dir/db__XXXX_XX_XX_XXXXXX/db
16 -d/--db: database for the backup, default = test_results_collection
17
18 usage:
19 ```
20 python backup_mongodb.py
21 ```
22
23 #### <i class="icon-file"></i> restore mongodb
24
25 arguments:
26 : -u/--url: Mongo DB URL, default = mongodb://127.0.0.1:27017/
27   -i/--input_dir: Input directory for the Restore, must be specified,
28   the restore input must be specified to dir/db__XXXX_XX_XX_XXXXXX/db
29   -d/--db: database name after the restore, default = basename of input_dir
30
31 usage:
32 ```
33 python restore_mongodb.py
34 ```
35 #### <i class="icon-file"></i> update mongodb
36
37  arguments:
38 : -u/--url: Mongo DB URL, default = mongodb://127.0.0.1:27017/
39  -d/--db: database name to be updated, default = test_results_collection
40
41 changes need to be done:
42 change collection name, modify changes.collections_old2New
43  > collections_old2New = {
44      'old_collection': 'new_collection',
45  }
46
47  change field name, modify changes.fields_old2New
48  > fields_old2New = {
49      'collection': [(query, {'old_field': 'new_field'})]
50  }
51
52  change the doc, modify changes.docs_old2New
53  > docs_old2New = {
54      'test_results': [
55          ({'field': 'old_value'}, {'field': 'new_value'}),
56          (query, {'field': 'new_value'}),
57      ]
58  }
59
60 #### <i class="icon-file"></i> update opnfv-testapi process
61 This script must be run right in this directory and remember to
62 change ../etc/config.ini before running this script.
63
64 operations includes:
65 : kill running test_collection_api & opnfv-testapi
66 install or update dependencies according to ../requirements.txt
67 install opnfv-testapi
68 run opnfv-testapi
69
70 usage:
71 ```
72 python update_api.py
73 ```
74 #### <i class="icon-file"></i> update opnfv/testapi container
75 Here ansible-playbook is used to implement auto update.
76 Please make sure that the remote server is accessible via ssh.
77
78 install ansible, please refer:
79 ```
80 http://docs.ansible.com/ansible/intro_installation.html
81 ```
82 run update.yml
83 arguments:
84 : host: remote server, must provide
85 user: user used to access to remote server, default to root
86 port: exposed port used to access to testapi, default to 8000
87 image: testapi's docker image, default to opnfv/testapi:latest
88 update_path: templates directory in remote server, default to /tmp/testapi
89 mongodb_url: url of mongodb, default to 172.17.0.1, docker0 ip
90 swagger_url: swagger access url, default to http://host:port
91
92 usage:
93 ```
94 ansible-playbook update.yml --extra-vars "
95 host=10.63.243.17
96 user=zte
97 port=8000
98 image=opnfv/testapi
99 mode=build
100 update_path=/tmp/testapi
101 mongodb_url=mongodb://172.17.0.1:27017
102 swagger_url=http://10.63.243.17:8000"```
103 > **Note:**
104
105 > - If documents need to be changed, please modify file
106 templates/changes_in_mongodb.py, and refer section **update mongodb**