Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 44c91e9

Browse files
Merge pull request #5 from madeiramadeirabr/hotfix_ambiente_dev_x_test
Ajustes para boot de banco de dados
2 parents 666782d + 4c33d13 commit 44c91e9

File tree

16 files changed

+158
-49
lines changed

16 files changed

+158
-49
lines changed

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
# Fake credentials for Localstack
1111
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
1212
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
13+
TEST_ENV: ${TEST_ENV}
1314
depends_on:
1415
- "localstack"
1516
- "redis"
@@ -30,6 +31,7 @@ services:
3031
# Fake credentials for Localstack
3132
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
3233
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
34+
TEST_ENV: ${TEST_ENV}
3335
depends_on:
3436
- "localstack"
3537
- "redis"

examples/lambda_api/README.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@ Execute the follow command:
5959
./scripts/runenv.sh
6060
```
6161

62-
### Boot the queues
63-
Execute the follow command:
64-
```
65-
./scripts/boot.sh
66-
```
6762

6863
## Samples
6964
See the project samples in this folder [here](samples).
@@ -84,11 +79,7 @@ First you need install the tests requirements:
8479
### Components tests:
8580
Start the docker containers:
8681
```
87-
./scripts/runenv.sh
88-
```
89-
Booting the environment:
90-
```
91-
./scripts/boot.sh
82+
./scripts/testenv.sh
9283
```
9384

9485
Executing the tests:
@@ -123,11 +114,7 @@ Execute the follow command:
123114
### Component test coverage:
124115
Start the docker containers:
125116
```
126-
./scripts/runenv.sh
127-
```
128-
Booting the environment:
129-
```
130-
./scripts/boot.sh
117+
./scripts/testenv.sh
131118
```
132119

133120
Execute the follow command:

examples/lambda_api/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
# Fake credentials for Localstack
1111
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
1212
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
13+
TEST_ENV: ${TEST_ENV}
1314
depends_on:
1415
- "localstack"
1516
- "redis"

examples/lambda_api/scripts/boot-lambda.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if test -f ${current_parent_folder}requirements.txt; then
5555
fi
5656

5757
echo "Requirements file: ${current_parent_folder}requirements-vendor.txt"
58-
if test -f ${current_parent_folder}requirement.s-vendor.txt; then
58+
if test -f ${current_parent_folder}requirements-vendor.txt; then
5959
python3 -m pip install -r ${current_parent_folder}requirements-vendor.txt -t ${current_parent_folder}vendor
6060
# cat ${current_parent_folder}requirements-vendor.txt
6161
echo "requirements vendor..."
@@ -84,14 +84,18 @@ if test -f "${current_parent_folder}scripts/localstack/lambda/create-function-fr
8484
read -p "Press enter to continue..."
8585

8686
if test $APP_LAMBDA_EVENT_SOURCE = true;then
87-
echo '----------------------------------------'
88-
echo "$0 - Creating the event source: $APP_LAMBDA_NAME"
89-
echo '----------------------------------------'
90-
${current_parent_folder}scripts/localstack/lambda/create-event-source-mapping.sh $APP_LAMBDA_NAME $APP_QUEUE
87+
if test $TEST_ENV = 0; then
88+
echo '----------------------------------------'
89+
echo "$0 - Creating the event source: $APP_LAMBDA_NAME"
90+
echo '----------------------------------------'
91+
${current_parent_folder}scripts/localstack/lambda/create-event-source-mapping.sh $APP_LAMBDA_NAME $APP_QUEUE
92+
else
93+
echo 'Event source disabled'
94+
fi
9195
else
9296
echo 'There is no event source for this lambda'
9397
fi
9498
fi
9599
else
96100
echo "File not found: ${current_parent_folder}scripts/localstack/lambda/create-function-from-s3.sh"
97-
fi
101+
fi

examples/lambda_api/scripts/boot.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,15 @@ if test -f ${current_file_path}boot-lambda.sh; then
8686
${current_file_path}boot-lambda.sh
8787
else
8888
echo 'There is no lambda to be booted'
89-
fi
89+
fi
90+
91+
read -p "Press enter to continue..."
92+
93+
echo '----------------------------------------'
94+
echo "$0 - Database boot"
95+
echo '----------------------------------------'
96+
if test -f ${current_file_path}boot-db.sh; then
97+
${current_file_path}boot-db.sh
98+
else
99+
echo 'There is no database to be booted'
100+
fi
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -----------------------------------------------------------------------------
2+
# Current file variables
3+
# -----------------------------------------------------------------------------
4+
debug=false
5+
parent_folder="../"
6+
current_path=$(pwd)/
7+
current_path_basename=$(basename $(pwd))
8+
current_file_full_path=$0
9+
# echo $current_filepath
10+
current_file_name=$(basename -- "$0")
11+
# echo $current_filename
12+
if [ $current_file_full_path = $current_file_name ] || [ $current_file_full_path = "./$current_file_name" ]; then
13+
current_file_full_path="./${current_file_full_path}"
14+
current_file_path="./"
15+
else
16+
current_file_path="${current_file_full_path/$current_file_name/''}"
17+
fi
18+
19+
current_file_path_basename=$(basename -- "$current_file_path")
20+
#echo "xxxxx current_file_path_basename $current_file_path_basename"
21+
22+
if [ -z "$current_file_path_basename" ] || [ $current_file_path = "./" ]; then
23+
# echo 'aq'
24+
current_parent_folder="../"
25+
else
26+
# echo 'naq'
27+
current_file_path_basename=$current_file_path_basename/
28+
current_parent_folder="${current_file_path/$current_file_path_basename/''}"
29+
fi
30+
31+
32+
if [ debug ]; then
33+
echo '----------------------------------------'
34+
echo "$0 - Script variables"
35+
echo '----------------------------------------'
36+
echo "current_path: $current_path"
37+
echo "current_path_basename: $current_path_basename"
38+
echo "current_file_full_path: $current_file_full_path"
39+
echo "current_file_name: $current_file_name"
40+
echo "current_file_path: $current_file_path"
41+
echo "current_parent_folder: $current_parent_folder"
42+
echo '----------------------------------------'
43+
fi
44+
45+
if test -d ${current_parent_folder}vendor; then
46+
echo "rm -Rf ${current_parent_folder}vendor/*"
47+
rm -Rf ${current_parent_folder}vendor/*
48+
fi
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export TEST_ENV=0
12
docker-compose up $1 $2 $3
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export TEST_ENV=1
2+
docker-compose up $1 $2 $3

examples/lambda_sqs/README.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ Execute the follow command:
6969
./scripts/runenv.sh
7070
```
7171

72-
[//]: # (### Boot the lambda)
73-
74-
[//]: # (Execute the follow command:)
75-
76-
[//]: # (```)
77-
78-
[//]: # (./scripts/boot.sh)
79-
80-
[//]: # (```)
81-
8272
### Running the app
8373

8474

@@ -121,11 +111,7 @@ First you need install the tests requirements:
121111
### Components tests:
122112
Start the docker containers:
123113
```
124-
./scripts/runenv.sh
125-
```
126-
Booting the environment:
127-
```
128-
./scripts/boot.sh
114+
./scripts/testenv.sh
129115
```
130116

131117
Executing the tests:
@@ -160,13 +146,10 @@ Execute the follow command:
160146
### Component test coverage:
161147
Start the docker containers:
162148
```
163-
./scripts/runenv.sh
164-
```
165-
Booting the environment:
166-
```
167-
./scripts/boot.sh
149+
./scripts/testenv.sh
168150
```
169151

152+
170153
Execute the follow command:
171154
```
172155
./scripts/venv-exec.sh ./scripts/tests/component-coverage.sh

examples/lambda_sqs/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
# Fake credentials for Localstack
1111
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
1212
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
13+
TEST_ENV: ${TEST_ENV}
1314
depends_on:
1415
- "localstack"
1516
- "redis"

0 commit comments

Comments
 (0)