Compare commits

...

6 Commits

Author SHA1 Message Date
antejavor
c8719c20df Run on docker release version. 2023-06-21 13:15:39 +02:00
antejavor
de9aa1fd56 Decrease query quantity. 2023-06-19 14:47:53 +02:00
antejavor
1c55f9c5bd Add query module writes and reads. 2023-06-19 14:45:57 +02:00
antejavor
c7fb5016d3 Update running script. 2023-06-16 14:22:45 +02:00
antejavor
f9ce2a4be6 Init replication script. 2023-06-16 14:19:23 +02:00
Marko Budiselić
cf1a86ed13 Refactor tests/integration/run.sh (#1016) 2023-06-15 23:10:52 +02:00
8 changed files with 193 additions and 64 deletions

View File

@@ -196,22 +196,7 @@ jobs:
- name: Run integration tests
run: |
cd tests/integration
for name in *; do
if [ ! -d $name ]; then continue; fi
pushd $name >/dev/null
echo "Running: $name"
if [ -x prepare.sh ]; then
./prepare.sh
fi
if [ -x runner.py ]; then
./runner.py
elif [ -x runner.sh ]; then
./runner.sh
fi
echo
popd >/dev/null
done
tests/integration/run.sh
- name: Run cppcheck and clang-format
run: |

View File

@@ -146,22 +146,7 @@ jobs:
- name: Run integration tests
run: |
cd tests/integration
for name in *; do
if [ ! -d $name ]; then continue; fi
pushd $name >/dev/null
echo "Running: $name"
if [ -x prepare.sh ]; then
./prepare.sh
fi
if [ -x runner.py ]; then
./runner.py
elif [ -x runner.sh ]; then
./runner.sh
fi
echo
popd >/dev/null
done
tests/integration/run.sh
- name: Run cppcheck and clang-format
run: |

View File

@@ -146,22 +146,7 @@ jobs:
- name: Run integration tests
run: |
cd tests/integration
for name in *; do
if [ ! -d $name ]; then continue; fi
pushd $name >/dev/null
echo "Running: $name"
if [ -x prepare.sh ]; then
./prepare.sh
fi
if [ -x runner.py ]; then
./runner.py
elif [ -x runner.sh ]; then
./runner.sh
fi
echo
popd >/dev/null
done
tests/integration/run.sh
- name: Run cppcheck and clang-format
run: |

View File

@@ -146,22 +146,7 @@ jobs:
- name: Run integration tests
run: |
cd tests/integration
for name in *; do
if [ ! -d $name ]; then continue; fi
pushd $name >/dev/null
echo "Running: $name"
if [ -x prepare.sh ]; then
./prepare.sh
fi
if [ -x runner.py ]; then
./runner.py
elif [ -x runner.sh ]; then
./runner.sh
fi
echo
popd >/dev/null
done
tests/integration/run.sh
- name: Run cppcheck and clang-format
run: |

1
tests/integration/audit/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.log

47
tests/integration/run.sh Executable file
View File

@@ -0,0 +1,47 @@
#!/bin/bash -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
print_help() {
echo -e "$0 => run all under tests/integration"
echo -e "$0 folder_name => run single test under tests/integration"
exit 1
}
test_one() {
cd "$DIR"
integration_test_folder_name="$1"
pushd "$integration_test_folder_name" >/dev/null
echo "Running: $integration_test_folder_name"
if [ -x prepare.sh ]; then
./prepare.sh
fi
if [ -x runner.py ]; then
./runner.py
elif [ -x runner.sh ]; then
./runner.sh
fi
echo
popd >/dev/null
}
test_all() {
cd "$DIR"
for name in *; do
if [ ! -d "$name" ]; then continue; fi
test_one "$name"
done
}
if [ "$#" -eq 0 ]; then
test_all
else
if [ "$#" -gt 1 ]; then
print_help
else
if [ -d "$DIR/$1" ]; then
test_one "$1"
else
print_help
fi
fi
fi

View File

@@ -0,0 +1,114 @@
!/bin/bash -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd $DIR/../../build
query_list=(
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CALL dummy_query.dummy_read() YIELD *;"
"CALL dummy_query.dummy_write() YIELD *;"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
"CREATE (:Node)-[:CONNECTED]->(:Node);"
)
# Start the first memgraph instance
echo "Starting memgraph..."
./memgraph --log-level=TRACE --storage-recover-on-startup=true --storage-snapshot-interval-sec=600 --log-file=$DIR/memgraph.log --bolt-port 7687 --query-modules-directory=$DIR/query_modules &
sleep 5
# Capture the process ID (PID)
memgraph=$!
echo $memgraph
docker run -d -p 7688:7687 --name memgraph_docker memgraph/memgraph:2.8.0 --log-level=TRACE --storage-recover-on-startup=true --storage-snapshot-interval-sec=600 &
sleep 5
cd $DIR/query_modules
tar -cf - dummy_query.py | docker cp -a - memgraph_docker:/usr/lib/memgraph/query_modules/
docker exec -it -u 0 memgraph_docker bash -c "chown -R root:root /usr/lib/memgraph/query_modules"
docker_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' memgraph_docker)
echo $docker_ip
#check docker query module ownership
docker exec -it memgraph_docker ls -l /usr/lib/memgraph/query_modules
# Function to execute query commands
execute_query_native() {
local query=$1
echo "$query" | mgconsole -host "127.0.0.1" -port 7687
}
execute_query_docker(){
local query=$1
echo "$query" | mgconsole -host "127.0.0.1" -port 7688
}
execute_query_docker "CALL mg.load_all();"
execute_query_docker "CALL dummy_query.dummy_read() YIELD *;"
function cleanup {
echo "Terminating child processes..."
echo "Stopping memgraph..."
kill -9 $memgraph
sleep 5
echo "Stopping memgraph_docker..."
docker stop memgraph_docker
echo "Removing memgraph_docker..."
docker rm memgraph_docker
echo "Script execution completed."
exit
}
trap cleanup SIGINT
previous_time=$(date +%s)
previous_minute=$(date +%M)
previous_hour=$(date +%H)
while true; do
current_time=$(date +%s)
current_minute=$(date +%M)
current_hour=$(date +%H)
if ((current_time - previous_time >= 5)); then
echo "Five seconds have passe running create query."
for query in "${query_list[@]}"; do
execute_query_native "$query" &
execute_query_docker "$query" &
done
previous_time=$current_time
fi
if [[ $current_minute != $previous_minute ]]; then
echo "One minute has passed running match query."
execute_query_native "MATCH (n)-[r]->(m) RETURN DISTINCT COUNT(n);" &
execute_query_docker "MATCH (n)-[r]->(m) RETURN DISTINCT COUNT(n);" &
previous_minute=$current_minute
fi
if [[ $current_hour != $previous_hour ]]; then
echo "One hour has passed running delete query."
execute_query_native "MATCH (n) DETACH DELETE n;" &
execute_query_docker "MATCH (n) DETACH DELETE n;" &
previous_hour=$current_hour
fi
done

View File

@@ -0,0 +1,27 @@
import random
import mgp
@mgp.read_proc
def dummy_read(
context: mgp.ProcCtx,
) -> mgp.Record(total_vertices=int, total_edges=int):
vertices = context.graph.vertices
total_edges = 0
for vertex in vertices:
for edge in vertex.out_edges:
total_edges += 1
return mgp.Record(total_vertices=len(vertices), total_edges=total_edges)
@mgp.write_proc
def dummy_write(
context: mgp.ProcCtx,
) -> mgp.Record(vertex=mgp.Vertex):
for i in range(0, 5):
node = context.graph.create_vertex()
node.add_label("Procedure_node")
node.properties.set("id", random.randint(0, 100000))
return mgp.Record(vertex=node)