Giter VIP home page Giter VIP logo

snapp-test-case's Introduction

Snapp's Test case

This is a test case of DevOps role from the Snappmarket. I share it here with my answer.

Tests:

1- Create a simple node.js application for printing current timestamp and dockerize it (Dockerfile + docker compose).

2- Use nginx for web server behind the application (Dockerfile + docker compose)

3- Create ha proxy config file with these criteria: star:

  1. one listen block to passing mysql connections to the desired ip/port
  2. one frontend block to receive http requests on port 80
  3. one backend block with 2 servers
  4. use basic http authentication for accessing the backend
  5. Dockerize ha proxy

4- Create a pipeline with Gitlab CI to running, validating and reloading ha proxy config file automatically when merging to develop branch.

5- It's a bash script test case that asked you to understand it to solve some issue on its.

Answers

1-4: I solved them into the files' code. (you can find it into this repo). Also, because I didn't have enough time, I forced to summarize something(Sorry for that).

5: All Answers of bash script test case(two purposes):

  • 1- Purpose of this code: We have printed all regular files listed in /tmp directory that modified greater than 24 hours ago and contains *.dophin.temp pattern(extension), then this list sent to adddate() function, afterward this function add date $time to this list and print it.
  • 2- All files in the / directory that they are modified greater than 24 hours ago and they have *.dophin.temp pattern(extension) sent to xargs for print in echo.
  • 3- Problems of the Test:
    1. "For loops" over "find output" are fragile, it's better to use "find -exec" or a "while read" loop.(line: 9)
    2. We must use double quote to prevent globbing(Security issue) and word splitting.(lines: 11, 12)
    3. It's better to use -print0/-0 or -exec + to allow for non-alphanumeric filenames.(line: 15)
    4. It's better to use find instead of ls to handle non-alphanumeric filenames.(line: 12)
  • 4- Rewrite code(another way):
#!/bin/bash
adddate() {
  while read -r line
  do
      echo "$(date) $line"
  done
}

while read -r file
 do
 echo "$file"
 find "$file" -mindepth 1 -maxdepth 1 -printf '%f\n' | adddate >> /tmp/clean.log
 done < "$( find /tmp -type f -mtime +0 -name '*.dolphin.temp' )"

find / -print0/-0 -type f -mtime +0 -name '*.dolphin.temp' | xargs echo
exit 0

snapp-test-case's People

Contributors

ali-hallaji avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar  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.