1 = Testing = 2 3 Before attempting to integrate imip-agent with other system components, 4 it can be useful to check whether the different programs function as 5 expected by themselves. Should errors or faults occur, these would need 6 to be remedied first before attempting to get the software working with 7 the [[../MailIntegration|mail]] and [[../WebServerIntegration|Web]] 8 system components. 9 10 <<TableOfContents(2,2)>> 11 12 == How the Software Works == 13 14 To see how the software operates, you can run one of the agent programs 15 provided in the distribution. For example: 16 17 {{{ 18 ./imip_resource.py -S xxx/store -P xxx/static -p xxx/prefs -d \ 19 < tests/templates/event-request.txt 20 }}} 21 22 This uses one of the test files, sending it to the agent program for 23 resource entities, producing output resembling the following: 24 25 {{{ 26 Outgoing parts for paul.boddie@example.com... 27 From nobody Wed Oct 28 00:24:41 2015 28 MIME-Version: 1.0 29 Content-Transfer-Encoding: base64 30 Content-Type: text/calendar; charset="utf-8"; method="REPLY" 31 From: calendar@example.com 32 To: paul.boddie@example.com 33 Subject: Calendar system message 34 35 QkVHSU46VkNBTEVOREFSDQpNRVRIT0Q6UkVQTFkNClZFUlNJT046Mi4wDQpCRUdJTjpWRlJFRUJV 36 U1kNCk9SR0FOSVpFUjptYWlsdG86cGF1bC5ib2RkaWVAZXhhbXBsZS5jb20NCkFUVEVOREVFO1NF 37 TlQtQlk9Im1haWx0bzpjYWxlbmRhckBleGFtcGxlLmNvbSI6bWFpbHRvOnJlc291cmNlLXJvb20t 38 Y29uZnJvb20NCiBAZXhhbXBsZS5jb20NClVJRDpmYjFAZXhhbXBsZS5jb20NCkVORDpWRlJFRUJV 39 U1kNCkVORDpWQ0FMRU5EQVINCg== 40 }}} 41 42 The rather opaque encoding can be inspected using the `tools/showmail.py` 43 program, and thus the result of the script can be seen by piping the output 44 through that program as follows: 45 46 {{{ 47 ./imip_resource.py -S xxx/store/ -P xxx/static/ -p xxx/prefs/ -d \ 48 < tests/templates/event-request.txt \ 49 | tools/showmail.py 50 }}} 51 52 The result should resemble the following: 53 54 {{{ 55 Outgoing parts for paul.boddie@example.com... 56 MIME-Version: 1.0 57 Content-Type: text/calendar; charset="utf-8"; method="REPLY" 58 From: calendar@example.com 59 To: paul.boddie@example.com 60 Subject: Calendar system message 61 62 BEGIN:VCALENDAR 63 METHOD:REPLY 64 VERSION:2.0 65 BEGIN:VEVENT 66 DTSTAMP:20151027T232738Z 67 UID:event1@example.com 68 ATTENDEE;PARTSTAT=ACCEPTED;SENT-BY="mailto:calendar@example.com":mailto:reso 69 urce-room-confroom@example.com 70 SUMMARY:Meeting at 4pm 71 ORGANIZER:mailto:paul.boddie@example.com 72 DTSTART;TZID=Europe/Oslo:20141126T160000 73 DTEND;TZID=Europe/Oslo:20141126T170000 74 END:VEVENT 75 END:VCALENDAR 76 }}} 77 78 What has happened here is the presentation of a request to the resource 79 program in the form of an e-mail message containing an iCalendar event 80 employing a scheduling method. The program interprets the request, 81 consults its own records, makes a decision about scheduling the event, 82 and indicates the kind of response it would like to send back to the 83 requester. 84 85 == The Test Suite == 86 87 A script called `test_all.sh` is provided that runs a test suite (found 88 in the `tests` directory within the source code distribution), initialising 89 new and separate data store instances for each test, running programs that 90 are presented with message content, and testing for the desired effects of 91 running those programs with such content. 92 93 {{{ 94 ./test_all.sh 95 }}} 96 97 The test suite by default (or by indicating `file` as the data store type), 98 records test information in subdirectories of `/tmp`. 99 100 To run all tests against a different data store, such as a 101 [[../DatabaseStore|database store]] instead of the [[../FileStore|file store]], 102 the `STORE_TYPE` environment variable can be specified as in the following 103 example: 104 105 {{{ 106 STORE_TYPE=postgresql ./test_all.sh 107 }}} 108 109 The test suite records `postgresql` tests in a specially-created database 110 called `imip_agent_test` that the system user running the tests must be allowed 111 to create and drop. This may require the granting of administrative rights 112 within PostgreSQL for the system user concerned. 113 114 Individual tests may also be run directly from the topmost level of the 115 source code distribution. For example: 116 117 {{{ 118 tests/test_resource_invitation.sh 119 }}} 120 121 Should everything be functioning correctly, `Success` should be reported 122 repeatedly as opposed to `Failed`. If the latter occurs, the output of the 123 tests should be inspected: a number of files whose names end with `.tmp` 124 will have been saved in the current directory, and these will contain the 125 output from various commands from the last test script invocation; the 126 `err.tmp` will contain tracebacks indicating serious error conditions, 127 should any have occurred. 128 129 == Testing in the Deployment Environment == 130 131 Although the above testing may indicate that the software is functional, 132 it does not demonstrate that the software has been successfully integrated 133 into the deployment environment. One elementary test involves sending mail 134 to an address that should be configured to handle incoming calendar messages. 135 136 A basic script is provided that replicates a subset of the functionality in 137 the traditional `mail` command for sending messages. It is invoked by 138 specifying the sender and recipients of a message and by passing the message 139 itself to the script's standard input. For example: 140 141 {{{ 142 tools/sendmail.py paul.boddie@example.com resource-room-confroom@example.com \ 143 < tests/templates/event-request.txt 144 }}} 145 146 Here, the sender (`paul.boddie@example.com`) and recipient 147 (`resource-room-confroom@example.com`) must match the identities specified 148 within the supplied file (`tests/templates/event-request.txt`), and for a 149 specific deployment environment these identities will need to be changed. 150 The following lines from the supplied file would be involved: 151 152 {{{ 153 From: paul.boddie@example.com 154 To: resource-room-confroom@example.com 155 ORGANIZER:mailto:paul.boddie@example.com 156 ATTENDEE;ROLE=CHAIR:mailto:paul.boddie@example.com 157 ATTENDEE;RSVP=TRUE:mailto:resource-room-confroom@example.com 158 }}} 159 160 It makes most sense to choose a recipient acting as a resource so that an 161 automated response may be generated with the sender receiving this response. 162 However, other kinds of recipients may also be tested in this way. 163 164 The result of this invocation will become known via the following sources of 165 information: 166 167 * The sender's mailbox (if the recipient sends an automated response) 168 * The sender's data store 169 * The recipient's mailbox (if the recipient is configured to store mail) 170 * The recipient's data store 171 * Mail system logs (particularly in case of errors) 172 173 See the [[../MailIntegration|mail integration guide]] for more information 174 about configuring and troubleshooting mail systems.