Skip to content

Commit 99a33de

Browse files
authored
Add smoke testing (#597)
1 parent f683aef commit 99a33de

40 files changed

+1204
-0
lines changed

smoke-release-testing/.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.build
2+
*.tar.gz*
3+
get_helm.sh
4+
kubectl
5+
kubectl.sha256
6+
dist/

smoke-release-testing/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# A smoke test of Memgraph's release
2+
3+
The reasons for smoke release testing are:
4+
* to test a given feature during the release cycle (the fastest is to directly build and run memgraph binary).
5+
* to test packaged versions of Memgraph (e.g. Docker)
6+
* to test on a given deployment infrastructure (e.g. k8s)
7+
* to test under different infrastructure environments (e.g. k8s+GCP, k8s+Azure)
8+
* to test backward compatibility
9+
* to test Community -> Enterprise transition
10+
* to test Enterprise -> Community transition.
11+
12+
NOTE: GQLAlchemy version is not fixed on purpose.
13+
NOTE: GQLAlchmey uses an old version of the neo client -> the neo4j version is fixed.
14+
15+
## Test Types
16+
17+
* Testing drivers (mostly Memgraph ones, testing official Neo4j drives is done
18+
under https://github.com/memgraph/memgraph/tree/master/tests/drivers + these
19+
are run against the plain binary, not a full package).
20+
* inspecting packaged files
21+
* running queries to test that all features are correctly packaged
22+
* migration procedures.
23+
24+
## Delivery Types
25+
26+
* Plain memgraph binary
27+
* Linux packages (.deb, .rpm)
28+
* Docker images
29+
* Helm charts.
30+
31+
## Environments
32+
33+
* ARCH: x86, ARM
34+
* OS: Linux, Mac, Windows
35+
* K8s: Kind, Minicube
36+
* Clouds: AWS, Azure, GCP.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
memgraph:
2+
image:
3+
repository: memgraph/memgraph
4+
tag: 2.18.1
5+
pullPolicy: IfNotPresent
6+
env:
7+
MEMGRAPH_ENTERPRISE_LICENSE: "<your-license>"
8+
MEMGRAPH_ORGANIZATION_NAME: "<your-organization-name>"
9+
probes:
10+
startup:
11+
failureThreshold: 30
12+
periodSeconds: 10
13+
readiness:
14+
initialDelaySeconds: 5
15+
periodSeconds: 5
16+
liveness:
17+
initialDelaySeconds: 30
18+
periodSeconds: 10
19+
data:
20+
volumeClaim:
21+
storagePVCClassName: ""
22+
storagePVC: true
23+
storagePVCSize: "1Gi"
24+
logPVCClassName: ""
25+
logPVC: true
26+
logPVCSize: "256Mi"
27+
coordinators:
28+
volumeClaim:
29+
storagePVCClassName: ""
30+
storagePVC: true
31+
storagePVCSize: "1Gi"
32+
logPVCClassName: ""
33+
logPVC: true
34+
logPVCSize: "256Mi"
35+
affinity:
36+
enabled: false
37+
38+
data:
39+
- id: "0"
40+
boltPort: 7687
41+
managementPort: 10000
42+
replicationPort: 20000
43+
args:
44+
- "--experimental-enabled=high-availability"
45+
- "--management-port=10000"
46+
- "--bolt-port=7687"
47+
- "--also-log-to-stderr"
48+
- "--log-level=TRACE"
49+
- "--log-file=/var/log/memgraph/memgraph.log"
50+
- "--telemetry-enabled=False"
51+
52+
- id: "1"
53+
boltPort: 7687
54+
managementPort: 10000
55+
replicationPort: 20000
56+
args:
57+
- "--experimental-enabled=high-availability"
58+
- "--management-port=10000"
59+
- "--bolt-port=7687"
60+
- "--also-log-to-stderr"
61+
- "--log-level=TRACE"
62+
- "--log-file=/var/log/memgraph/memgraph.log"
63+
- "--telemetry-enabled=False"
64+
65+
coordinators:
66+
- id: "1"
67+
boltPort: 7687
68+
managementPort: 10000
69+
coordinatorPort: 12000
70+
args:
71+
- "--experimental-enabled=high-availability"
72+
- "--coordinator-id=1"
73+
- "--coordinator-port=12000"
74+
- "--management-port=10000"
75+
- "--bolt-port=7687"
76+
- "--also-log-to-stderr"
77+
- "--log-level=TRACE"
78+
- "--coordinator-hostname=memgraph-coordinator-1.default.svc.cluster.local"
79+
- "--log-file=/var/log/memgraph/memgraph.log"
80+
- "--nuraft-log-file=/var/log/memgraph/memgraph.log"
81+
- "--telemetry-enabled=False"
82+
83+
- id: "2"
84+
boltPort: 7687
85+
managementPort: 10000
86+
coordinatorPort: 12000
87+
args:
88+
- "--experimental-enabled=high-availability"
89+
- "--coordinator-id=2"
90+
- "--coordinator-port=12000"
91+
- "--management-port=10000"
92+
- "--bolt-port=7687"
93+
- "--also-log-to-stderr"
94+
- "--log-level=TRACE"
95+
- "--coordinator-hostname=memgraph-coordinator-2.default.svc.cluster.local"
96+
- "--log-file=/var/log/memgraph/memgraph.log"
97+
- "--nuraft-log-file=/var/log/memgraph/memgraph.log"
98+
- "--telemetry-enabled=False"
99+
100+
- id: "3"
101+
boltPort: 7687
102+
managementPort: 10000
103+
coordinatorPort: 12000
104+
args:
105+
- "--experimental-enabled=high-availability"
106+
- "--coordinator-id=3"
107+
- "--coordinator-port=12000"
108+
- "--management-port=10000"
109+
- "--bolt-port=7687"
110+
- "--also-log-to-stderr"
111+
- "--log-level=TRACE"
112+
- "--coordinator-hostname=memgraph-coordinator-3.default.svc.cluster.local"
113+
- "--log-file=/var/log/memgraph/memgraph.log"
114+
- "--nuraft-log-file=/var/log/memgraph/memgraph.log"
115+
- "--telemetry-enabled=False"

smoke-release-testing/experiment.bash

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash -e
2+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
source "$SCRIPT_DIR/utils.bash"
4+
5+
# NOTE: Use the below line if you just want to spin up the containers and leave them running.
6+
# run_memgraph_docker_containers RC RC
7+
# NOTE: Use the below line if you want to cleanup the containers after run of this script.
8+
spinup_and_cleanup_memgraph_dockers none none
9+
echo "Waiting for memgraph to initialize..."
10+
wait_for_memgraph $MEMGRAPH_DEFAULT_HOST $MEMGRAPH_NEXT_DATA_BOLT_PORT
11+
echo "Memgraph is up and running!"
12+
13+
source ./mgconsole/multi_tenancy.bash
14+
test_multi_tenancy $MEMGRAPH_DEFAULT_HOST $MEMGRAPH_NEXT_DATA_BOLT_PORT
15+
16+
# NOTE: Test what's the exit status of the script by using `echo $?`:
17+
# * if it's == 0 -> all good
18+
# * if it's != 0 -> something went wrong.

smoke-release-testing/flags.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import sys
2+
import subprocess
3+
import xml.etree.ElementTree as ET
4+
5+
6+
def extract_flags(to_run):
7+
ret = {}
8+
data = subprocess.run(to_run, stdout=subprocess.PIPE).stdout.decode("utf-8")
9+
data = "\n".join([line for line in data.split("\n") if line.startswith("<")])
10+
root = ET.fromstring(data)
11+
for child in root:
12+
if child.tag == "usage" and child.text.lower().count("warning"):
13+
raise Exception("You should set the usage message!")
14+
if child.tag == "flag":
15+
flag = {}
16+
for elem in child:
17+
flag[elem.tag] = elem.text if elem.text is not None else ""
18+
flag["override"] = False
19+
ret[flag["name"]] = flag
20+
return ret
21+
22+
23+
# The intention below was just to print flags into a file and make diff to
24+
# manually observer the difference. Future extenstion is to take the same
25+
# values and run memgraph between versions with non-default flags.
26+
memgraph_docker_image = sys.argv[1]
27+
flags = extract_flags(
28+
["docker", "run", "-it", "--rm", memgraph_docker_image, "--help-xml"]
29+
)
30+
for flag_name, flag_details in flags.items():
31+
print(flag_name, flag_details["default"])
32+
# IMPORTANT: There is also an issue with printing default values, because
33+
# --help is returning build defaults which is missleaning to the user but also
34+
# here because we can't detect changes in default values.

smoke-release-testing/init.bash

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash -e
2+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
source "$SCRIPT_DIR/utils.bash"
4+
5+
if [ ! -x "$(command -v jq)" ]; then
6+
sudo apt-get install -y jq
7+
fi
8+
9+
if [ ! -x "$(command -v go)" ]; then
10+
sudo apt install -y golang-go
11+
# or, https://go.dev/doc/install
12+
fi
13+
14+
go install sigs.k8s.io/[email protected]
15+
echo "kind installed under $(go env GOPATH)/bin"
16+
export PATH="$(go env GOPATH)/bin:$PATH"
17+
kind --version
18+
19+
if [ ! -f "/usr/local/bin/kubectl" ]; then
20+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
21+
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
22+
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
23+
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
24+
fi
25+
kubectl version --client
26+
27+
# TODO(gitbuda): Something is broken here -> properly check for cluster status.
28+
if ! kubectl cluster-info --context kind-kind-kind; then
29+
kind create cluster --name kind-kind
30+
fi
31+
kubectl get all -A
32+
33+
if [ ! -f "/usr/local/bin/helm" ]; then
34+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
35+
chmod 700 get_helm.sh
36+
./get_helm.sh
37+
fi
38+
39+
helm repo add memgraph https://memgraph.github.io/helm-charts
40+
helm repo update
41+
helm repo list
42+
43+
# Last mgconsole.
44+
# rm -rf $SCRIPT_DIR/mgconsole.build # To download and rebuild everything.
45+
if [ ! -d "$SCRIPT_DIR/mgconsole.build" ]; then
46+
git clone [email protected]:memgraph/mgconsole.git "$SCRIPT_DIR/mgconsole.build"
47+
fi
48+
MG_CONSOLE_TAG="master"
49+
MG_CONSOLE_BINARY="$SCRIPT_DIR/mgconsole.build/build/src/mgconsole"
50+
if [ ! -f "$MG_CONSOLE_BINARY" ]; then
51+
cd "$SCRIPT_DIR/mgconsole.build"
52+
git checkout $MG_CONSOLE_TAG
53+
mkdir -p build && cd build
54+
cmake -DCMAKE_RELEASE_TYPE=Release ..
55+
make -j8
56+
fi
57+
if [ -x "$MG_CONSOLE_BINARY" ]; then
58+
echo "mgconsole available"
59+
else
60+
echo "failed to build mgconsole"
61+
fi
62+
63+
cd $SCRIPT_DIR/query_modules
64+
mkdir -p dist
65+
g++ -std=c++20 -fPIC -shared -I$SCRIPT_DIR/../mage/cpp/memgraph/include -o dist/basic_cpp.so basic.cpp
66+
67+
rm $SCRIPT_DIR/get_helm.sh || true
68+
rm $SCRIPT_DIR/kubectl || true
69+
rm $SCRIPT_DIR/kubectl.sha256 || true

smoke-release-testing/init_mac.bash

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash -e
2+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
source "$SCRIPT_DIR/utils.bash"
4+
5+
if [ ! -x "$(command -v go)" ]; then
6+
brew install go
7+
fi
8+
go version
9+
10+
if [ ! -f "$(go env GOPATH)/bin/kind" ]; then
11+
go install sigs.k8s.io/[email protected]
12+
echo "kind installed under $(go env GOPATH)/bin"
13+
fi
14+
export PATH="$(go env GOPATH)/bin:$PATH"
15+
kind --version
16+
17+
if [ ! -f "/usr/local/bin/kubectl" ]; then
18+
echo "TODO: install kubectl"
19+
exit 1
20+
fi
21+
kubectl version --client
22+
23+
if [ ! -f "/usr/local/bin/helm" ]; then
24+
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
25+
chmod 700 get_helm.sh
26+
./get_helm.sh
27+
fi
28+
helm version
29+
30+
# kubectl config get-clusters
31+
if ! kubectl cluster-info --context kind-experiment; then
32+
kind create cluster --name experiment
33+
fi
34+
kubectl get all -A
35+
36+
helm repo add memgraph https://memgraph.github.io/helm-charts
37+
helm update
38+
helm list
39+
helm my-release memgraph/memgraph
40+
41+
rm $SCRIPT_DIR/get_helm.sh || true
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash -e
2+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
source "$SCRIPT_DIR/utils.bash"
4+
5+
spinup_and_cleanup_memgraph_dockers
6+
echo "Waiting for memgraph to initialize..."
7+
wait_for_memgraph $MEMGRAPH_DEFAULT_HOST $MEMGRAPH_NEXT_DATA_BOLT_PORT
8+
echo "Memgraph is up and running!"
9+
10+
docker exec -it memgraph_next_data bash -c "test -x /usr/lib/memgraph/memgraph"
11+
docker exec -it memgraph_next_data bash -c "test -d /usr/lib/memgraph/auth_module"
12+
docker exec -it memgraph_next_data bash -c "test -d /usr/lib/memgraph/query_modules"
13+
docker exec -it memgraph_next_data bash -c "test -d /usr/lib/memgraph/python_support"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Memgraph features tested by mgconsole
2+
3+
NOTE: Each `.bash` file under this directory should be runnable in isolation.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
source "$SCRIPT_DIR/../utils.bash"
4+
5+
test_show_database_settings() {
6+
__host="$1"
7+
__port="$2"
8+
echo "SHOW DATABASE SETTINGS;" | $MEMGRAPH_CONSOLE_BINARY --host $__host --port $__port
9+
}
10+
11+
test_auth_roles() {
12+
__host="$1"
13+
__port="$2"
14+
echo "FEATURE: Auth Roles"
15+
16+
echo "CREATE ROLE IF NOT EXISTS test_reader;" | $MEMGRAPH_CONSOLE_BINARY --host $__host --port $__port
17+
echo "SHOW ROLES;" | $MEMGRAPH_CONSOLE_BINARY --host $__host --port $__port
18+
}
19+
20+
if [ "${BASH_SOURCE[0]}" -ef "$0" ]; then
21+
# NOTE: Take a look at session_trace.bash for the v1 implementation of binary-docker picker.
22+
trap cleanup_memgraph_binary_processes EXIT # To make sure cleanup is done.
23+
set -e # To make sure the script will return non-0 in case of a failure.
24+
25+
# NOTE: If you want to run custom memgraph binary just set MEMGRAPH_BUILD_PATH to your memgraph build directory.
26+
run_memgraph_binary "--bolt-port $MEMGRAPH_DEFAULT_PORT --log-level=TRACE --log-file=mg_test_auth_roles_enterprise.logs --data-directory=test_auth_roles_enterprise"
27+
wait_for_memgraph $MEMGRAPH_DEFAULT_HOST $MEMGRAPH_DEFAULT_PORT
28+
# test_show_database_settings $MEMGRAPH_DEFAULT_HOST $MEMGRAPH_DEFAULT_PORT
29+
test_auth_roles $MEMGRAPH_DEFAULT_HOST $MEMGRAPH_DEFAULT_PORT
30+
cleanup_memgraph_binary_processes
31+
32+
rm -rf $MG_BUILD_PATH/test_auth_roles_enterprise/auth
33+
ORIG_MEMGRAPH_ENTEPRISE_LICENSE="$MEMGRAPH_ENTERPRISE_LICENSE"
34+
ORIG_MEMGRAPH_ORGANIZATION_NAME="$MEMGRAPH_ORGANIZATION_NAME"
35+
unset MEMGRAPH_ENTERPRISE_LICENSE
36+
unset MEMGRAPH_ORGANIZATION_NAME
37+
# NOTE: License is not stored in settings.
38+
run_memgraph_binary "--bolt-port 7688 --log-level=TRACE --log-file=mg_test_auth_roles_community.logs --data-directory=test_auth_roles_enterprise"
39+
wait_for_memgraph $MEMGRAPH_DEFAULT_HOST 7688
40+
# test_show_database_settings $MEMGRAPH_DEFAULT_HOST 7688
41+
test_auth_roles $MEMGRAPH_DEFAULT_HOST 7688
42+
export MEMGRAPH_ENTERPRISE_LICENSE="$ORIG_MEMGRAPH_ENTEPRISE_LICENSE"
43+
export MEMGRAPH_ORGANIZATION_NAME="$ORIG_MEMGRAPH_ORGANIZATION_NAME"
44+
fi

0 commit comments

Comments
 (0)