Giter Club home page Giter Club logo

devops_helloworld's Introduction

Web based Hello World application

This case study is aimed at being used for running several experiments. That's the reason why it contains (so far) a DB and some web services.

Assumptions/Pre-requisites

Hardware

Laptop with at least 8 Gb memory (recommended 16 Gb, ideally 32 Gb)

Software

  1. Maven (v 3.6.2, or higher)
  1. VirtualBox(v 6.0, or higher)
  1. Vagrant (v 2.2.5, or higher)
  1. Postman (V 7.19.1 (7.19.1) or higher)

Set local working environment

1- Clone this repo

2- Import the given project into your favourite IDE

3- Build the project using Maven. Either you do it from within the IDE, or from a terminal. From the terminal you must:

3.1- Get to the directory

cd ~/<git_root_folder>/helloworld/product.helloworld

3.2- Run the comand.

mvn clean install

Running this command should show (almost at the end of the output):

[INFO] BUILD SUCCESS

Note

  • The project is ready to be imported on the Eclipse IDE as an existen Maven project.

Set local testing environment

In order to run the application some tools have to be installed. The idea is to use the same versions and configurations of the tools as expected to be in the production environment. In this manner, testing the application in our local environment (to some extend) it's similar that running the application on the production environment.

For this purpose, a local production-like testing environment is going to be setup.

1- Get to the directory

cd ~/<git_root_folder>/helloworld/product.helloworld`

2- Run the command

vagrant up

Running this command should shown at the end of the output:

 default: Done.

Troubleshooting: if you see error messages like:

default: Extract into target directory
default: 
default: gzip: stdin: not in gzip format
default: tar: Child returned status 1
default: tar: Error is not recoverable: exiting now

then (the most probable) is that the version of Tomcat used is not available any more. This has to be solved by editing the file

setup-tomcat.sh

and changing in the line

curl -o apache-tomcat-10.1.16.tar.gz https://downloads.apache.org/tomcat/tomcat-9/v9.0.34/bin//apache-tomcat-10.1.16.tar.gz

the value v9.0.34 for the latest available Tomcat version.

Check local testing environment setup

1- Get to the directory

cd ~/<git_root_folder>/helloworld/product.helloworld

2- Jump into the virtual environment (refered to also as guest) :

 vagrant ssh

3- Check mysql installation

mysql -u root -p

password: 12345678

You should have been able to connect to the database engine. To quit, type:

quit;

4- Check Tomcat installation and configuration

Open a browser, and try to access to this url

http://192.168.56.14:8080

Then, try to access to the Tomcat's management are, via this url

http://192.168.56.14:8080/manager/html

user and password: admin

Run the application

In order to try out the application, it first has to be deployed in the virtual environment setup for such pourpose. This is done by executing the following steps:

1- Get to the directory

cd ~/<git_root_folder>/helloworld/product.helloworld

2- Jump into the virtual environment (refered to also as guest) :

 vagrant ssh

3- Create the dabase schema and tables

mysql -u root -p  < /vagrant_scripts/db-helloworld.sql

password: 12345678

4- Deploy the application

Go to folder

cd /vagrant_scripts/

Execute script

sudo ./deploy-snapshot.sh

Note

  • Only step 4 has to be executed every time you want to re-deploy the application, assuming no modifications to the database were made.

Test the application

  1. Landing page: http://192.168.56.14:8080/helloworld

  2. Static html page: http://192.168.56.14:8080/helloworld/helloworld.html

  3. Web service 1 => Timestamp service: http://192.168.56.14:8080/helloworld/FirstServlet

  4. Web service 2 => TEST database table's content: http://192.168.56.14:8080/helloworld/select

  5. Web service 3 => TEST database table's insert: use postman application and check if you can properly post data into the database and get proper response.

The url to use is:

http://192.168.56.14:8080/helloworld/insert?name=Hello2&value=1376

You might change the parameters as you wish.

The expected response should be:

<html><body><b>Successfully Inserted</b></body></html>

Final remarks

These guidelines explain how to come up with a development environment such that:

  • the build of the application is automatically done using maven,
  • the setup of a local testing environment is automatically made using Vagrant, and
  • the (re)deployment of the application for testing purposes is automtically done.

devops_helloworld's People

Contributors

acapozucca avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.