...

Text file src/edge-infra.dev/cmd/sds/novnc/README.md

Documentation: edge-infra.dev/cmd/sds/novnc

     1
     2## NoVNC container Build
     3
     4This directory contains the bazel rules to build the novnc container image,
     5which includes nginx configuration to serve the NoVNC html files
     6and act as a proxy for websocket connections.
     7Nginx in the container should be started by running the `runNginx.sh` script,
     8which is used to perform all necessary pre-start steps,
     9as well as running nginx itself.
    10
    11### vnc_lite.html
    12
    13**Note:** Most of this section is old, out of date and unlikely to work as is.
    14Locally hosting vnc_lite.html can still work,
    15however it requires much more manual interaction and may no longer be the easiest method of development.
    16This section is no longer officially supported, enter at your own risk.
    17
    18Changes have been made to the default `vnc_lite.html` provided by NoVNC to customise it to include dsds specific requirements.
    19These changes can be seen [below](#vnc_litehtml-changes).
    20A copy of the file is included in the repo at `novnc/vnc_lite.html`, which is copied over the file provided by NoVNC during the novnc container build.
    21
    22To make changes to the vnc_lite.html file, it is usually easier to serve novnc locally, which allows you to quckly edit the files in a familiar development environment and view the changes in your web browser.
    23To do this you will need a copy of the novnc repo and the edge-infra repo cloned locally, and you will need access to an IEN with a working novnc container.
    24
    25Follow these steps, making sure to update the repo locations on your machine `EDGE_INFRA` and `NOVNC`:
    26
    27```bash
    28# Tag from build_script.sh
    29NOVNC_TAG="v1.3.0"
    30
    31# Repo location
    32EDGE_INFRA="${HOME}/edge/edge-infra"
    33NOVNC="${HOME}/vnc/noVNC/noVNC"
    34
    35# Checkout correct version
    36cd "${NOVNC}"
    37git checkout "${NOVNC_TAG}"
    38
    39# Copy the edge-infra version of vnc_lite.html into the novnc repo
    40ln -s "${EDGE_INFRA}/cmd/sds/novnc/novnc/vnc_lite.html" index.html
    41
    42# Copy in the svg icons into the novnc repo
    43ln -s "${EDGE_INFRA}/cmd/sds/novnc/novnc/favicon.svg" favicon.svg
    44ln -s "${EDGE_INFRA}/cmd/sds/novnc/novnc/visibility.svg" visibility.svg
    45ln -s "${EDGE_INFRA}/cmd/sds/novnc/novnc/visibility_off.svg" visibility_off.svg
    46
    47# serve the vnc_lite.html, defaults to port 8000
    48python3 -m http.server >> server.log 2>&1 &
    49```
    50
    51Set up port forwarding for access to the websocket proxy
    52
    53```bash
    54kubectl port-forward services/novnc 8081:80
    55```
    56
    57You can now access vnc_lite.html in the browser at an address such as `http://localhost:8000/?port=8081&path=/ws?token=ien-a0163e00000a`.
    58
    59For testing the `clusterName` and `bannerName` parameters:
    60`http://localhost:8000/?bannerName=my-test-banner&clusterName=my-test-store&port=8081&path=/ws?token=ien-a0163e00000a`
    61
    62You can now make edits to the local copy of vnc_lite.html in the edge-infra repo and refresh the browser to see those updates.
    63
    64**Note: Testing this way should only be used during development of a new feature.**
    65**You should always test the feature fully by recreating the container and applying it to an IEN before it is considered complete**
    66
    67### vnc_lite.html changes
    68
    69**Note:** Additional updates have been done in the meantime
    70
    71This summarises the changes made to the NoVNC version of vnc_lite.html
    72
    731. Update titlebar and banner with node, cluster and banner name
    741. Add an auto reconnect capability - if connection to the VNC server were to be lost, then a feature has been added to attempt reconnection automatically if the browser tab is still in focus.
    751. Replace use of browser prompt with a modal to request password when connecting.
    761. Simplify required url by removing the need to duplicate store and banner id in the websocket path
    77
    78
    79
    80## Integration Testing
    81
    82Integration tests for novnc are defined in the `novnc_test.go` file.
    83These are L2 integration tests, and will require a kind cluster if you wish to run them locally.
    84A mock vncserver is created in the kind cluster by installing a simple websocket server as a daemon set that returns its host node name.
    85The `local` kustomization of the novnc component is then installed into the test namespace.
    86
    87### Setup
    88
    89The integration tests also depend on the `daemonsetdns` component.
    90The integration tests will install the `daemonsetdns` component into the cluster if it does not already exist on the cluster, or it will use the existing component if it is present on the cluster.
    91For the integration tests to successfully install the component they will need access to the container image, which can be done by building and pushing the image:
    92
    93```bash
    94just push --bazel-configs=local cmd/sds/daemonsetdns/...
    95```
    96
    97
    98#### Re-Installing the Daemonsetdns component
    99
   100If changes have been made to the daemonsetdns component you may wish to test novnc with the new version of daemonsetdns.
   101To do this you will need to remove the existing `daemonsetdns` component from the cluster for the tests to install the new version the next time they are run.
   102This can be done using the following commands
   103
   104```bash
   105kubectl delete clusterrole daemonsetdns
   106kubectl delete clusterrolebindings daemonsetdns
   107kubectl delete ns daemonsetdns
   108```
   109
   110### Testing
   111
   112To run the tests locally, first push all required containers:
   113
   114```bash
   115just push --bazel-configs=local cmd/sds/vnc/...
   116just push --bazel-configs=local cmd/sds/novnc/...
   117```
   118
   119When running the tests you may need to specify that the tests should use the local registry, which can be done using the `--workloads_repo=localhost:21700` argument.
   120
   121The test can be run using bazel, e.g.
   122
   123```
   124bazel test --workloads_repo=localhost:21700 --nocache_test_results //cmd/sds/novnc:novnc_test --config=integration --test_arg=-integration-level=2
   125```
   126
   127or using `rosa`:
   128
   129```
   130rosa //cmd/sds/novnc:novnc_test --workloads_repo=localhost:21700 -- -integration-level=2
   131```

View as plain text