diff options
Diffstat (limited to 'report/deliverable-3')
31 files changed, 712 insertions, 0 deletions
diff --git a/report/deliverable-3/Makefile b/report/deliverable-3/Makefile new file mode 100644 index 0000000..135009b --- /dev/null +++ b/report/deliverable-3/Makefile @@ -0,0 +1,9 @@ +.PHONY: default clean FORCE + +default : main.pdf + +%.pdf : %.tex FORCE + latexmk -pdf $< + +clean : + latexmk -C diff --git a/report/deliverable-3/appendix/minutes.tex b/report/deliverable-3/appendix/minutes.tex new file mode 100644 index 0000000..44aa702 --- /dev/null +++ b/report/deliverable-3/appendix/minutes.tex @@ -0,0 +1,68 @@ +\section{Meeting Minutes}\label{app:meet} +\begin{lstlisting} + +Group Project Meeting 1 post submission +Date: 12/02/18 +Topics: +Reassigning scrum roles +Creating next set of tasks +Task allocation + +Outcomes: +* Scrum: + * scrum master - Hafeez + * project owner - Calum + +*Tasks: + * Implementing endpoints + * Implementing file conversions + * Improving test coverage + * Writing tests for untested sections + * Connecting all middleware + * Decide on how to deal with errors + * Organising file-system + * Creating a Linter to maintain a consistent file structure + +Group Project Meeting 2 Pre-sprint +Date 19/02/18 +Topics: +Define user stories +Task allocation + +Outcomes: +* Sprint + * 2 Week long sprint + * Mid sprint meeting set for 26/02/18 +* Images + * Dealing with leica and zeiss files +* Testing + * Implementing unit and integration tests +* Logger + * Standard and SQL logger + + +Group Project Meeting 3 mid-Sprint +Date 26/02/18 +Topics: +updating progress + +Outcomes: +* Images + * Continued work on image files + * File extraction and testing + * Stitching +* Logger + * Needed a better one to log problems + +Group Project Meeting 4 post-sprint +Date 05/03/18 +Topics +Final tasks required before deadline + +Outcomes: + * Finishing off of the report + * Finish testing + * Process manager + * Hosting on heroku + +\end{lstlisting} diff --git a/report/deliverable-3/appendix/scrumboard.tex b/report/deliverable-3/appendix/scrumboard.tex new file mode 100644 index 0000000..e868278 --- /dev/null +++ b/report/deliverable-3/appendix/scrumboard.tex @@ -0,0 +1,8 @@ +\section{Scrum Board Images} \label{app:board} + +{ +\centering +\includegraphics[width=\textwidth]{graphics/scrum.jpg} +\includegraphics[width=\textwidth]{graphics/scrum3.jpg} +\includegraphics[width=\textwidth]{graphics/scrum4.jpg} +} diff --git a/report/deliverable-3/biblio.bib b/report/deliverable-3/biblio.bib new file mode 100644 index 0000000..fdfc56b --- /dev/null +++ b/report/deliverable-3/biblio.bib @@ -0,0 +1,189 @@ +@misc {tslint, + howpublished = {https://palantir.github.io/tslint/}, + title = {TSLint}, + publisher = {Palantir Technologies}, + year = {2016}, + note = {Accessed: 2018-03-01} +} + +@misc {protocol, + howpublished = {https://github.com/CS3099JH2017/cs3099jh/tree/master/protocols}, + title = {CS3099JH2017 Protocol}, + publisher = {CS3099 Year Group of 2017/18}, + year = {2018}, + note = {Accessed: 2018-03-02} +} + +@misc {yarn, + howpublished = {https://yarnpkg.com/en/docs}, + title = {Yarn}, + publisher = {Yarn Organization}, + note = {Accessed: 2018-03-02} +} + +@misc {typescript, + howpublished = {https://www.typescriptlang.org/docs/home.html}, + title = {TypeScript}, + publisher = {Microsoft}, + year = {2017}, + note = {Accessed: 2018-03-02} +} + +@misc {sequelize, + howpublished = {http://docs.sequelizejs.com/}, + title = {Sequelize}, + publisher = {Sequelize}, + note = {Accessed: 2018-03-02} +} + +@misc {sequelize-typescript, + howpublished = {https://github.com/RobinBuschmann/sequelize-typescript}, + title = {sequelize-typescript}, + publisher = {Robin Buschmann}, + note = {Accessed: 2018-03-02} +} + +@misc {postgres, + howpublished = {https://www.postgresql.org/docs/}, + title = {PostreSQL}, + publisher = {The PostgreSQL Global Development Group}, + year = {2018}, + note = {Accessed: 2018-03-02} +} + +@misc {mocha, + howpublished = {https://mochajs.org/}, + title = {Mocha}, + publisher = {mochajs}, + note = {Accessed: 2018-03-02} +} + +@misc {mocha-each, + howpublished = {https://github.com/ryym/mocha-each}, + title = {mocha-each}, + publisher = {ryym}, + note = {Accessed: 2018-03-02} +} + +@misc {chai, + howpublished = {http://chaijs.com/api/bdd/}, + title = {Chai Assertion Library}, + publisher = {chaijs}, + note = {Accessed: 2018-03-02} +} + +@misc {chai-http, + howpublished = {http://chaijs.com/plugins/chai-http/}, + title = {Chai HTTP}, + publisher = {chaijs}, + note = {Accessed: 2018-03-02} +} + +@misc {express, + howpublished = {https://expressjs.com/en/4x/api.html}, + title = {Express 4.x}, + publisher = {expressjs}, + year = {2017}, + note = {Accessed: 2018-03-02} +} + +@misc {passport, + howpublished = {http://www.passportjs.org/docs/}, + title = {Passport}, + publisher = {Jared Hanson}, + note = {Accessed: 2018-03-02} +} + +@misc {passport-local, + howpublished = {https://github.com/jaredhanson/passport-local}, + title = {passport-local}, + publisher = {Jared Hanson}, + note = {Accessed: 2018-03-02} +} + +@misc {morgan, + howpublished = {https://github.com/expressjs/morgan}, + title = {morgan}, + publisher = {expressjs}, + note = {Accessed: 2018-03-02} +} + +@misc {typedoc, + howpublished = {http://typedoc.org/guides/usage/}, + title = {TypeDoc}, + publisher = {TypeStrong}, + note = {Accessed: 2018-03-02} +} + +@misc {xlsx, + howpublished = {https://github.com/sheetjs/js-xlsx}, + title = {js-xlsx}, + publisher = {SheetJS}, + note = {Accessed: 2018-03-02} +} + +@misc {docker, + howpublished = {https://hub.docker.com/}, + title = {Docker Hub}, + publisher = {Docker Inc.}, + year = {2016}, + note = {Accessed: 2018-03-02} +} + +@misc {@types, + howpublished = {http://definitelytyped.org/}, + title = {DefinitelyTyped}, + publisher = {DefinitelyTyped}, + year = {2017}, + note = {Accessed: 2018-03-02} +} + +@misc {strongloop, + howpublished = {https://strongloop.com/}, + title = {StrongLoop}, + publisher = {IBM}, + year = {2018}, + note = {Accessed: 2018-03-07} +} + +@misc {pm2, + howpublished = {http://pm2.keymetrics.io/}, + title = {pm2}, + publisher = {KeyMetrics}, + note = {Accessed: 2018-03-07} +} + +@misc {forever, + howpublished = {https://github.com/foreverjs/forever}, + title = {foreverjs}, + publisher = {foreverjs}, + note = {Accessed: 2018-03-07} +} + +@misc {sharp, + howpublished = {https://github.com/lovell/sharp}, + title = {sharp}, + publisher = {Lovell Fuller}, + note = {Accessed: 2018-03-06} +} + +@misc {sharpPerformance, + howpublished = {http://sharp.pixelplumbing.com/en/stable/performance/}, + title = {Sharp Performance}, + publisher = {Lovell Fuller}, + note = {Accessed: 2018-03-06} +} + +@misc {zeissLicence, + howpublished = {https://www.zeiss.com/microscopy/int/products/microscope-software/czi/czi-download.html}, + title = {Apply for Zeiss Licence}, + publisher = {Carl Zeiss Microscopy GmbH}, + note = {Accessed: 2018-03-06} +} + +@misc {openseadragon, + howpublished = {https://openseadragon.github.io/docs/}, + title = {OpenSeadDragon}, + publisher = {openseadragon}, + note = {Accessed: 2019-03-07} +} diff --git a/report/deliverable-3/graphics/1.png b/report/deliverable-3/graphics/1.png Binary files differnew file mode 100644 index 0000000..089b8ef --- /dev/null +++ b/report/deliverable-3/graphics/1.png diff --git a/report/deliverable-3/graphics/2.png b/report/deliverable-3/graphics/2.png Binary files differnew file mode 100644 index 0000000..1714110 --- /dev/null +++ b/report/deliverable-3/graphics/2.png diff --git a/report/deliverable-3/graphics/3.png b/report/deliverable-3/graphics/3.png Binary files differnew file mode 100644 index 0000000..7eef8dc --- /dev/null +++ b/report/deliverable-3/graphics/3.png diff --git a/report/deliverable-3/graphics/4.png b/report/deliverable-3/graphics/4.png Binary files differnew file mode 100644 index 0000000..8379ef7 --- /dev/null +++ b/report/deliverable-3/graphics/4.png diff --git a/report/deliverable-3/graphics/5.png b/report/deliverable-3/graphics/5.png Binary files differnew file mode 100644 index 0000000..aeea913 --- /dev/null +++ b/report/deliverable-3/graphics/5.png diff --git a/report/deliverable-3/graphics/6.png b/report/deliverable-3/graphics/6.png Binary files differnew file mode 100644 index 0000000..e3fb624 --- /dev/null +++ b/report/deliverable-3/graphics/6.png diff --git a/report/deliverable-3/graphics/7.png b/report/deliverable-3/graphics/7.png Binary files differnew file mode 100644 index 0000000..a917d83 --- /dev/null +++ b/report/deliverable-3/graphics/7.png diff --git a/report/deliverable-3/graphics/burndown.png b/report/deliverable-3/graphics/burndown.png Binary files differnew file mode 100644 index 0000000..f3ae71d --- /dev/null +++ b/report/deliverable-3/graphics/burndown.png diff --git a/report/deliverable-3/graphics/km-dash.png b/report/deliverable-3/graphics/km-dash.png Binary files differnew file mode 100644 index 0000000..840395d --- /dev/null +++ b/report/deliverable-3/graphics/km-dash.png diff --git a/report/deliverable-3/graphics/scrum.jpg b/report/deliverable-3/graphics/scrum.jpg Binary files differnew file mode 100644 index 0000000..4b5c911 --- /dev/null +++ b/report/deliverable-3/graphics/scrum.jpg diff --git a/report/deliverable-3/graphics/scrum2.jpg b/report/deliverable-3/graphics/scrum2.jpg Binary files differnew file mode 100644 index 0000000..231cf1f --- /dev/null +++ b/report/deliverable-3/graphics/scrum2.jpg diff --git a/report/deliverable-3/graphics/scrum3.jpg b/report/deliverable-3/graphics/scrum3.jpg Binary files differnew file mode 100644 index 0000000..012e9b3 --- /dev/null +++ b/report/deliverable-3/graphics/scrum3.jpg diff --git a/report/deliverable-3/graphics/scrum4.jpg b/report/deliverable-3/graphics/scrum4.jpg Binary files differnew file mode 100644 index 0000000..ab1f7a5 --- /dev/null +++ b/report/deliverable-3/graphics/scrum4.jpg diff --git a/report/deliverable-3/graphics/scrum5.jpg b/report/deliverable-3/graphics/scrum5.jpg Binary files differnew file mode 100644 index 0000000..e79e828 --- /dev/null +++ b/report/deliverable-3/graphics/scrum5.jpg diff --git a/report/deliverable-3/graphics/title-logo.png b/report/deliverable-3/graphics/title-logo.png Binary files differnew file mode 100644 index 0000000..8a72423 --- /dev/null +++ b/report/deliverable-3/graphics/title-logo.png diff --git a/report/deliverable-3/main.tex b/report/deliverable-3/main.tex new file mode 100644 index 0000000..dce9106 --- /dev/null +++ b/report/deliverable-3/main.tex @@ -0,0 +1,38 @@ +\input{preamble} + +\input{title} + +\begin{document} + + \maketitle + \thispagestyle{empty} + \newpage + \setcounter{page}{1} + + \tableofcontents + \newpage + + \input{texts/aims} + \input{texts/scrum} + \input{texts/conversion} + % \input{texts/protocol} + % \input{texts/auth} + \input{texts/logging} + \input{texts/process-management} + \input{texts/testing} + \input{texts/typings} + \input{texts/conclusion} + + \appendix + \newpage + \input{appendix/scrumboard} + \newpage + \input{appendix/minutes} + + \clearpage + + \nocite{*} + \bibliography{biblio}{} + \bibliographystyle{plain} + +\end{document} diff --git a/report/deliverable-3/preamble.tex b/report/deliverable-3/preamble.tex new file mode 100644 index 0000000..14787a9 --- /dev/null +++ b/report/deliverable-3/preamble.tex @@ -0,0 +1,13 @@ +\documentclass{article} + +\usepackage[margin=1in]{geometry} +\usepackage{a4wide} + +\usepackage{graphicx} +\graphicspath{{./graphics/}} + +\usepackage{float} +\usepackage{listings} +\usepackage{cite} + +\def\file{\texttt} diff --git a/report/deliverable-3/texts/aims.tex b/report/deliverable-3/texts/aims.tex new file mode 100644 index 0000000..e1da3ee --- /dev/null +++ b/report/deliverable-3/texts/aims.tex @@ -0,0 +1,7 @@ +\section{Aims for submission 2} +From our first submission, we now had a working server that allowed a user to access our own mock user interface to log in and access data based on their level of authorisation. Following this we set up a meeting to lay out goals for ourselves that would act as requirements for the second submission. +\begin{description} + \item[Define Specific Protocol] Now that we had a working server, we next wanted to define specific protocol in order to demo our progress using work from another Junior Honours HCI groups. + \item[Manage Filetype Conversions] A main part of this submission was creating a file converter for all the required file types that would be needed. + \item[Testing] As our code was getting more complicated we wanted to make sure that extensive testing was implemented to create a more secure and consistent system. +\end{description} diff --git a/report/deliverable-3/texts/conclusion.tex b/report/deliverable-3/texts/conclusion.tex new file mode 100644 index 0000000..0e40979 --- /dev/null +++ b/report/deliverable-3/texts/conclusion.tex @@ -0,0 +1,5 @@ +\section{Conclusion} +As a group a lot of progress was made for this submission, we were proactive in setting out goals for ourselves and feel we are now well on track to produce an outstanding final hand in. Our continued use of scrum has helped keep workload consistent and effective right through to this submission and we hope to continue in this way. Scrum is essential in our progress as it helps to manage time and organise the team work and so this process will be used for the duration of the project. Having now combined our work with the HCI group we are looking forward to working with teams focused on machine learning to tie together all 3 sections of the application to create the desired system set out by the project owner. + +\subsection{Next Tasks} +Viewing the system as a whole, substantial progress has been made in completing each required task whilst also managing time for each task appropriately. Looking further ahead, our next objectives will surround performance enhancing, further testing and finally completing the integration process with the rest of the system. The process for these will include a large amount of analysis on the working server, which include finding delays between certain requests and responses, measuring time taken for converting files and testing for bugs after integration. Another important aspect is the security of the application, and preventing bugs from leading to exploits which can be used for malicious use. This is particularly important within the medical industry as data confidentiality and integrity are apart of practitioners' policy. One method of testing for this task would be penetration testing, using a suite of tools to attack the application, which would determine any vulnerabilities that exist.
\ No newline at end of file diff --git a/report/deliverable-3/texts/conversion.tex b/report/deliverable-3/texts/conversion.tex new file mode 100644 index 0000000..87db332 --- /dev/null +++ b/report/deliverable-3/texts/conversion.tex @@ -0,0 +1,135 @@ +\section{File Conversion} +One of the most key pieces of functionality for the backend groups is the facilitation of the agnosticity of +original file formats to the end user. No matter the original upload format, backend groups should all be +capable of returning files in standard file formats. +These specific ``standards'' were not hard-defined by the specification, however as part of our whole year +protocol, it was decided that \emph{JSON} would be used for file meta-information, as well as the +main structure of all responses from a backend server. \emph{PNG} was decided upon as the standard file format +for all images, since it is very widely supported and has other favourable properties we would like to +take advantage of. + +\subsection{Dealing with Images} +The nature of the file formats that we were expected to abstract over however turned out to be significantly +more challenging than was initially perceived. The file formats of `Leica' and `Zeiss' are widely used in the +medical field (the department we are providing this service for), however almost nowhere else. Upon looking +into this more closely, it was found that the Zeiss file format is very proprietary and licensed. + +This means that in order to even gain access to simply read the documentation you must fill in your details +and make an application for the documentation~\cite{zeissLicence}. Part of the agreement for this documentation is that you are +not allowed to share it with anyone else; you are allowed to write software to \emph{deconstruct} them; you +are strictly \emph{not} allowed to write any software to construct them. + +The documentation gives a description of the various ``segments'' of binary that can appear in the file, and +attempts to assist you in the method to read them. Given the large nature of the file size of a Zeiss, it makes +sense for them to be designed to be `streamable', which they are --- allowing you to read smaller chunks at a +time rather than loading the whole object into memory simultaneously. + +After reading the specification in great detail, it was clear that it was extremely specialised and has +the potential to nest a variety of other file types within itself, as well as have many fields missing +--- as they are optional --- making it quite complex to interpret. In addition to this, the major difficulty +came from the fact that the base file is a proprietary binary file, which also contains things such as 128bit +unsigned integers. This fact, coupled with the substantial file sizes made the choice for languages to deal +with them limited to a systems programming language. Since I had most experience in `C99', then this seemed +the only realistic possibility. + +\subsubsection{Extraction of Zeiss Within `C'} +One major consideration was that --- due to the sheer file size of many of these images --- we would need +to store them on the local \file{/cs/scratch} drive of the lab machines: they are simply too +large to store either on our host servers statically, let alone when working on extracting and expanding the +thousands of smaller files within them. + +With this in mind, and closely comparing the +`C' code against the rough documentation licensed to me, the structures possible within a Zeiss file were +slowly built up. + +Methods were written to print out the contents of various structures as progress was made, in +order to ensure that the offsets for file streaming were continually at the correct locations and the data we +were parsing out of the file was as expected. To this effect, testing of the extraction was run continually +in the standard `C' approach of a couple lines at a time before re-compilation, along with using flags such as +`\verb|--pedantic|' in order to try to catch as many errors as possible. Occasionally \verb|valgrind| was also +run on this extraction code, since significant chunks of memory are allocated and freed during the +extraction process. \verb|valgrind| reports that there are no memory leaks at all --- even +on the larger 12Gb \file{.czi} files. + +\subsubsection{Converting Extracted Files} +Once the files/metadata/attachments had been successfully extracted from the target file, multiple issues were +discovered. +\begin{itemize} + \item The container format for the image segments was in \emph{JPEG-XR}. This is another proprietary + file format, which does not appear to be supported by anything at all, other than Microsoft's own software. + There is also extremely limited library support, especially for non-Windows platforms. + Fortunately, a C++-written \file{.jxr} decoder was found, and could + be compiled on the destination machine. Enough of the executable is able to be compiled before any problems + occur, and this decoder can be copied into the relative path for our own C source. + \item The library for decoding JXR's is only + capable of conversion to \emph{BMP} or \emph{TIFF}, which is not our desired format. Therefore an additional step of + converting the `JXR' to `TIFF', and then to `PNG' using the `imagemagick' command line tools like \verb|convert| + became necessary. + This is an annoying overhead, which is unfortunately unavoidable. + \item By simply extracting every image tile found within the JXR tile, we found that + there were also tiles found at non 1:1 zoom levels, which was wasteful to deal with, since we will be building + a custom image pyramid anyway. This issue was mitigated by adding some logic to only extract the tile to disk if + it was determined to have a 1:1 scaling and thus be on the base layer. + \item In a similar fashion to the previous issue, it also became apparent that there were many tiles in the + base layer which were of non-standard sizes, with some having tiny slivers as they came to edges etc. + The only solution to make these tiles appear on a nice grid of $n^2$ sizes, was to iterate over the fragmented + canvas and stitch together the portions we want. +\end{itemize} + +In order to complete the conversion side of things, it seemed appropriate to move away from C programming, and +even away from the scripts that were being using to control the C, to something like \emph{Python}. +The thought process behind this decision is the fact that Python supports multithreading --- which for something +as parallel as multiple image conversions seemed extremely advantageous. The code to do this section is fairly +small, but absolutely crucial to the overall pipeline of Zeiss format support. + +\subsubsection{Stitching Base Tiles} +Once we finally had all of the base tiles in a 1:1 scale and a format that was easier to deal with, the first task +was to figure out how to build up our own grid across the mismatch of sizes of existing base tiles.\\ +The tile dimensions decided on were 1024:1024. The reason for this, is that it is large enough to contain a +reasonable amount of information, without being so large that our server could provide or clients could load in +a timely manner. + +In order to do this stitching process, a decision was required as to the package to manage the image operations. +After a vast amount of searching and comparisons, the selection was made for \emph{Sharp}~\cite{sharp}. The reason for +this, was that it appeared to be the single library which was capable of all of the different kinds of image +processing jobs we expected to be doing. Another key reason is the fact that it is known in advance that a very +large number of images will need to be processed here, so performance is critical. Sharp appears to perform +very significantly better than its competitors~\cite{sharpPerformance}. Finally, it has typing +support to work with our environment. + +With this set, high level logic was written to check various image bounds for related base tiles to a specific +region request. Regions were then selected out, sorted by x and y offsets, then relevant chunks chopped out of +them and stitched together into a coherent region of our selected size. + +\subsubsection{Building Up Hierarchy of Zoom Levels} +These finalised base layer tiles are written to disk in an output directory and details about their creation +are recorded in a new data structure which will map out the pyramid style hierarchy of the tiles. +A small example of these final titles are shown on the cover page of our Report for interest as they are +legitimate generations in a format we would like. + +Now that the base layer exists, gaining the rest of the tile zoom levels, should be fairly simple --- by moving +up to the next power of two (2048) and collecting 4 images together then scaling this back down to 1024 pixels. +This process can be repeated for each level of zoom we would like to raise to. This will massively speed up +the process of searching through base tiles and stitching many together if we pre-process all of the intermediate +layers. Since most HCI groups are using OpenSeaDragon (which requests things in scales of powers +of two~\cite{openseadragon}), our approach should be a very fast performer with the trade off of larger up-front processing time.\\ +Indexing into this pyramid will be fast with each request too, as they will be separated by `C' value, which is +one of the image's layering options, then by zoom level. + +\subsection{Leica \& Other Formats} +As Zeiss is such a difficult and mammoth file format almost all of my time was spent dealing with purely this, +and it is still not even complete yet. However having looked quickly into Leica, there appears to be +library support, which may make life easier, along with the fact the internal structure appears to be similar to +a BigTiff. More progress on this format will take place for the next deliverable. + +As for other image formats such as JPEG, TIFF etc. These are standard formats and so will be trivial to +convert to our required standard of PNG so is not a significant point of progress currently. + +\subsection{Non image formats (\file{.csv} etc.)} +As for non image formats such as \file{.csv}, it has been decided that the backend should only be responsible of hosting these +files, since there is no way that a backend server could possibly predict what the file should be processed into. +Additionally, there are also many cases where an end-user may wish to deliberately store something in a format +which a backend server checking legitimacy of the file would complain about incorrectly. + +The team hasn't really looked into things such as Excel (\file{.xlsx}) files, however again, pre-emptively looking, there seems to +be fairly wide library support for things like this, so it was not a major concern for this deliverable. diff --git a/report/deliverable-3/texts/logging.tex b/report/deliverable-3/texts/logging.tex new file mode 100644 index 0000000..d0a7255 --- /dev/null +++ b/report/deliverable-3/texts/logging.tex @@ -0,0 +1,38 @@ +\section{Logging} +Server logging has now been formalised: the functionality is imported into +a file and can then be used to log messages at the selection of urgencies +specified in Protocol BE01~\cite{protocol}. + +These outputs have many configuration options, which ideally will be +incorporated into a global configuration handler in future development. + +\subsection{Standard Logging} +By default, the standard logger logs to three places: +\begin{enumerate} + \item Colourised, human-readable messages are printed to the console. + Any error- or critical-level messages are printed through stderr. + \item More verbose JSON editions of messages are written to a basic + logfile. + \item Critical-level messages are additionally written to an extra + logfile. +\end{enumerate} + +\subsection{SQL Query Logging} +A separate logger has been designed for logging the output of +Sequelize~\cite{sequelize}. Since Protocol BE01 does not specify that they +should be retreivable, the output queries can be stored with less associated +metadata. In addition, Sequelize can output the total required time to +process the query, which is stored in the log for future use as profiling +data. + +\subsection{Motivation} +Since basic server functionality has been implemented, the errors produced +will likely be caused by difficult-to-debug problems, such as edge-cases or +data races. With a verbose and thorough logging system, these problems +should be much easier to detect and rectify. + +In addition, Protocol BE01~\cite{protocol} requires of the backend support +for receiving and storing logs from other services. The introduction of a +well-implemented logging system abstracts this from the common use-case of +logging while keeping powerful functionality of forwarding and fetching logs +available for when it is needed. diff --git a/report/deliverable-3/texts/minutes.tex b/report/deliverable-3/texts/minutes.tex new file mode 100644 index 0000000..55aab2a --- /dev/null +++ b/report/deliverable-3/texts/minutes.tex @@ -0,0 +1,72 @@ +\begin{lstlisting} + +Group Project Meeting 1 post submission +Date: 12/02/18 +Topics: +Reassigning scrum roles +Creating next set of tasks +Task allocation + +Outcomes: +* Scrum: + * scrum master - Hafeez + * project owner - Calum + +*Tasks: + * Implementing endpoints + * Implementing file conversions + * Improving test coverage + * Writing tests for untested sections + * Connecting all middleware + * Decide on how to deal with errors + * Organising file-system + * Creating a Linter to maintain a consistent file structure + +Group Project Meeting 2 Pre-sprint +Date 15/02/18 +Topics: +Define user stories +Task allocation + +Outcomes: +* Sprint + * Week long sprint + * Meeting set for 22/02/18 + +Group Project Meeting 3 Post-Sprint +Date 22/02/18 +Topics: +Analysis of work +Next task assignment + +Outcomes: + +Group Project Meeting 4 +Date 24/02/18 +Topics: +Sprint aims +Sprint deadline + +Outcomes: + *Decided to hold a sprint now to leave time + before next submission to finish off all leftover work + +Group Project Meeting 5 +Date 03/03/18 +Topics +Analysis of work todo after sprint +Work needed to complete before deadline + + +Outcomes: + * Finishing off of the report + *Connecting work with another HCI group + *Finish testing + + + + + + + +\end{lstlisting} diff --git a/report/deliverable-3/texts/process-management.tex b/report/deliverable-3/texts/process-management.tex new file mode 100644 index 0000000..d99a73c --- /dev/null +++ b/report/deliverable-3/texts/process-management.tex @@ -0,0 +1,56 @@ +\section{Process Management and Deployment}\label{sec:pm} +In a production environment, many instances of a NodeJS server are run on +one machine; this way NodeJS applications can make use of multiple +processors. For this purpose, research into \emph{process managers} --- +applications used for running and managing production-level systems --- +was carried out. + +\subsection{Process Manager Selection}\label{sec:pms} +A number of process managers were investigated with the hope of +incorporating them into the production +system~\cite{strongloop}\cite{pm2}\cite{forever}. The application pm2 was +chosen, primarily for its highly-configurable \emph{ecosystem}-config files, +and \emph{pmx}\footnote{https://github.com/keymetrics/pmx}, +its profiling extension. + +\subsection{pm2 and KeyMetrics}\label{sec:pm2} + +\begin{figure} + \centering + \includegraphics[width=0.95\linewidth]{km-dash} + \caption{The KeyMetrics dashboard web client in use.}\label{fig:dash} +\end{figure} + +A feature available in \emph{pm2} is the ability to transmit profiling +statistics to a web client, as a dashboard. The dashboard also allows the +user to remotely issue commands to the running instances. Further, +custom profiling information, and custom remote commands, can be created +through the introduction of simple logic into the codebase. + +\subsection{Process Limitations}\label{sec:plim} +Running multiple NodeJS instances can quickly accumulate counts towards a +user process limit: each instance hosts several threads, and each connection +to the PostgreSQL database can pool several threads also, resulting in many +threads per instance. Compounded with the fact that pm2 itself also runs +as a NodeJS instance, this means that a user can reach their process limit +on the host labs very quickly. Using \texttt{nolimit} on process +instantiation is one solution, however this means having to run +\texttt{nolimit} when starting the databse, deamonising the process manager, +starting the server instances, and doing any miscellaneous tasks. This +limitation has stunted hindered attempts to connect to other teams' +products. + +\subsection{Heroku Hosting}\label{sec:her} +In response to the issues addressed in \S\ref{sec:plim}, an attempt to host +an instance of the server on hosting service +\emph{Heroku}\footnote{https://heroku.com/} has been started. This would +alloow the team to interact with other teams, without using a member's +process limit and hindering their productivity. Additionally, it would show +the deployability of the system --- an important factor for a backend +server. + +\subsection{External System Hosting}\label{sec:ext} +Another option is to host instances of the system on devices personally +owned by members of the team. This would give the team absolute control over +configuration of the sytem, and would have the potential to outperform an +instance running on a complementary Heroku service. diff --git a/report/deliverable-3/texts/scrum.tex b/report/deliverable-3/texts/scrum.tex new file mode 100644 index 0000000..ca724c8 --- /dev/null +++ b/report/deliverable-3/texts/scrum.tex @@ -0,0 +1,17 @@ +\section{Continued use of Scrum} +The scrum process was continued as we found this very useful in terms of clearly setting out tasks for each member and managing the progress of the implementation. One of the changes that was made for this sprint was the change in roles between team members. The change in responsibility allows team members to complete new and different jobs. In general the size and the time taken of each individual task was a lot more varied when comparing to the last submission, however, there were certain tasks which were larger in terms of hours put in. These large tasks included creating a logger system and a file converter. +\subsection{Sprints} + +\begin{figure}[h] + \centering + \includegraphics[width=0.6\textwidth]{burndown} + \caption{A Burndown Chart for the past 14 days.}\label{fig:burn} +\end{figure} + +As a team, it was decided that there would only be a single sprint, up until the next point of submission. This was because of the short time period, enough for only a two week sprint. In addition to this, the sprint assessment process was completed more often to ensure that as a team time was managed well and sufficient progress was being made. All the tasks that was set for this sprint were completed within the required time frame. +\subsection{Scrum board} +Again, the scrum board was used to outline and track the completion of each task. The same whiteboard in the John Honey main computer lab was used in order to maintain consistency. This gave a clear visual representation of the objectives. During the sprint, the main jobs required for completion were to further enhance the testing unit to increase its coverage across the implemented systems, implement a simple file converter and introduce a logging system for the server. Much experience was gained from completing previous sprints and so using this experience we were better equipped to handle larger tasks. Examples of the board in use can be found in Appendix \ref{app:board}. + +\subsection{Meetings} +Regular meetings were also held to discuss and evaluate progress. This was crucial in the scrum process and as working in a team to allow a point of communication between each member at the same point in time. An example of a major decision being made during the discussion was the change of language of the file converter implementation. It was decided that the more appropriate language to use would be C as there would more extensive libraries for this particular operation and would also have the advantage of greater efficiency. Multiple meetings were held during the most recent sprint to determine the tasks required for completion, to evaluate whether each task was completed and track progress in between. +The minutes for formal meetings are available in Appendix \ref{app:meet}. diff --git a/report/deliverable-3/texts/testing.tex b/report/deliverable-3/texts/testing.tex new file mode 100644 index 0000000..e3f709b --- /dev/null +++ b/report/deliverable-3/texts/testing.tex @@ -0,0 +1,15 @@ +\section{Testing} +Tests do not currently run on the gitlab server, as the postgres integration with the docker gitlab-ci is still missing. This means any tests run automatically when pushing will fail. \par +When running integration tests locally, please make sure the postgres server is up and running on localhost. +\subsection{Structure} +Testing files were restructured for a more organised and professional approach. All test files end in ``*.\(<\)context\(>\).test.ts'' and were moved to the ``test'' directory. At this moment, ``\(<\)context\(>\)'' includes ``unit'' and ``routes''. Further, they were categorised into \textit{integration} and \textit{unit} tests and moved into corresponding sub-directories. \par +Apart from making test files easier to find, this new structure also allowed us to run specific tests independently to isolate failures and quickly rerun individual tests. For example \texttt{yarn test:routes:auth} runs all authentication tests. +\subsection{Integration Testing} +\texttt{yarn test:routes} +This category of tests targeted the interplay of different server components as it tested server endpoints (routes) rather than internal functions. We aimed to test all routes for responses of success, and various degrees of failure. \par +E.g. \textbf{``auth.routes.test.ts''} tested the authentication middle-ware, checking existing users could log in only with correct usernames, passwords and reauthentication tokens. During our later meetings, we realised that security is a key-component of medical systems, and requires further much more in-depth testing to guarantee safety of patient data. \par +\textbf{``protocol.routes.test.ts''} aims to cover all endpoints specified in the agreed protocol by using the \textit{mocha-each} npm module. This allowed us to write few mocha testing functions iterating over the long list of endpoints, checking HTTP responses to fit the JSON response templates to conform to the protocol. This form of testing is still incomplete. +\subsection{Unit Testing} +\texttt{yarn test:unit} +The main motivation for this category of tests was to find bugs early on without having to run the whole server. This saves time and uncovers new code breaking old functionality. We also found that unit tests improved the design process by forcing implementation of code that is testable. Furthermore, unit tests were often used as a form of documentation, as it aided in understanding how code of other team members worked and could be used. \par +We decided that each team-member was responsible for creating the unit tests for their code. Unfortunately the number and coverage of unit tests is still quite low. This may be the result of prioritising functionality over bug-resilience and test-driven development. diff --git a/report/deliverable-3/texts/typings.tex b/report/deliverable-3/texts/typings.tex new file mode 100644 index 0000000..36297b7 --- /dev/null +++ b/report/deliverable-3/texts/typings.tex @@ -0,0 +1,27 @@ +\section{Type Enforcement} +In order to run JavaScript code as TypeScript code, typings (usually +supplied in a \file{.d.ts}-extended file) are applied at compile-time to +make sense of the original source's variable types. For a couple of +packages that have been used in the submission, these typings are not +available, due to a lack of desirablilty --- the packages in question are +niche and as such see little use. + +\subsection{mocha-each} +One such package is \emph{mocha-each}, a utility package for compacting +Mocha tests for readability and classification~\cite{mocha-each}. Without +typings, this package cannot be used in TypeScript projects. Due to its +single-facet use, however, it was simple to design a custom +\file{.d.ts} file. With small edits to conform to +guidelines~\cite{@types}, typings for +mocha-test were contributed to the DefinitelyTyped types repository\footnote{% +https://github.com/DefinitelyTyped/DefinitelyTyped/% +tree/master/types/mocha-each}. + +\subsection{pmx} +The package pmx (as previously described in \S\ref{sec:pms}) is useful for +profiling. Similarly to mocha-each, however, it does not have supported typing. +Since this package covers a far wider range of functionality, and since said +functionality is very involved with sensitive run-time engine manipulation, +typings were written only for the functions being used by the team, and have +been kept in-house for their incompleteness. The files in question can be found +in \file{src/profiler}. diff --git a/report/deliverable-3/title.tex b/report/deliverable-3/title.tex new file mode 100644 index 0000000..4406ef6 --- /dev/null +++ b/report/deliverable-3/title.tex @@ -0,0 +1,15 @@ +\title{Report \\ Juniour Honours Project \\[0.5ex] Submission 2} +\author{Hafeez Abdul-Rehaman \\[1ex] Johannes Weck \\[1ex] Josh Lee \\[1ex] Calum Duff \\[2ex] Tom Harley} +\date{\today} + +\makeatletter + \def\@maketitle{ + \begin{center} + \includegraphics[width=0.7\linewidth]{title-logo}\\[10ex] + {\huge \bfseries \@title{ }}\\[1ex] + \rule{0.5\textwidth}{.4pt}\\[1ex] + {\LARGE \@author}\\[15ex] + {\large \@date} + \end{center} + } +\makeatother |
