|
1 | 1 | Testing and Deploying a Generic IOC
|
2 | 2 | ===================================
|
3 | 3 |
|
| 4 | +Continuous Integration |
| 5 | +---------------------- |
| 6 | + |
| 7 | +An important feature of epics-containers is CI. The ioc-template that we |
| 8 | +based ioc-adurl upon has built-in CI for GitHub (and DLS internal GitLab). |
| 9 | + |
| 10 | +The first thing we will do is get the project pushed up to GitHub and |
| 11 | +verify that the CI is working. |
| 12 | + |
| 13 | +Before pushing the project we must push our changes to the submodule ibek-defs, |
| 14 | +then we can push the main project to GitHub too: |
| 15 | + |
| 16 | +.. code-block:: bash |
| 17 | +
|
| 18 | + cd ibek-defs |
| 19 | + git add . |
| 20 | + git commit -m "Added ADURL" |
| 21 | + git push |
| 22 | + cd .. |
| 23 | + git add . |
| 24 | + git commit -m "update the template to ADUrl" |
| 25 | + git push |
| 26 | +
|
| 27 | +If you now go up to the GitHub page for the project and click on ``Actions`` |
| 28 | +and click on the latest build you should see something like this: |
| 29 | + |
| 30 | +.. figure:: ../images/github_actions2.png |
| 31 | + |
| 32 | + GitHub Actions for ioc-adurl |
| 33 | + |
| 34 | +This build should succeed. |
| 35 | + |
| 36 | +Publishing the Generic IOC Container to GHCR |
| 37 | +-------------------------------------------- |
| 38 | + |
| 39 | +Now give your genericIOC a version tag and push it to GitHub. |
| 40 | +.. code-block:: bash |
| 41 | +
|
| 42 | + git tag 23.4.1 |
| 43 | + git push origin 23.4.1 |
| 44 | +
|
| 45 | +You will see the CI rebuild the container and push it to the GitHub container |
| 46 | +registry at github.io/<YOUR GITHUB USER>/ioc-adurl:<YOUR TAG>. |
| 47 | + |
| 48 | +This time the build will take 2 minutes. Last time it took 10 minutes |
| 49 | +(because we were building areaDetector and graphicsMagick). The speed up |
| 50 | +is because we keep a build cache in GitHub actions. |
| 51 | + |
| 52 | +Once the build is complete, if you go to your project page on GitHub |
| 53 | +https://github.com/<YOUR GITHUB ACCOUNT>/ioc-adurl you should now see a |
| 54 | +``Packages`` tab. Click on the developer package and and you should see |
| 55 | +something like this: |
| 56 | + |
| 57 | +.. figure:: ../images/ghcr.png |
| 58 | + |
| 59 | + The ioc-adurl container on GHCR |
| 60 | + |
| 61 | +This means that the container is now available for anyone to use with a |
| 62 | +``podman/docker pull`` command as described in the ``Installation`` tab. |
| 63 | + |
| 64 | + |
| 65 | +Making the Tests Relevant to our Generic IOC |
| 66 | +-------------------------------------------- |
| 67 | + |
| 68 | +You may notice that some tests were run as part of the CI. These generic |
| 69 | +tests are used by the ioc-template and are defined in the ``tests`` directory. |
| 70 | +We need to update them to be relevant to our new generic IOC. |
| 71 | + |
| 72 | +TODO: I just noticed that the tests do not use the build cache (but also |
| 73 | +they are not required to push the built container so don't hold up |
| 74 | +development). |
| 75 | + |
| 76 | +In the ``ioc/config`` folder we have some default config that is used by the |
| 77 | +generic IOC if no config is provided. We can use this for testing and need |
| 78 | +to update the tests to use it too. |
| 79 | + |
| 80 | +To do this remove the file ``ioc/config/ioc.db`` and replace the contents |
| 81 | +of ``ioc/config/st.cmd`` with: |
| 82 | + |
| 83 | +.. code-block:: |
| 84 | +
|
| 85 | + cd "$(TOP)" |
| 86 | +
|
| 87 | + dbLoadDatabase "dbd/ioc.dbd" |
| 88 | + ioc_registerRecordDeviceDriver(pdbbase) |
| 89 | +
|
| 90 | + URLDriverConfig("EXAMPLE.CAM", 0, 0) |
| 91 | +
|
| 92 | + # NDPvaConfigure(portName, queueSize, blockingCallbacks, NDArrayPort, NDArrayAddr, pvName, maxMemory, priority, stackSize) |
| 93 | + NDPvaConfigure("EXAMPLE.PVA", 2, 0, "EXAMPLE.CAM", 0, "EXAMPLE:IMAGE", 0, 0, 0) |
| 94 | + startPVAServer |
| 95 | +
|
| 96 | + # instantiate Database records for Url Detector |
| 97 | + dbLoadRecords("URLDriver.template","P=EXAMPLE, R=:CAM:, PORT=EXAMPLE.CAM, TIMEOUT=1, ADDR=0") |
| 98 | + dbLoadRecords("NDPva.template", "P=EXAMPLE, R=:PVA:, PORT=EXAMPLE.PVA, ADDR=0, TIMEOUT=1, NDARRAY_PORT=EXAMPLE.CAM, NDARRAY_ADR=0, ENABLED=1") |
| 99 | +
|
| 100 | + # start IOC shell |
| 101 | + iocInit |
| 102 | +
|
| 103 | + # poke some records |
| 104 | + dbpf "EXAMPLE:CAM:AcquirePeriod", "0.1" |
| 105 | +
|
| 106 | +Next, remove the folders ``tests/example-config`` and ``tests/example-ibek-config``. |
| 107 | + |
| 108 | +Then edit the ``tests/run_tests.sh`` file. Remove the test blocks titled |
| 109 | +``Test an ibek IOC`` and ``Test a hand coded st.cmd IOC`` leaving just the |
| 110 | +block called ``Test the default example IOC``. Finally edit the block to |
| 111 | +look like this: |
| 112 | + |
| 113 | +.. code-block:: bash |
| 114 | +
|
| 115 | +
|
| 116 | + ... |
| 117 | + fi |
| 118 | + podman run ${ioc_args} |
| 119 | + check_pv 'EXAMPLE:CAM:AcquirePeriod' '0.1' |
| 120 | +
|
| 121 | +Now try out the test with the following command: |
| 122 | + |
| 123 | +.. code-block:: bash |
| 124 | +
|
| 125 | + ./tests/run_tests.sh |
| 126 | +
|
| 127 | +We have made a very simple test that only checks one PV value, but that is |
| 128 | +good enough to validate that the IOC is running and that the config is |
| 129 | +being loaded. You can add more sophisticated tests as needed to your |
| 130 | +own generic IOCs. |
| 131 | + |
| 132 | +If you had any issues with getting this tutorial working, you can get a |
| 133 | +fully working version of the ioc-adurl project from the following link: |
| 134 | + |
| 135 | + https://github.com/epics-containers/ioc-adurl |
| 136 | + |
| 137 | +Try out some GUI |
| 138 | +---------------- |
| 139 | + |
| 140 | +To make the example more interesting I have provided an edm screen for it. |
| 141 | + |
| 142 | +After running the tests in the previous section you should have a running |
| 143 | +container still active. You can see this using ``podman ps``. You should |
| 144 | +see that ``ioc-template-test-container`` is still running. You can start it |
| 145 | +again with ``tests/run_tests.sh`` if it is not. |
| 146 | + |
| 147 | +Now get the edm screens and launch them as follows. |
| 148 | + |
| 149 | +.. code-block:: bash |
| 150 | +
|
| 151 | + cd /tmp |
| 152 | + git clone [email protected]:epics-containers/ioc-adurl.git |
| 153 | + cd ioc-adurl |
| 154 | + opi/example.sh |
| 155 | +
|
| 156 | +You should see the C2DataViewer. Click on auto button and you should see: |
| 157 | + |
| 158 | +.. figure:: ../images/millie.png |
| 159 | + |
| 160 | + Millie the Labradoodle |
| 161 | + |
| 162 | +To work out how Millie got into the viewer, take a look at example.sh, I leave |
| 163 | +this as an exercise for the reader. |
| 164 | + |
| 165 | + |
4 | 166 |
|
5 |
| -don't forget to remove the RTEMS build from CI. |
|
0 commit comments