Course(s) Evaluation

In this blog post I will include my thoughts about the classes TC3045 (Software Quality and Testing) and CB00881 (Smart Citizens)

First of all, these were my first and last classes (because I’m graduating and I’m not planning to do a Masters) using the Flipped Learning method. I found it very interesting because I had a lot of flexibility in terms of homeworks and tasks, at the start of the semester I was working in a full-time job so I have the option to complete all my pending assignments in my free time. To be honest, I should have been more careful about the deadlines and deliveries because I have a considerable amount of accumulated tasks to do at the end of the semester.

About the content of the classes and assignments, they met my expectations, there were some assignments that challenged myself and taught me new things. At the start of the semester, we have to write blogs weekly for CB00881, I wrote a few on time because I don’t have the writing habit developed, I don’t really like writing so much, but I want to. Recently I started to read more blogs about the new technologies, the updates and improvements in the actual ones, and some tutorial blogs to develop something using a language or framework. I want to share some knowledge to the world and start writing some blog stuff and link the code I used to my GitHub repo, I proposed myself that I want to contribute to some Open Source repos in order to thanks all the amazing people that are doing it and all the times I used those repos. I hope I will do it.

Ken is amazing teacher, he really knows how to transmit his knowledge and encourage you to learn. But apart of being a good teacher, he is a great human being, he is always open to talk to you about your thoughts, life, work, feelings and whatever you want, he will listen and he will be there to help.

Anuncio publicitario

Sprint 3 Review

This sprint we did the following:

  • Rebuilt the backend response in different endpoints.
  • Redeployed all the infrastructure, because the services were down.
  • Changed the credentials needed for the Redis.
  • Developed the frontend needed to show in real time the information (bikes available and the ones disabled).
  • Developed a serverless function which retrieves the data on real time and calculates a new output every time we want to consult the web page.

Dev Ops Part III

For this part, we’re going to automate pulls of our project to the Linux Server we did set up in Part II.

Make sure you have a GitHub account before start.

Adding 2 factor authentication to GitHub and SSH keys

  • Sign into GitHub and go to Settings
  • Select Security from left menu
  • Click on Enable two-factor authentication and follow the instructions
  • Choose the desired method, I did it with SMS
  • Once you finish, you’ll see a page like this

To add SSH keys do the following:

  • Sign into GitHub and go to Settings
  • Choose SSH and GPG Keys in the left menu
  • Click on the New SSH button
  • Set the title to this new SSH and to generate it we will do the following:

Inside the Virtual Machine, open the terminal app and run the following command

ssh-keygen -t rsa

Follow the prompted instructions to store it in your machine. Once the key is generated, try to clone the repo we previously created in Part II using the SSH method. If it clones without any problem, it means that it worked!

Make any change to the repo and commit it. Try to pull from the VM to ensure it works.

We’re going to automate pulls from our project to keep the website updated. Let’s create a simple shell script.

mkdir cicd_scripts
cd cicd_scripts

/** **/

cd $HOME/Server/devops // This is the path to my project
git pull origin master

/** **/

Now, let’s modify our cronjobs

crontab -e

// Add this at the end of the file

* * * * * sh $HOME/cicd_scripts/

Our server will be doing pulls to the master branch every minute, to keep it updated. Let’s make a small change and commit it.

Open the browser and refresh the page, it has the changes we made! Now you have automated pulls in your server!

How often should we update?

It depends on the project, I’ll go for after midnight, around 2:00 A.M. – 3:00 A.M., to ensure that there is less traffic in the website, unless it is a critical change that has to be updated right now.

How do you ensure (and you should do this) that you do not end up with two copies of your update script running at the same time?

There are tools to accomplish this. One method that I liked is using flock. It came bundled with Ubuntu, basically it is a tool that if a job is running, it creates a lockfile to prevent running more than one instance of a jobs. It is very easy to use it, to add it to our current jobs we just write the following

* * * * * /usr/bin/flock -w 0 $HOME/cicd_scripts/cicd.lockfile sh $HOME/cicd_scripts/ 

We’re telling it to create a lock file inside our scripts folder, it will prevent running our script more than one time

This has to be done for every cron jobs that we create.

Stay tuned for the Part IV post!


DevOps Part II

We are on our first step to become a DevOps expert. We will begin setting up a Linux Server (NodeJS) on a Virtual Machine. I recommend VirtualBox, it is open source and very easy to set up.

Preparing VirtualBox for running Ubuntu

Launch VirtualBox and select «New», the next prompt will appear. Make sure you select Linux and Ubuntu (32|64-bit) version.

Set the RAM

Select the Hard Drive Type

Your VM is almost ready, when you boot it from the first time, it prompts you to select the bootable file, make sure you select the *.iso file you downloaded from the Ubuntu webpage.

Follow the instructions prompted by the OS like creating an Username and Password, when it finished, we’re going to install the required packages for running Node.

Installing NodeJS & Git

First we need the curl package, open the Terminal app and type

sudo apt-get install curl

Next step is to download Node source, type the following command

curl -sL | sudo -E bash -

Once finished, let’s install NodeJS by running the next command

sudo apt-get install -y nodejs

Finally, verify that node and npm are correctly installed by checking the version of each one

node -v
npm -v

Our next step is to install git, so we run the next command

sudo apt-get install git

And like node and npm, let’s verify the installation by checking the version

git --version

Now let’s create a repository for serving a simple webpage using node and express. In a new folder run npm init, and fill the prompted options. This will let us install node packages using npm. Install express by running npm install express. Let’s write some HTML and JavaScript.


In the package.json file, add a new script for running our development server.

"scripts": {    
"start": "node src/index.js"

Run the script typing npm run start and open the browser in http://localhost:8080, you should see the following

It works!

Remember to add git to the project.

Now, we’re going to write a small cron job in our Virtual Machine, type the following

crontab -e

Select your desired terminal editor and you’ll be able to edit or add cron jobs

At the end of the file we will write the cronjob, add something simple like this

* * * * * echo 'Hello Cron!' > $HOME/cron.txt

This task will be running every minute and overwrite the file with ‘Hello Cron!’, close the file and save it. Next go to your home directory in one minute and see that the file is created

Amazing! We wrote our first cronjob in Linux. This is the part II of a series of five posts