Skip to content

Commit e4eef73

Browse files
committed
Test ES backup against v2.x appliances
1 parent 80a877f commit e4eef73

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

test/bin/ghe-es-snapshot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
# Usage: ghe-es-snapshot
3+
# Emulates the remote GitHub ghe-service-ensure-mysql command. Tests use this
4+
# to assert that the command was executed.
5+
set -e
6+
echo "ghe-es-snapshot OK"

test/test-ghe-backup.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ mkdir -p gh-enterprise-es/node/0
2121
touch gh-enterprise-es/node/0/stuff1
2222
touch gh-enterprise-es/node/0/stuff2
2323

24+
# Create some fake elasticsearch data in the remote snapshot data directory
25+
if [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
26+
mkdir -p "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-snapshots"
27+
cd "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-snapshots"
28+
echo "fake snapshot file" > "snapshot-1"
29+
echo "fake metadata file" > "metadata-1"
30+
mkdir -p indices/repositories
31+
echo "fake document data" > indices/repositories/dumb-file
32+
fi
33+
2434
# Create some test repositories in the remote repositories dir
2535
mkdir "$GHE_REMOTE_DATA_USER_DIR/repositories"
2636
cd "$GHE_REMOTE_DATA_USER_DIR/repositories"
@@ -84,10 +94,13 @@ begin_test "ghe-backup first snapshot"
8494
# verify all pages data was transferred
8595
diff -ru "$GHE_REMOTE_DATA_USER_DIR/pages" "$GHE_DATA_DIR/current/pages"
8696

87-
# TODO ES backup not yet supported under 2.x VM
97+
# ES backup path is different under v11.10.x and v2.x appliances
8898
if [ "$GHE_VERSION_MAJOR" -eq 1 ]; then
89-
# verify all ES data was transferred
99+
# verify all ES data was transferred from live directory
90100
diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch"
101+
elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
102+
# verify all ES data was transferred from snapshot directory
103+
diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-snapshots" "$GHE_DATA_DIR/current/elasticsearch"
91104
fi
92105
)
93106
end_test
@@ -146,10 +159,13 @@ begin_test "ghe-backup subsequent snapshot"
146159
# verify all pages data was transferred
147160
diff -ru "$GHE_REMOTE_DATA_USER_DIR/pages" "$GHE_DATA_DIR/current/pages"
148161

149-
# TODO ES backup not yet supported under 2.x VM
162+
# ES backup path is different under v11.10.x and v2.x appliances
150163
if [ "$GHE_VERSION_MAJOR" -eq 1 ]; then
151-
# verify all ES data was transferred
164+
# verify all ES data was transferred from live directory
152165
diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch" "$GHE_DATA_DIR/current/elasticsearch"
166+
elif [ "$GHE_VERSION_MAJOR" -ge 2 ]; then
167+
# verify all ES data was transferred from snapshot directory
168+
diff -ru "$GHE_REMOTE_DATA_USER_DIR/elasticsearch-snapshots" "$GHE_DATA_DIR/current/elasticsearch"
153169
fi
154170
)
155171
end_test

0 commit comments

Comments
 (0)