Merge pull request #4 from surister/Python_Syntax_Checker

Python syntax checker
This commit is contained in:
surister 2019-12-21 16:43:02 +01:00 committed by GitHub
commit 7a3b804cbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 367 additions and 13 deletions

View File

@ -2,7 +2,7 @@
:information_source:  This repository contains questions on various DevOps and SRE related topics :information_source:  This repository contains questions on various DevOps and SRE related topics
:bar_chart:  There are currently **630** questions :bar_chart:  There are currently **635** questions
:books:  To learn more about DevOps check the resources in [DevOpsBit.com](https://devopsbit.com) :books:  To learn more about DevOps check the resources in [DevOpsBit.com](https://devopsbit.com)
@ -375,7 +375,7 @@ You can describe the UI way to add new slaves but better to explain how to do in
</b></details> </b></details>
<details> <details>
<summary>How would you implement an option of a starting a build from a certain stage and not from the beginning?<summary><br><b> <summary>How would you implement an option of a starting a build from a certain stage and not from the beginning?</summary><br><b>
</b></details> </b></details>
##### Jenkins Dev ##### Jenkins Dev
@ -417,6 +417,14 @@ SAAS
* Private</summary><br><b> * Private</summary><br><b>
</b></details> </b></details>
<details>
<summary>What are the differences between Cloud Provides and On-Premise solution?</summary><br><b>
In cloud providers, someone else owns and manages the hardware, hire the relevant infrastructure teams and pays for real-estate (for both hardware and people). You can focus on your business.
In On-Premise solution, it's quite the opposite. You need to take care of hardware, infrastructure teams and pay for everything which can be quite expensive. On the other hand it's tailored to your needs.
</b></details>
## AWS ## AWS
@ -441,6 +449,12 @@ Edge locations are basically content delivery network which caches data and insu
<summary>What is IAM?</summary><br><b> <summary>What is IAM?</summary><br><b>
</b></details> </b></details>
<details>
<summary>True or False? IAM configuration is defined globally and not per region</summary><br><b>
True
</b></details>
##### S3 ##### S3
<details> <details>
@ -553,25 +567,33 @@ Stop the instance, the type of the instance to match the desired RAM and start t
* Classic LB - low costs, good for test or dev environments * Classic LB - low costs, good for test or dev environments
</b></details> </b></details>
##### Security ##### AWS Security
<details>
<summary>What is the shared responsibility model? In other words, what AWS is responsible for and what the user is responsible for in regards to Security?</summary><br><b> <summary>What is the shared responsibility model? In other words, what AWS is responsible for and what the user is responsible for in regards to Security?</summary><br><b>
</b></details> </b></details>
<details>
<summary>What is the AWS compliance program?</summary><br><b> <summary>What is the AWS compliance program?</summary><br><b>
</b></details> </b></details>
<details>
<summary>Explain what each of the following services is used for <summary>Explain what each of the following services is used for
* AWS Inspector * AWS Inspector
* AWS Artifact * AWS Artifact
* AWS WAF
* AWS Shield</summary><br><b> * AWS Shield</summary><br><b>
</b></details> </b></details>
<details>
<summary>What is AWS WAF? Give an example of how it can used and describe what resources or services you can use it with</summary><br><b>
</b></details>
<details>
<summary>What AWS VPN is usef for?</summary><br><b> <summary>What AWS VPN is usef for?</summary><br><b>
</b></details> </b></details>
<details>
<summary>What is the difference between Site-to-Site VPN and Client VPN?</summary><br><b> <summary>What is the difference between Site-to-Site VPN and Client VPN?</summary><br><b>
</b></details> </b></details>
@ -580,7 +602,7 @@ Stop the instance, the type of the instance to match the desired RAM and start t
True True
</b></details> </b></details>
#### Databases #### AWS Databases
<details> <details>
<summary>What is RDS?</summary><br><b> <summary>What is RDS?</summary><br><b>
@ -597,10 +619,27 @@ True
<summary>What is EBS?</summary><br><b> <summary>What is EBS?</summary><br><b>
</b></details> </b></details>
#### AWS Networking
<details> <details>
<summary>What is VPC?</summary><br><b> <summary>What is VPC?</summary><br><b>
</b></details> </b></details>
<details>
<summary>Explain Security Groups and Network ACLs</summary><br><b>
</b></details>
#### Misc
<details>
<summary>Explain what are the following services and give an use case example for each one them:
* CloudTrail
* CloudWatch
* CloudSearch</summary><br><b>
</b></details>
## Network ## Network
<a name="network-beginner"></a> <a name="network-beginner"></a>
@ -890,7 +929,8 @@ As to fix it there are serveral options:
3. You would look for your distro default $PATH variable, copy paste using method #1 3. You would look for your distro default $PATH variable, copy paste using method #1
Note: There are many ways of getting errors like this: if bash_profile or any configuration file of your interpreter was wrongly modified; causing erratics behaviours, Note: There are many ways of getting errors like this: if bash_profile or any configuration file of your interpreter was wrongly modified; causing erratics behaviours,
permissions issues, bad compiled software (if you compiled it by yourself)... there is no answer that will be true 100% of the time.</b> permissions issues, bad compiled software (if you compiled it by yourself)... there is no answer that will be true 100% of the time.
</b>
</p> </p>
</details> </details>
@ -1204,7 +1244,7 @@ execution or run forever
</b></details> </b></details>
<details> <details>
<summary>What signal is used by default when you run 'kill <process id>'?</summary><br><b> <summary>What signal is used by default when you run 'kill *process id*'?</summary><br><b>
<pre> <pre>
The default signal is SIGTERM (15). This signal kills The default signal is SIGTERM (15). This signal kills
process gracefully which means it allows it to save current process gracefully which means it allows it to save current
@ -1273,7 +1313,7 @@ You can also try closing/terminating the parent process. This will make the zomb
</b></details> </b></details>
<details> <details>
<summary>Can you explain how network process/connection is established and how it's terminated?><br></b> <summary>Can you explain how network process/connection is established and how it's terminated?></summary><br></b>
</b></details> </b></details>
<details> <details>
@ -2262,7 +2302,7 @@ Setting the replicas to 0 will shut down the process. Now start it with `kubectl
</b></details> </b></details>
<details> <details>
<summary>Explain recursion</summary<br><b> <summary>Explain recursion</summary><br><b>
</b></details> </b></details>
<details> <details>
@ -3093,7 +3133,7 @@ a = f()
</b></details> </b></details>
<details> <details>
<summary>Can you implement Linked List in Python?<br><b> <summary>Can you implement Linked List in Python?</summary><br><b>
</b></details> </b></details>
<details> <details>
@ -3925,7 +3965,7 @@ the pseudo table to retrieve the sum of the prices spent by each customer, then
</b></details> </b></details>
<details> <details>
<summmary>Describe in detail how you bring up an instance with an IP you can reach from outside the cloud</summary><br><b> <summary>Describe in detail how you bring up an instance with an IP you can reach from outside the cloud</summary><br><b>
</b></details> </b></details>
<details> <details>

View File

@ -2,9 +2,10 @@
import random import random
rand_num_li = sorted([random.randint(1, 50) for iter in range(10)]) rand_num_li = sorted([random.randint(1, 50) for _ in range(10)])
target = random.randint(1, 50) target = random.randint(1, 50)
def binary_search(li, le, ri, target): def binary_search(li, le, ri, target):
if le <= ri: if le <= ri:
mid = ri + le // 2 mid = ri + le // 2

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# We dont care about non alphanumerics filenames so we just ls | grep to shortern the script. # We dont care about non alphanumerics filenames so we just ls | grep to shorten the script.
echo $(( $(ls ./scenarios/ | grep ".*md" -c) + $(grep \</summary\> -c README.md) )) echo $(( $(ls ./scenarios/ | grep ".*md" -c) + $(grep \</summary\> -c README.md) ))

91
scripts/main.py Normal file
View File

@ -0,0 +1,91 @@
import pathlib
p = pathlib.Path(__file__).parent.parent.joinpath('README.md')
with open(p, 'rb') as f:
file_list = [line.rstrip() for line in f.readlines()]
details_final_count = 0
details_count = 0
print(len(file_list))
for q in file_list:
if b'<details>' in q:
details_count += 1
if b'</details>' in q:
details_final_count += 1
print(details_count, details_final_count)
# TODO Checkear que tenemos mismo numero de details tabs, aunque esto no asegura al 100% que esta bien formateado.
# Una vez que tenemos un número par, podemos más o menos estar seguros de que la cosa va bien, y hacer ya entonces
# el checkeo de las demás tags.
# Problema: No obtenemos el lugar de donde esta mal el details, entonces; hacerlo.
# IDEA: comprobar que despues de un detail va un /detail y mas o menos supongo que podremos acotar, hacer pruebas.
def get_question_list(f):
questions_list = []
temp = []
after_summary_tag = False
for line in f:
if line.startswith(b'<details>'):
temp.append(line)
after_summary_tag = True
elif after_summary_tag and line != b'' and b'</details>' not in line:
temp.append(line)
elif after_summary_tag and b'</details>' in line:
temp.append(line)
after_summary_tag = False
questions_list.append(temp)
temp = []
return questions_list
def get_answered_questions(question_list) -> int:
c = 0
for q in question_list:
index = 0
for i in q:
if b'</summary>' in i:
index = q.index(i)
if q[index+1: len(q) - 1]:
# print(q[2: len(q) - 1], '-->', q)
c += 1
return c
def check_even_tags(question_list):
summary_count = 0
details_count = 0
# details count not necessary cus we already have that checked beforehand
for q in question_list:
print(q)
for l in q:
print(l)
if b'<details>' in l:
details_count += 1
if b'<summary>' in l:
summary_count += 1
if b'</details>' in l:
details_count += 1
if b'</summary>' in l:
summary_count += 1
print(summary_count, details_count)
if summary_count != 2 or details_count != 2:
raise Exception(f'You are missing a tag in {q}')
details_count = 0
summary_count = 0
# check_even_tags(get_question_list(file_list))
# if __name__ == '__main__':
# q_list = get_question_list(file_list)
# print(len(q_list))
# print(get_answered_questions(q_list))

29
scripts/tests/test.py Normal file
View File

@ -0,0 +1,29 @@
import unittest
import pathlib
from scripts.main import get_answered_questions, get_question_list
def open_test_case_file(n: int):
p = pathlib.Path(rf'D:\PycharmProjects\devops-interview-questions\scripts\tests\testcase{n}.md')
with open(p, 'rb') as f:
file_list = [line.rstrip() for line in f.readlines()]
return file_list
class QuestionCount(unittest.TestCase):
solutions = (
)
def test_count_case_1(self):
raw_list = open_test_case_file(1)
question_list = get_question_list(raw_list)
answers = get_answered_questions(question_list)
self.assertEqual(len(question_list), 21)
self.assertEqual(answers, 2)
def test_count_case_2(self):
pass

101
scripts/tests/testcase1.md Normal file
View File

@ -0,0 +1,101 @@
<details>
<summary>What objects in S3 consists of?
* Another way to ask it: explain key, value, version id and meta data in context of objects</summary><br><b>
</b></details>
<details>
<summary>Explain data consistency</summary><br><b>
</b></details>
<details>
<summary>Can you host dynamic websites on S3?. What about static websites?</summary><br><b>
</b></details>
<details>
<summary>What security measures have you taken in context of S3?</summary><br><b>
</b></details>
<details>
<summary>What is a storage class? What storage classes are you familiar with?</summary><br><b>
</b></details>
##### EC2
<details>
<summary>What is EC2? What is it used for?</summary><br><b>
</b></details>
<details>
<summary>What EC2 pricing models are there?</summary><br><b>
</b></details>
<details>
<summary>How to increase RAM for a given EC2 instance?</summary><br><b>
Stop the instance, the type of the instance to match the desired RAM and start the instance.
</b></details>
<details>
<summary>What is an AMI?</summary><br><b>
</b></details>
<details>
<summary>How many storage options are there for EC2 Instances?</summary><br><b>
</b></details>
<details>
<summary>What happens when an EC2 instance is stopped or terminated?</summary><br><b>
</b></details>
<details>
<summary>What are Security Groups?</summary><br><b>
</b></details>
<details>
<summary>How to migrate an instance to another availability zone?</summary><br><b>
</b></details>
<details>
<summary>What are spot instances?</summary><br><b>
</b></details>
##### CloudFront
<details>
<summary>Explain what is CloudFront and what is it used for</summary><br><b>
</b></details>
<details>
<summary>Explain the following
* Origin
* Edge location
* Distribution</summary><br><b>
</b></details>
<details>
<summary>What delivery methods available for the user with CDN?</summary><br><b>
</b></details>
<details>
<summary>True or False?. Objects are cached for the life of TTL</summary><br><b>
</b></details>
##### Load Balancers
<details>
<summary>What types of load balancers are supported in EC2 and what are they used for?</summary><br><b>
* Application LB - layer 7 traffic
* Network LB - ultra-high performances or static IP address
* Classic LB - low costs, good for test or dev environments
</b></details>
##### AWS Security
<details>
<summary>What is the shared responsibility model? In other words, what AWS is responsible for and what the user is responsible for in regards to Security?</summary><br><b>
</b></details>
<details>
<summary>What is the AWS compliance program?</summary><br><b>
</b></details>

View File

@ -0,0 +1,92 @@
<details>
<summary>Explain what each of the following services is used for
* AWS Inspector
* AWS Artifact
* AWS Shield</summary><br><b>
</b></details>
<details>
<summary>What is AWS WAF? Give an example of how it can used and describe what resources or services you can use it with</summary><br><b>
</b></details>
<details>
<summary>What AWS VPN is usef for?</summary><br><b>
</b></details>
<details>
<summary>What is the difference between Site-to-Site VPN and Client VPN?</summary><br><b>
</b></details>
<details>
<summary>True or False? AWS Inspector can perform both network and host assessments</summary><br><b>
True
</b></details>
#### AWS Databases
<details>
<summary>What is RDS?</summary><br><b>
</b></details>
<details>
<summary>What are some features or benefits of using RDS?</summary><br><b>
1. Multi AZ - great for Disaster Recovery
2. Read Replicas - for better performances
</b></details>
<details>
<summary>What is EBS?</summary><br><b>
</b></details>
#### AWS Networking
<details>
<summary>What is VPC?</summary><br><b>
</b></details>
<details>
<summary>Explain Security Groups and Network ACLs</summary><br><b>
</b></details>
#### Misc
<details>
<summary>Explain what are the following services and give an use case example for each one them:
* CloudTrail
* CloudWatch
* CloudSearch</summary><br><b>
</b></details>
## Network
<a name="network-beginner"></a>
#### :baby: Beginner
<details>
<summary>What is Ethernet?</summary><br><b>
</b></details>
<details>
<summary>What is a MAC address? What is it used for?</summary><br><b>
</b></details>
<details>
<summary>When is this MAC address used?: ff:ff:ff:ff:ff:ff</summary><br><b>
</b></details>
<details>
<summary>What is an IP address?</summary><br><b>
</b></details>
<details>
<summary>Explain subnet mask and given an example</summary><br><b>
</b></details>
<details>
<summary>What is a private IP address? What do we need it for?</summary><br><b>
</b></details>

View File

View File

View File