Merge "Improve documentation for Search Operators by adding examples" into stable-3.5
diff --git a/test/docker/gerrit/Dockerfile b/test/docker/gerrit/Dockerfile
index dd42d7f..b826394 100755
--- a/test/docker/gerrit/Dockerfile
+++ b/test/docker/gerrit/Dockerfile
@@ -1,13 +1,17 @@
 FROM gerritcodereview/gerrit:3.5.0.1-ubuntu20
 
 ENV GERRIT_SITE /var/gerrit
-COPY artifacts/plugins/ $GERRIT_SITE/plugins/
+RUN rm -rf "$GERRIT_SITE/plugins" && mkdir "$GERRIT_SITE/plugins"
+RUN git config -f "$GERRIT_SITE/etc/gerrit.config" auth.type \
+    DEVELOPMENT_BECOME_ANY_ACCOUNT
+RUN git config -f "$GERRIT_SITE/etc/gerrit.config" \
+    sendemail.enable "false"
+RUN git config -f "$GERRIT_SITE/etc/gerrit.config" \
+    "operator-alias.change.independson" "in_depends-on"
+RUN git config -f "$GERRIT_SITE/etc/gerrit.config" \
+    "operator-alias.change.hasdependson" "has_depends-on"
 
-USER root
-
-COPY artifacts/bin/ /tmp/
-COPY start.sh /
-RUN { [ -e /tmp/gerrit.war ] && cp /tmp/gerrit.war "$GERRIT_SITE/bin/gerrit.war" ; } || true
-
-USER gerrit
-ENTRYPOINT /start.sh
+COPY artifacts /tmp/
+RUN cp /tmp/plugins/* "$GERRIT_SITE/plugins/"
+RUN { [ -e /tmp/bin/gerrit.war ] && cp /tmp/bin/gerrit.war "$GERRIT_SITE/bin/gerrit.war" ; } || true
+RUN chmod 777 "$GERRIT_SITE/git"
diff --git a/test/docker/gerrit/start.sh b/test/docker/gerrit/start.sh
deleted file mode 100755
index cf48b39..0000000
--- a/test/docker/gerrit/start.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-
-git config -f "$GERRIT_SITE/etc/gerrit.config" \
-    operator-alias.change.independson "in_depends-on"
-git config -f "$GERRIT_SITE/etc/gerrit.config" \
-    operator-alias.change.hasdependson "has_depends-on"
-git config -f "$GERRIT_SITE/etc/gerrit.config" \
-    sendemail.enable "false"
-
-echo "Initializing Gerrit site ..."
-java -jar "$GERRIT_SITE/bin/gerrit.war" init -d "$GERRIT_SITE" --batch
-
-echo "Running Gerrit ..."
-exec "$GERRIT_SITE"/bin/gerrit.sh run
diff --git a/test/docker/run.sh b/test/docker/run.sh
index 517baf3..8930623 100755
--- a/test/docker/run.sh
+++ b/test/docker/run.sh
@@ -59,7 +59,7 @@
 
 run_depends_on_plugin_tests() {
     docker-compose "${COMPOSE_ARGS[@]}" up --detach
-    docker-compose "${COMPOSE_ARGS[@]}" exec -T --user=gerrit_admin run_tests \
+    docker-compose "${COMPOSE_ARGS[@]}" exec -T --user=admin run_tests \
         '/depends_on/test/docker/run_tests/start.sh'
 }
 
diff --git a/test/docker/run_tests/Dockerfile b/test/docker/run_tests/Dockerfile
index 1ecd6b3..969fbb3 100755
--- a/test/docker/run_tests/Dockerfile
+++ b/test/docker/run_tests/Dockerfile
@@ -2,7 +2,7 @@
 
 ARG UID=1000
 ARG GID=1000
-ENV USER gerrit_admin
+ENV USER admin
 ENV USER_HOME /home/$USER
 ENV WORKSPACE $USER_HOME/workspace
 
@@ -19,6 +19,6 @@
 RUN ssh-keygen -P '' -f "$USER_HOME"/.ssh/id_rsa
 RUN chmod 400 "$USER_HOME"/.ssh/id_rsa
 RUN git config --global user.name "Gerrit Admin"
-RUN git config --global user.email "gerrit_admin@example.com"
+RUN git config --global user.email "admin@example.com"
 
 ENTRYPOINT ["tail", "-f", "/dev/null"]
diff --git a/test/docker/run_tests/start.sh b/test/docker/run_tests/start.sh
index fdc3f32..947d534 100755
--- a/test/docker/run_tests/start.sh
+++ b/test/docker/run_tests/start.sh
@@ -5,13 +5,10 @@
 
 setup_test_project() {
     echo "Creating a test project ..."
-    ssh -p "$PORT" -x "$GERRIT_HOST" gerrit create-project "${TEST_PROJECT}".git \
-        --owner "Administrators" --submit-type "MERGE_IF_NECESSARY"
+    ssh -p "$PORT" -x "$GERRIT_HOST" gerrit create-project "${TEST_PROJECT}" \
+        --owner "Administrators" --submit-type "MERGE_IF_NECESSARY" \
+        --empty-commit
     git clone ssh://"$GERRIT_HOST":"$PORT"/"$TEST_PROJECT" "$WORKSPACE"
-    pushd "$WORKSPACE" > /dev/null
-    git commit -m "Initial commit" --allow-empty
-    git push ssh://"$GERRIT_HOST":"$PORT"/"$TEST_PROJECT" HEAD:refs/heads/master
-    popd > /dev/null
 }
 
 cp -r /depends_on "$USER_HOME"/
@@ -20,11 +17,11 @@
 ./docker/run_tests/wait-for-it.sh "$GERRIT_HOST":"$PORT" \
     -t 60 -- echo "Gerrit is up"
 
-echo "Creating a default user account ..."
+echo "Update admin account ..."
 
 cat "$USER_HOME"/.ssh/id_rsa.pub | ssh -p 29418 -i /server-ssh-key/ssh_host_rsa_key \
-  "Gerrit Code Review@$GERRIT_HOST" suexec --as "admin@example.com" -- gerrit create-account \
-     --ssh-key - --email "gerrit_admin@localdomain"  --group "Administrators" "gerrit_admin"
+    "Gerrit Code Review@$GERRIT_HOST" suexec --as "admin@example.com" -- \
+    gerrit set-account "$USER" --add-ssh-key -
 
 setup_test_project