Skip to content

Commit 0f6b20f

Browse files
committed
Externalize common scripts in e2e tests
1 parent 0ec49cd commit 0f6b20f

3 files changed

Lines changed: 144 additions & 352 deletions

File tree

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env bash
2+
3+
install_test_tools() {
4+
apt-get -qq update
5+
apt-get -y install wget netcat kafkacat build-essential
6+
}
7+
8+
install_gcloud_sdk() {
9+
print_banner "Installing Google Cloud SDK"
10+
if [[ ! $(command -v gsutil) ]]; then
11+
CURRENT_DIR=$(dirname "$BASH_SOURCE")
12+
. "${CURRENT_DIR}"/install-google-cloud-sdk.sh
13+
fi
14+
15+
export GOOGLE_APPLICATION_CREDENTIALS
16+
gcloud auth activate-service-account --key-file ${GOOGLE_APPLICATION_CREDENTIALS}
17+
}
18+
19+
install_and_start_local_redis() {
20+
print_banner "Installing and tarting Redis at localhost:6379"
21+
# Allow starting serving in this Maven Docker image. Default set to not allowed.
22+
echo "exit 0" >/usr/sbin/policy-rc.d
23+
apt-get -y install redis-server >/var/log/redis.install.log
24+
redis-server --daemonize yes
25+
redis-cli ping
26+
}
27+
28+
install_and_start_local_postgres() {
29+
print_banner "Installing and starting Postgres at localhost:5432"
30+
apt-get -y install postgresql >/var/log/postgresql.install.log
31+
service postgresql start
32+
# Initialize with database: 'postgres', user: 'postgres', password: 'password'
33+
cat <<EOF >/tmp/update-postgres-role.sh
34+
psql -c "ALTER USER postgres PASSWORD 'password';"
35+
EOF
36+
chmod +x /tmp/update-postgres-role.sh
37+
su -s /bin/bash -c /tmp/update-postgres-role.sh postgres
38+
export PGPASSWORD=password
39+
pg_isready
40+
}
41+
42+
install_and_start_local_zookeeper_and_kafka() {
43+
print_banner "Installing and starting Zookeeper at localhost:2181 and Kafka at localhost:9092"
44+
wget -qO- https://www-eu.apache.org/dist/kafka/2.3.0/kafka_2.12-2.3.0.tgz | tar xz
45+
mv kafka_2.12-2.3.0/ /tmp/kafka
46+
nohup /tmp/kafka/bin/zookeeper-server-start.sh /tmp/kafka/config/zookeeper.properties &>/var/log/zookeeper.log 2>&1 &
47+
sleep 5
48+
tail -n10 /var/log/zookeeper.log
49+
nohup /tmp/kafka/bin/kafka-server-start.sh /tmp/kafka/config/server.properties &>/var/log/kafka.log 2>&1 &
50+
sleep 20
51+
tail -n10 /var/log/kafka.log
52+
kafkacat -b localhost:9092 -L
53+
}
54+
55+
build_feast_core_and_serving() {
56+
print_banner "Building Feast Core and Feast Serving"
57+
infra/scripts/download-maven-cache.sh \
58+
--archive-uri gs://feast-templocation-kf-feast/.m2.2019-10-24.tar \
59+
--output-dir /root/
60+
61+
# Build jars for Feast
62+
mvn --quiet --batch-mode --define skipTests=true clean package
63+
64+
ls -lh core/target/*jar
65+
ls -lh serving/target/*jar
66+
}
67+
68+
start_feast_core() {
69+
print_banner "Starting Feast Core"
70+
71+
if [ -n "$1" ]; then
72+
echo "Custom Spring application.yml location provided: $1"
73+
export CONFIG_ARG="--spring.config.location=file://$1"
74+
fi
75+
76+
nohup java -jar core/target/feast-core-$FEAST_BUILD_VERSION.jar $CONFIG_ARG &> /var/log/feast-core.log &
77+
./wait-for-it.sh localhost:6565 --timeout=90
78+
79+
tail -n10 /var/log/feast-core.log
80+
nc -w2 localhost 6565 </dev/null
81+
}
82+
83+
start_feast_serving() {
84+
print_banner "Starting Feast Online Serving"
85+
86+
if [ -n "$1" ]; then
87+
echo "Custom Spring application.yml location provided: $1"
88+
export CONFIG_ARG="--spring.config.location=file://$1"
89+
fi
90+
91+
nohup java -jar serving/target/feast-serving-$FEAST_BUILD_VERSION.jar $CONFIG_ARG &>/var/log/feast-serving-online.log &
92+
./wait-for-it.sh localhost:6566 --timeout=60
93+
94+
tail -n100 /var/log/feast-serving-online.log
95+
nc -w2 localhost 6566 </dev/null
96+
}
97+
98+
install_python_with_miniconda_and_feast_sdk() {
99+
print_banner "Installing Python 3.7 with Miniconda and Feast SDK"
100+
# Install Python 3.7 with Miniconda
101+
wget -q https://repo.continuum.io/miniconda/Miniconda3-4.7.12-Linux-x86_64.sh \
102+
-O /tmp/miniconda.sh
103+
bash /tmp/miniconda.sh -b -p /root/miniconda -f
104+
/root/miniconda/bin/conda init
105+
source ~/.bashrc
106+
107+
# Install Feast Python SDK and test requirements
108+
make compile-protos-python
109+
pip install -qe sdk/python
110+
pip install -qr tests/e2e/requirements.txt
111+
}
112+
113+
print_banner() {
114+
echo "
115+
============================================================
116+
$1
117+
============================================================
118+
"
119+
}

infra/scripts/test-end-to-end-batch.sh

Lines changed: 14 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test -z ${TEMP_BUCKET} && TEMP_BUCKET="feast-templocation-kf-feast"
2424
test -z ${JOBS_STAGING_LOCATION} && JOBS_STAGING_LOCATION="gs://${TEMP_BUCKET}/staging-location"
2525

2626
# Get the current build version using maven (and pom.xml)
27-
FEAST_BUILD_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
27+
export FEAST_BUILD_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
2828
echo Building version: $FEAST_BUILD_VERSION
2929

3030
echo "
@@ -38,152 +38,24 @@ This script will run end-to-end tests for Feast Core and Batch Serving.
3838
tests/e2e via pytest.
3939
"
4040

41-
apt-get -qq update
42-
apt-get -y install wget netcat kafkacat build-essential
41+
source setup-common-functions.sh
4342

44-
45-
echo "
46-
============================================================
47-
Installing gcloud SDK
48-
============================================================
49-
"
50-
if [[ ! $(command -v gsutil) ]]; then
51-
CURRENT_DIR=$(dirname "$BASH_SOURCE")
52-
. "${CURRENT_DIR}"/install-google-cloud-sdk.sh
53-
fi
54-
55-
export GOOGLE_APPLICATION_CREDENTIALS
56-
gcloud auth activate-service-account --key-file ${GOOGLE_APPLICATION_CREDENTIALS}
57-
58-
59-
60-
echo "
61-
============================================================
62-
Installing Redis at localhost:6379
63-
============================================================
64-
"
65-
# Allow starting serving in this Maven Docker image. Default set to not allowed.
66-
echo "exit 0" > /usr/sbin/policy-rc.d
67-
apt-get -y install redis-server > /var/log/redis.install.log
68-
redis-server --daemonize yes
69-
redis-cli ping
70-
71-
echo "
72-
============================================================
73-
Installing Postgres at localhost:5432
74-
============================================================
75-
"
76-
apt-get -y install postgresql > /var/log/postgresql.install.log
77-
service postgresql start
78-
# Initialize with database: 'postgres', user: 'postgres', password: 'password'
79-
cat <<EOF > /tmp/update-postgres-role.sh
80-
psql -c "ALTER USER postgres PASSWORD 'password';"
81-
EOF
82-
chmod +x /tmp/update-postgres-role.sh
83-
su -s /bin/bash -c /tmp/update-postgres-role.sh postgres
84-
export PGPASSWORD=password
85-
pg_isready
86-
87-
echo "
88-
============================================================
89-
Installing Zookeeper at localhost:2181
90-
Installing Kafka at localhost:9092
91-
============================================================
92-
"
93-
wget -qO- https://www-eu.apache.org/dist/kafka/2.3.0/kafka_2.12-2.3.0.tgz | tar xz
94-
mv kafka_2.12-2.3.0/ /tmp/kafka
95-
nohup /tmp/kafka/bin/zookeeper-server-start.sh /tmp/kafka/config/zookeeper.properties &> /var/log/zookeeper.log 2>&1 &
96-
sleep 5
97-
tail -n10 /var/log/zookeeper.log
98-
nohup /tmp/kafka/bin/kafka-server-start.sh /tmp/kafka/config/server.properties &> /var/log/kafka.log 2>&1 &
99-
sleep 20
100-
tail -n10 /var/log/kafka.log
101-
kafkacat -b localhost:9092 -L
43+
install_test_tools
44+
install_gcloud_sdk
45+
install_and_start_local_redis
46+
install_and_start_local_postgres
47+
install_and_start_local_zookeeper_and_kafka
10248

10349
if [[ ${SKIP_BUILD_JARS} != "true" ]]; then
104-
echo "
105-
============================================================
106-
Building jars for Feast
107-
============================================================
108-
"
109-
110-
infra/scripts/download-maven-cache.sh \
111-
--archive-uri gs://feast-templocation-kf-feast/.m2.2019-10-24.tar \
112-
--output-dir /root/
113-
114-
# Build jars for Feast
115-
mvn --quiet --batch-mode --define skipTests=true clean package
116-
117-
ls -lh core/target/*jar
118-
ls -lh serving/target/*jar
50+
build_feast_core_and_serving
11951
else
12052
echo "[DEBUG] Skipping building jars"
12153
fi
12254

123-
echo "
124-
============================================================
125-
Starting Feast Core
126-
============================================================
127-
"
128-
# Start Feast Core in background
129-
cat <<EOF > /tmp/core.application.yml
130-
grpc:
131-
port: 6565
132-
enable-reflection: true
133-
134-
feast:
135-
jobs:
136-
polling_interval_milliseconds: 10000
137-
job_update_timeout_seconds: 240
138-
139-
active_runner: direct
140-
141-
runners:
142-
- name: direct
143-
type: DirectRunner
144-
options: {}
145-
146-
metrics:
147-
enabled: false
148-
149-
stream:
150-
type: kafka
151-
options:
152-
topic: feast-features
153-
bootstrapServers: localhost:9092
154-
replicationFactor: 1
155-
partitions: 1
156-
157-
spring:
158-
jpa:
159-
properties.hibernate:
160-
format_sql: true
161-
event:
162-
merge:
163-
entity_copy_observer: allow
164-
hibernate.naming.physical-strategy=org.hibernate.boot.model.naming: PhysicalNamingStrategyStandardImpl
165-
hibernate.ddl-auto: update
166-
datasource:
167-
url: jdbc:postgresql://localhost:5432/postgres
168-
username: postgres
169-
password: password
170-
EOF
171-
172-
nohup java -jar core/target/feast-core-${FEAST_BUILD_VERSION}.jar \
173-
--spring.config.location=file:///tmp/core.application.yml \
174-
&> /var/log/feast-core.log &
175-
sleep 35
176-
tail -n10 /var/log/feast-core.log
177-
nc -w2 localhost 6565 < /dev/null
178-
179-
echo "
180-
============================================================
181-
Starting Feast Warehouse Serving
182-
============================================================
183-
"
55+
export FEAST_JOBS_POLLING_INTERVAL_MILLISECONDS=10000
56+
start_feast_core
18457

18558
DATASET_NAME=feast_$(date +%s)
186-
18759
bq --location=US --project_id=${GOOGLE_CLOUD_PROJECT} mk \
18860
--dataset \
18961
--default_table_expiration 86400 \
@@ -232,35 +104,11 @@ server:
232104
233105
EOF
234106

235-
nohup java -jar serving/target/feast-serving-${FEAST_BUILD_VERSION}.jar \
236-
--spring.config.location=file:///tmp/serving.warehouse.application.yml \
237-
&> /var/log/feast-serving-warehouse.log &
238-
sleep 15
239-
tail -n100 /var/log/feast-serving-warehouse.log
240-
nc -w2 localhost 6566 < /dev/null
241-
242-
echo "
243-
============================================================
244-
Installing Python 3.7 with Miniconda and Feast SDK
245-
============================================================
246-
"
247-
# Install Python 3.7 with Miniconda
248-
wget -q https://repo.continuum.io/miniconda/Miniconda3-4.7.12-Linux-x86_64.sh \
249-
-O /tmp/miniconda.sh
250-
bash /tmp/miniconda.sh -b -p /root/miniconda -f
251-
/root/miniconda/bin/conda init
252-
source ~/.bashrc
107+
start_feast_serving /tmp/serving.warehouse.application.yml
253108

254-
# Install Feast Python SDK and test requirements
255-
make compile-protos-python
256-
pip install -qe sdk/python
257-
pip install -qr tests/e2e/requirements.txt
109+
install_python_with_miniconda_and_feast_sdk
258110

259-
echo "
260-
============================================================
261-
Running end-to-end tests with pytest at 'tests/e2e'
262-
============================================================
263-
"
111+
print_banner "Running end-to-end tests with pytest at 'tests/e2e'"
264112
# Default artifact location setting in Prow jobs
265113
LOGS_ARTIFACT_PATH=/logs/artifacts
266114

@@ -282,12 +130,7 @@ fi
282130

283131
cd ${ORIGINAL_DIR}
284132

285-
echo "
286-
============================================================
287-
Cleaning up
288-
============================================================
289-
"
133+
print_banner "Cleaning up"
290134

291135
bq rm -r -f ${GOOGLE_CLOUD_PROJECT}:${DATASET_NAME}
292-
293136
exit ${TEST_EXIT_CODE}

0 commit comments

Comments
 (0)