Mongo-tietokannassa tapahtuvien muutosten vertailu versiopäivitysten yhteydessä
Huovinen, Toni (2019)
Huovinen, Toni
2019
All rights reserved. This publication is copyrighted. You may download, display and print it for Your own personal use. Commercial use is prohibited.
Julkaisun pysyvä osoite on
https://urn.fi/URN:NBN:fi:amk-2019091218425
https://urn.fi/URN:NBN:fi:amk-2019091218425
Tiivistelmä
Modernin ohjelmistokehityksen yksi kulmakivi on lähdekoodin ja tietokantojen muutosten seuraaminen. Ilman tätä mahdollisuutta ohjelmistoprojektien kehitys olisi huomattavan hidasta, ellei jopa mahdotonta. Opinnäytetyön tarkoituksena oli suunnitella BCB Medical Oy:lle kevyt ohjelma seuraamaan yrityksen Mongo-tietokannassa tapahtuvia dataobjektien muutoksia BCB:n asiakkaille julkaisemien verkkoselainpohjaisten ohjelmien toimituspäivitysten aikana. Luodun ohjelman oli tarkoitus toimia osana yrityksen käyttämää Atlassianin Bamboo-palvelua. Lähtötilanteessa vertailu suoritettiin manuaalisesti, mikä altistaa inhimillisille virheille.
Työ toteutettiin Java ja Groovy -ohjelmointikielillä IntelliJ IDEA -kehitysympäristössä. Muita työssä käytettyjä teknologioita olivat Mongo NoSQL -tietokanta ja tämän graafisena käyttöliittymänä Studio 3T, Sourcetree versionhallinnan työkaluna sekä Bamboo jatkuvan integraation ja toimituksen ympäristönä. Ohjelmakoodia lähdettiin rakentamaan iteroiden, mikä mahdollistaa nopeat testaukset ja korjaukset ongelmien ilmetessä.
Työn ensimmäinen versio täytti perusvaatimukset. Tämä toimi kuitenkin manuaalisesti eikä sen vuoksi ollut yhteensopiva Bamboon kanssa. Toista versiota lähdettiin kehittämään ensimmäisen pohjalta, ja tästä saatiin automaattisesti toimiva kokonaisuus. Tästä jatkokehitettiin versio, joka oli mahdollisimman yhteensopiva Bamboon kanssa, ja toiminnallisuuden vuoksi koodi jaettiin vielä kahtia. Ensimmäinen osa haki dataobjektien nykytilanteen ja tallensi sen JSON-muodossa tiedostoon. Toinen osa koodista luki aiemmin tallennetun tiedoston, haki dataobjektien päivitetyn nykytilanteen ja suoritti vertailun näiden kahden välillä. Tuloksena oli siisti raporttidokumentti Mongo-tietokantaan. Toimeksiannossa ei päästy aivan loppuun, skriptejä ei saatu vietyä mukaan varsinaisiin ohjelmiin virallisten tietokantayhteyksien uupuessa. Toimintaa kuitenkin pystyttiin simuloimaan onnistuneesti.
Johtopäätöksenä voidaan todeta, että Mongo-tietokantojen vertailun automatisointi osaksi jatkuvan toimituksen putkea on mahdollista. Tämä vähentää manuaalisen tarkistuksen määrää ja virheiden syntyä. One of the cornerstones in modern software development is the ability to track changes in your source code and database, without this ability developing new bigger software would be considerably more slower if not impossible. In this thesis report, I will guide the reader through the process in which I created a scripts for BCB Medical Ltd which are able to track the changes happening in their Mongo database regarding dataobjects during software update process. Program I was tasked to create was meant to be part of their Atlassian Bamboo continuous integration and deployment pipeline. Currently database changes are checked manually and that is slow and opens door to the possibility of errors.
In this thesis I am introducing the reader to the technologies and languages I used to create the script. These were Java and Groovy programming language and IntelliJ IDEA as an integrated development environment. For version control client I used Sourcetree and for managing Mongo databases I used Studio 3T. Bamboo was used as a platform for continuous integration and development. Studio 3T acted as a source of inspiration when I was designing the script. As for the creation of scripts, I chose an iterative approach for rapid testing and quick fixing.
First version of script fulfilled the basic needs that we agreed upon but it needed manual input from user and thus it was not suitable. This version gave a good base for the second version which I was able to turn into fully automatic script. For Bamboo I divided the script into two pieces, first part was responsible for fetching current dataobjects from the database and stored that data as a JSON file. Second part of script read the JSON file created earlier and fetched the current, possibly updated dataobjects from the database and performed the comparison between the two datasets. That resulted in a clean report document which was stored in Mongo database. Unfortunately, I wasn’t able to put the scripts in the actual development environment due to the lack of official database connections. However, I was able to simulate functionality using JSON files in Bamboo and through IntelliJ IDEA using databases.
In conclusion, I am safe to say that it is indeed possible to create a script or two for the Bamboo environment and automate the differentiation process. Automation significantly speeds up the processes, releases people to do other tasks and lowers the possibilities of errors.
Työ toteutettiin Java ja Groovy -ohjelmointikielillä IntelliJ IDEA -kehitysympäristössä. Muita työssä käytettyjä teknologioita olivat Mongo NoSQL -tietokanta ja tämän graafisena käyttöliittymänä Studio 3T, Sourcetree versionhallinnan työkaluna sekä Bamboo jatkuvan integraation ja toimituksen ympäristönä. Ohjelmakoodia lähdettiin rakentamaan iteroiden, mikä mahdollistaa nopeat testaukset ja korjaukset ongelmien ilmetessä.
Työn ensimmäinen versio täytti perusvaatimukset. Tämä toimi kuitenkin manuaalisesti eikä sen vuoksi ollut yhteensopiva Bamboon kanssa. Toista versiota lähdettiin kehittämään ensimmäisen pohjalta, ja tästä saatiin automaattisesti toimiva kokonaisuus. Tästä jatkokehitettiin versio, joka oli mahdollisimman yhteensopiva Bamboon kanssa, ja toiminnallisuuden vuoksi koodi jaettiin vielä kahtia. Ensimmäinen osa haki dataobjektien nykytilanteen ja tallensi sen JSON-muodossa tiedostoon. Toinen osa koodista luki aiemmin tallennetun tiedoston, haki dataobjektien päivitetyn nykytilanteen ja suoritti vertailun näiden kahden välillä. Tuloksena oli siisti raporttidokumentti Mongo-tietokantaan. Toimeksiannossa ei päästy aivan loppuun, skriptejä ei saatu vietyä mukaan varsinaisiin ohjelmiin virallisten tietokantayhteyksien uupuessa. Toimintaa kuitenkin pystyttiin simuloimaan onnistuneesti.
Johtopäätöksenä voidaan todeta, että Mongo-tietokantojen vertailun automatisointi osaksi jatkuvan toimituksen putkea on mahdollista. Tämä vähentää manuaalisen tarkistuksen määrää ja virheiden syntyä.
In this thesis I am introducing the reader to the technologies and languages I used to create the script. These were Java and Groovy programming language and IntelliJ IDEA as an integrated development environment. For version control client I used Sourcetree and for managing Mongo databases I used Studio 3T. Bamboo was used as a platform for continuous integration and development. Studio 3T acted as a source of inspiration when I was designing the script. As for the creation of scripts, I chose an iterative approach for rapid testing and quick fixing.
First version of script fulfilled the basic needs that we agreed upon but it needed manual input from user and thus it was not suitable. This version gave a good base for the second version which I was able to turn into fully automatic script. For Bamboo I divided the script into two pieces, first part was responsible for fetching current dataobjects from the database and stored that data as a JSON file. Second part of script read the JSON file created earlier and fetched the current, possibly updated dataobjects from the database and performed the comparison between the two datasets. That resulted in a clean report document which was stored in Mongo database. Unfortunately, I wasn’t able to put the scripts in the actual development environment due to the lack of official database connections. However, I was able to simulate functionality using JSON files in Bamboo and through IntelliJ IDEA using databases.
In conclusion, I am safe to say that it is indeed possible to create a script or two for the Bamboo environment and automate the differentiation process. Automation significantly speeds up the processes, releases people to do other tasks and lowers the possibilities of errors.