forked from ovh/pci-test
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
259686b255 | |||
012b0bf04c | |||
![]() |
cd81e92142 | ||
![]() |
7a1433eb61 | ||
936e0f80f0 | |||
6e7fe656b4 | |||
9ef89a992f | |||
a1ab1f4dcc | |||
![]() |
aec71aa51a | ||
![]() |
0b0ab94faa | ||
![]() |
0418052330 | ||
![]() |
a8f341a85f |
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
#.gitignore
|
||||
#ex3/*.terraform*
|
||||
#ex3/terraform*
|
||||
|
||||
# Local .terraform directories
|
||||
**/.terraform*
|
||||
|
||||
# .tfstate files
|
||||
*.tfstate
|
||||
*.tfstate.*
|
||||
|
||||
# Crash log files
|
||||
crash.log
|
||||
crash.*.log
|
||||
|
||||
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
|
||||
# password, private keys, and other secrets. These should not be part of version
|
||||
# control as they are data points which are potentially sensitive and subject
|
||||
# to change depending on the environment.
|
||||
*.tfvars
|
||||
*.tfvars.json
|
||||
|
||||
# Ignore override files as they are usually used to override resources locally and so
|
||||
# are not checked in
|
||||
override.tf
|
||||
override.tf.json
|
||||
*_override.tf
|
||||
*_override.tf.json
|
||||
|
||||
# Ignore transient lock info files created by terraform apply
|
||||
.terraform.tfstate.lock.info
|
||||
|
||||
# Include override files you do wish to add to version control using negated pattern
|
||||
# !example_override.tf
|
||||
|
||||
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
|
||||
# example: *tfplan*
|
||||
|
||||
# Ignore CLI configuration files
|
||||
.terraformrc
|
||||
terraform.rc
|
174
README.md
174
README.md
@ -1 +1,173 @@
|
||||
# merge-vs-rebase
|
||||
# Intro
|
||||
|
||||
We created this set of exercises to give you the opportunity to express yourself technically. Do as much as you can in
|
||||
the time you have. Feel free to ask us questions, if any. No worries if you can't make it all by lack of time or
|
||||
understanding of what we're asking. We'll defrief it with you during our next call.
|
||||
|
||||
**Have fun!**
|
||||
|
||||
## Fork
|
||||
|
||||
Register an account and fork this repo.
|
||||
|
||||
You will push your results to your fork.
|
||||
|
||||
# Ex. 1 - python
|
||||
|
||||
This exercise will be split into multiple smaller ones. For each one
|
||||
you can create files named `a.py`, `b.py` and `c.py`. You maybe resuse the same
|
||||
environment for all sub-exercises
|
||||
|
||||
Guidelines:
|
||||
- Use python version python3.7+.
|
||||
- Unless specified otherwise you can only use builtin modules.
|
||||
|
||||
### python - A
|
||||
|
||||
Write a script that prints out whatever text input is passed as argument
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
$ python a.py ping ping ping
|
||||
ping ping ping
|
||||
```
|
||||
|
||||
### python - B
|
||||
|
||||
Write a script take takes one argument (-t/--target) which can only
|
||||
accept the following values `titi`, `toto`, `tata`. When called with a valid
|
||||
target, the script should print out the target text to stdout (`titi`, `toto` or `tata`).
|
||||
When an invalid target is provided an error message should be printed to stderr
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
$ python b.py --target titi
|
||||
titi
|
||||
|
||||
$ python b.py -t tutu
|
||||
usage: b.py [-h] [-t {titi,toto,tata}]
|
||||
b.py: error: argument -t/--target: invalid choice: 'tutu' (choose from 'titi', 'toto', 'tata')
|
||||
```
|
||||
|
||||
### python - C
|
||||
|
||||
Write a script that creates ascii art equivalent of text passed as argument.
|
||||
For this exercise you may use a 3rd party module.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
$ python c.py 'Hello buddies'
|
||||
_ _ _ _ _ _ _ _
|
||||
| | | | ___ | || | ___ | |__ _ _ __| | __| |(_) ___ ___
|
||||
| |_| | / _ \| || | / _ \ | '_ \ | | | | / _` | / _` || | / _ \/ __|
|
||||
| _ || __/| || || (_) | | |_) || |_| || (_| || (_| || || __/\__ \
|
||||
|_| |_| \___||_||_| \___/ |_.__/ \__,_| \__,_| \__,_||_| \___||___/
|
||||
|
||||
```
|
||||
|
||||
# Ex. 2 - docker
|
||||
|
||||
In ex2 folder, you will find a `app` binary.
|
||||
|
||||
Can you build very lighweight docker image that contains ONLY `app` binary, and that execute `app` by default?
|
||||
|
||||
Push your Dockerfile in the ex2 folder.
|
||||
|
||||
# Ex. 3 - terraform
|
||||
|
||||
In ex3 folder, you will find an incomplete `openrc` file.
|
||||
|
||||
You will need to amend the file to configure the correct `OS_USERNAME`, `OS_PASSWORD` and `OS_REGION_NAME` with the one that we gave to you.
|
||||
|
||||
Then, using `terraform`, can you write a plan to boot a `d2-4` with a floating IP.
|
||||
|
||||
Bonus, on that instance, make sure a web server (`nginx`) is running.
|
||||
|
||||
Push your `main.tf` file in ex3 folder.
|
||||
|
||||
# Ex. 4 - git
|
||||
|
||||
In this repo, there are two branches:
|
||||
|
||||
- stein
|
||||
- queens
|
||||
|
||||
Stein contains the following commits:
|
||||
|
||||
- 1ff2641 (stein) G
|
||||
- cf24853 F
|
||||
- 3fcdfa0 E
|
||||
- cb8c71a D
|
||||
- 849ef26 C
|
||||
- 372c155 B
|
||||
- edc8ed7 A
|
||||
|
||||
Queens contains the following commits:
|
||||
|
||||
- 2624c16 (queens) F
|
||||
- 5e3521b B
|
||||
- edc8ed7 A
|
||||
|
||||
So the common ancestor is A (same commit ID).
|
||||
|
||||
B has been cherry-picked from stein to queens, without conflicts.
|
||||
|
||||
F has also been cherry-picked but with conflicts (solved, of course).
|
||||
|
||||
## Exercice
|
||||
|
||||
You will need to create two branches:
|
||||
|
||||
- merged
|
||||
- rebased
|
||||
|
||||
### Merged
|
||||
|
||||
Create the merged branch first:
|
||||
|
||||
```bash
|
||||
git checkout -b merged origin/queens
|
||||
```
|
||||
|
||||
Then merge the stein branch into your branch
|
||||
|
||||
```bash
|
||||
git merge origin/stein
|
||||
```
|
||||
|
||||
You will have a conflict to solved.
|
||||
|
||||
Solve it, then push your `merged` branch to your repo.
|
||||
|
||||
### Rebased
|
||||
|
||||
Now create the rebased branch:
|
||||
|
||||
```bash
|
||||
git checkout -b rebased origin/queens
|
||||
```
|
||||
|
||||
Now rebase it on top of stein:
|
||||
|
||||
```bash
|
||||
git rebase -i origin/stein
|
||||
```
|
||||
|
||||
You will have a conflict to solved.
|
||||
|
||||
Solve it, then push your `rebased` branch to your repo.
|
||||
|
||||
## Check diff
|
||||
|
||||
Now check the diff between your two branches `merged` and `rebased`.
|
||||
|
||||
```bash
|
||||
git diff merged..rebased
|
||||
```
|
||||
|
||||
Can you explain why you have a diff?
|
||||
|
||||
Write down the explanation in ex4 folder (like in a `README.md` file)
|
||||
|
0
ex1/.placeholder
Normal file
0
ex1/.placeholder
Normal file
4
ex1/a.py
Normal file
4
ex1/a.py
Normal file
@ -0,0 +1,4 @@
|
||||
import sys
|
||||
|
||||
argv = " ".join(sys.argv[1:])
|
||||
print("You've written:", argv)
|
24
ex1/b.py
Normal file
24
ex1/b.py
Normal file
@ -0,0 +1,24 @@
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
vars = {"toto", "tata", "titi"}
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument(
|
||||
'-t', '--target',
|
||||
nargs='+',
|
||||
choices=vars,
|
||||
help="Specify from 1 to 3 values from: toto, tata, titi.",
|
||||
required=True
|
||||
)
|
||||
|
||||
# Execute parsing
|
||||
args = parser.parse_args()
|
||||
|
||||
# Check if arguments are more than expected
|
||||
if len(args.target) > 3:
|
||||
print("Error: can be used **at max 3** values from 'toto', 'tata' and 'titi'.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
print("You've written:", args.target)
|
11
ex1/c.py
Normal file
11
ex1/c.py
Normal file
@ -0,0 +1,11 @@
|
||||
import sys
|
||||
import pyfiglet
|
||||
|
||||
# check if executed without text and print help
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python c.py 'text to be converted'")
|
||||
sys.exit(1)
|
||||
|
||||
text = " ".join(sys.argv[1:])
|
||||
f = pyfiglet.figlet_format(text)
|
||||
print(f)
|
0
ex2/.placeholder
Normal file
0
ex2/.placeholder
Normal file
3
ex2/dockerfile
Normal file
3
ex2/dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM alpine:latest
|
||||
COPY app /app
|
||||
ENTRYPOINT ["/app"]
|
0
ex3/.placeholder
Normal file
0
ex3/.placeholder
Normal file
31
ex3/main.tf
Normal file
31
ex3/main.tf
Normal file
@ -0,0 +1,31 @@
|
||||
terraform {
|
||||
required_version = ">= 0.14.0"
|
||||
required_providers {
|
||||
openstack = {
|
||||
source = "terraform-provider-openstack/openstack"
|
||||
version = "~> 1.53.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_networking_floatingip_v2" "_3245829148481055-FIP" {
|
||||
pool = "Ext-Net"
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "_3245829148481055-pci-test-ex3" {
|
||||
name = "_3245829148481055-pci-test-ex3"
|
||||
image_id = "d2083aa0-94ee-491d-a20c-0c8db1acdb96"
|
||||
flavor_name = "d2-4"
|
||||
key_pair = "3245829148481055-KP"
|
||||
security_groups = ["default"]
|
||||
user_data = "#cloud-config\npackages:\n - nginx\nruncmd:\n - systemctl enable nginx\n - systemctl start nginx"
|
||||
|
||||
network {
|
||||
name = "3245829148481055-int-net"
|
||||
}
|
||||
}
|
||||
|
||||
resource "openstack_compute_floatingip_associate_v2" "_3245829148481055-FIP" {
|
||||
floating_ip = "${openstack_networking_floatingip_v2._3245829148481055-FIP.address}"
|
||||
instance_id = "${openstack_compute_instance_v2._3245829148481055-pci-test-ex3.id}"
|
||||
}
|
0
ex4/.placeholder
Normal file
0
ex4/.placeholder
Normal file
Loading…
Reference in New Issue
Block a user