diff --git a/.github/workflows/e2e_all.yml b/.github/workflows/e2e_all.yml index cea16ed..435d17f 100644 --- a/.github/workflows/e2e_all.yml +++ b/.github/workflows/e2e_all.yml @@ -17,11 +17,12 @@ jobs: fail-fast: false matrix: version: - - 1.20.1 - - 1.19.3 + - 1.20.4 + - 1.19.4 - 1.18.2 - 1.17.1 - 1.16.5 + - 1.16.3 - 1.15.2 - 1.14.4 - 1.13.2 diff --git a/.github/workflows/e2e_notable.yml b/.github/workflows/e2e_notable.yml index 51138e9..c47d7be 100644 --- a/.github/workflows/e2e_notable.yml +++ b/.github/workflows/e2e_notable.yml @@ -20,7 +20,7 @@ jobs: fail-fast: false matrix: version: - - 1.20.1 + - 1.20.4 - 1.16.5 - 1.16.3 - 1.13.2 diff --git a/.gitignore b/.gitignore index b5eb768..835522d 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,7 @@ bin/ ### Mac OS ### .DS_Store + +### Python ### +/venv/ +/.venv/ diff --git a/.vscode/launch.json b/.vscode/launch.json index aea59bf..72bd411 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,19 +1,33 @@ { - "version": "0.2.0", - "configurations": [ - { - "type": "java", - "name": "debug proxy (in Docker)", - "request": "attach", - "hostName": "localhost", - "port": 9010, - }, - { - "type": "java", - "name": "debug server (in Docker)", - "request": "attach", - "hostName": "localhost", - "port": 9011, - } - ] + "version": "0.2.0", + "configurations": [ + { + "name": "run.py", + "type": "python", + "request": "launch", + "program": "run.py", + "args": [ + "velocity", + "1.20.1", + "test" + ], + "cwd": "${workspaceFolder}/tests_e2e/", + "console": "integratedTerminal", + "justMyCode": true + }, + { + "type": "java", + "name": "debug proxy (in Docker)", + "request": "attach", + "hostName": "localhost", + "port": 9010 + }, + { + "type": "java", + "name": "debug server (in Docker)", + "request": "attach", + "hostName": "localhost", + "port": 9011 + } + ] } diff --git a/tests_e2e/.gitignore b/tests_e2e/.gitignore index 2824e61..c103676 100644 --- a/tests_e2e/.gitignore +++ b/tests_e2e/.gitignore @@ -1,3 +1,6 @@ test_env/ #jar/ debug.log + +.venv +venv diff --git a/tests_e2e/README.md b/tests_e2e/README.md index c8353eb..23bf466 100644 --- a/tests_e2e/README.md +++ b/tests_e2e/README.md @@ -12,11 +12,9 @@ I wanted to verify if the plugin actually works on all Minecraft versions we cla ## How? -Thanks to [@itzg](https://github.com/itzg) who probably spent countless hours on [Docker image for hosting Minecraft server](https://github.com/itzg/docker-minecraft-server) it was easy. We just spin up a test server using Docker Compose and log into the game. The bot (which is built using [node-minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol)) only needs to join the server and listen to specific plugin channels. +Thanks to [@itzg](https://github.com/itzg), who probably spent countless hours on [Docker image for hosting Minecraft server](https://github.com/itzg/docker-minecraft-server), it was easy. We just spin up a test server using Docker Compose and log into the game. The bot (which is built using [node-minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol)) only needs to join the server and listen to specific plugin channels. -But automatic bot test is not _that_ useful. It doesn't behave like real Minecraft client. - -More importantly, now I can easily debug different combinations of Minecraft server versions and proxies. +Automatic bot test is not _that_ useful because it doesn't behave like real Minecraft client. Now I can easily debug different combinations of Minecraft server versions and proxies. ## Let me try @@ -35,6 +33,5 @@ Command: * `test` – perform automatic (E2E) tests * `manual` – spin up specified server and proxy * * Use env `JAVA_DEBUG=1` to enable Java debugging. Local port `9010` goes for the proxy, `9011` for the server. Example: `JAVA_DEBUG=1 ./run.sh waterfall 1.16.5 manual` -* `build` – build Docker images -* `cleanup` – calls `docker compose down` -* `convert` – calls `docker compose convert` +* * Use env `BLUE=1` to enable second server (e.g. to debug map persistence). You'll be able to switch between servers with `/server red/blue`. + diff --git a/tests_e2e/docker-compose.bungeecord.yml b/tests_e2e/docker-compose.bungeecord.yml deleted file mode 100644 index 68e4796..0000000 --- a/tests_e2e/docker-compose.bungeecord.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - proxy: - build: - args: - - TYPE_DIR=bungeecord - environment: - - TYPE=bungeecord diff --git a/tests_e2e/docker-compose.velocity.yml b/tests_e2e/docker-compose.velocity.yml deleted file mode 100644 index f1b702a..0000000 --- a/tests_e2e/docker-compose.velocity.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - proxy: - build: - args: - - TYPE_DIR=velocity - environment: - - TYPE=velocity diff --git a/tests_e2e/docker-compose.waterfall.yml b/tests_e2e/docker-compose.waterfall.yml deleted file mode 100644 index 7669151..0000000 --- a/tests_e2e/docker-compose.waterfall.yml +++ /dev/null @@ -1,7 +0,0 @@ -services: - proxy: - build: - args: - - TYPE_DIR=bungeecord - environment: - - TYPE=waterfall diff --git a/tests_e2e/docker-compose.yml b/tests_e2e/docker-compose.yml index af757dc..549512d 100644 --- a/tests_e2e/docker-compose.yml +++ b/tests_e2e/docker-compose.yml @@ -1,17 +1 @@ version: "3.8" -services: - bot: - build: - context: bot - environment: - - BOT_HOST=proxy - depends_on: - - proxy - server: - build: - context: server - proxy: - build: - context: proxy - depends_on: - - server diff --git a/tests_e2e/proxy/Dockerfile b/tests_e2e/proxy/Dockerfile index b72c299..4a1be93 100644 --- a/tests_e2e/proxy/Dockerfile +++ b/tests_e2e/proxy/Dockerfile @@ -2,6 +2,6 @@ FROM itzg/bungeecord ENV SERVER_PORT=25565 -ARG TYPE_DIR +ENV JVM_OPTS="-Dlog4j2.configurationFile=log4j2.xml" -COPY --chown=bungeecord:bungeecord ${TYPE_DIR}/files/ /server +COPY --chown=bungeecord:bungeecord . /server diff --git a/tests_e2e/proxy/bungeecord/files/config.yml b/tests_e2e/proxy/bungeecord/config.yml similarity index 60% rename from tests_e2e/proxy/bungeecord/files/config.yml rename to tests_e2e/proxy/bungeecord/config.yml index 9bb97d3..cde5c08 100644 --- a/tests_e2e/proxy/bungeecord/files/config.yml +++ b/tests_e2e/proxy/bungeecord/config.yml @@ -2,8 +2,5 @@ ip_forward: true online_mode: false listeners: - priorities: - - lobby + - red host: 0.0.0.0:25565 -servers: - lobby: - address: server:25565 diff --git a/tests_e2e/proxy/velocity/files/forwarding.secret b/tests_e2e/proxy/velocity/forwarding.secret similarity index 100% rename from tests_e2e/proxy/velocity/files/forwarding.secret rename to tests_e2e/proxy/velocity/forwarding.secret diff --git a/tests_e2e/proxy/velocity/log4j2.xml b/tests_e2e/proxy/velocity/log4j2.xml new file mode 100644 index 0000000..38d3fce --- /dev/null +++ b/tests_e2e/proxy/velocity/log4j2.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests_e2e/proxy/velocity/plugins/mapmodcompanion/config.toml b/tests_e2e/proxy/velocity/plugins/mapmodcompanion/config.toml index 710c34c..b0e4fc6 100644 --- a/tests_e2e/proxy/velocity/plugins/mapmodcompanion/config.toml +++ b/tests_e2e/proxy/velocity/plugins/mapmodcompanion/config.toml @@ -1,6 +1,3 @@ -[overrides] -1984 = 1337 - [world_id.modern] enabled = true diff --git a/tests_e2e/proxy/velocity/files/velocity.toml b/tests_e2e/proxy/velocity/velocity.toml similarity index 93% rename from tests_e2e/proxy/velocity/files/velocity.toml rename to tests_e2e/proxy/velocity/velocity.toml index 4efd530..051a46d 100644 --- a/tests_e2e/proxy/velocity/files/velocity.toml +++ b/tests_e2e/proxy/velocity/velocity.toml @@ -69,16 +69,6 @@ ping-passthrough = "DISABLED" # If not enabled (default is true) player IP addresses will be replaced by in logs enable-player-address-logging = true -[servers] -# Configure your servers here. Each key represents the server's name, and the value -# represents the IP address of the server to connect to. -main = "server:25565" - -# In what order we should try servers when a player logs in or is kicked from a server. -try = [ - "main" -] - [forced-hosts] [advanced] diff --git a/tests_e2e/proxy/waterfall b/tests_e2e/proxy/waterfall deleted file mode 120000 index d1c42c0..0000000 --- a/tests_e2e/proxy/waterfall +++ /dev/null @@ -1 +0,0 @@ -bungeecord \ No newline at end of file diff --git a/tests_e2e/requirements.txt b/tests_e2e/requirements.txt new file mode 100644 index 0000000..15468a3 --- /dev/null +++ b/tests_e2e/requirements.txt @@ -0,0 +1,7 @@ +certifi==2023.11.17 +charset-normalizer==3.3.2 +idna==3.6 +PyYAML==6.0.1 +requests==2.31.0 +toml==0.10.2 +urllib3==2.1.0 diff --git a/tests_e2e/run.py b/tests_e2e/run.py new file mode 100755 index 0000000..26e34a1 --- /dev/null +++ b/tests_e2e/run.py @@ -0,0 +1,473 @@ +#!/usr/bin/env python + +from logging import DEBUG, INFO, basicConfig, getLogger +from pathlib import Path +from signal import SIGINT +from sys import argv, stdout +from os import environ, makedirs, path +from subprocess import PIPE, STDOUT, run, Popen +from shutil import copytree, rmtree, copyfile +import requests +from yaml import load as yaml_load, dump as yaml_dump, Loader as YamlLoader, Dumper as YamlDumper +from toml import load as toml_load, dump as toml_dump + +logger = getLogger("tests_e2e") + +PARENT_DIR = Path(path.realpath(__file__)).parent + +SERVER_OVERRIDES = { + 'red': 42, + 'blue': 2000, +} + +PROXY_OVERRIDES = { + '42': 1337, + '2000': 3000, +} + +JAVA_DEBUG = { + 'proxy': 9010, + 'red': 9011, + 'blue': 9012, +} + +VERSIONS = { + '1.8.9': { + 'server': '1.8.8', + 'java': 8, + 'world': '1.8.9', + }, + **( + dict(( + version, + { + 'java': 8, + 'world': '1.8.9', + }, + ) for version in ( + '1.9.4', + '1.10.2', + '1.11.2', + '1.12.2', + )) + ), + **( + dict(( + version, + { + 'java': 8, + 'protocollib': True, + 'world': '1.13.2', + }, + ) for version in ( + '1.13.2', + '1.14.4', + '1.15.2', + '1.16.1', + '1.16.2', + '1.16.3', + )) + ), + **( + dict(( + version, + { + 'java': 8, + 'world': '1.13.2', + }, + ) for version in ( + '1.16.4', + '1.16.5', + )) + ), + **( + dict((version, {}) for version in ( + '1.17.1', + '1.18.2', + '1.19.3', + '1.19.4', + '1.20.1', + '1.20.2', + '1.20.3', + '1.20.4', + )) + ), + **( + dict(( + version, + { + 'bot': False, + }, + ) for version in ( + )) + ), +} + + +def gradle_build(): + logger.debug("Running gradle build") + run( + ['./gradlew', 'build'], + check=True, + cwd=str(PARENT_DIR.parent), + ) + + +def docker(l: list[str], **kwargs): + logger.debug(f"Running docker with: {l}") + p = Popen( + ['docker', *l], + cwd=str(PARENT_DIR), + **kwargs, + ) + p._sigint_wait_secs = 60.0 + return p + + +def copy_clean(_from: Path, _to: Path): + logger.debug(f"Copying {_from} -> {_to}") + if _to.is_dir(): + rmtree(_to) + copytree(_from, _to, symlinks=True) + + +def files_dir_of(entity: str): + return test_env_dir / f"{entity}" + + +def copy_plugin(into: Path): + copyfile( + PARENT_DIR.parent / "packages" / "single" / + "build" / "libs" / "MapModCompanion.jar", + into / "MapModCompanion.jar", + ) + + +def copy_server_files(): + logger.debug("Copying server files") + for server_name in servers: + _to = files_dir_of(server_name) + copy_clean( + PARENT_DIR / "server", + _to, + ) + copy_plugin(_to / "plugins") + mmc_config_path = _to / "plugins" / "MapModCompanion" / "config.yml" + with open(mmc_config_path, "r") as f: + config = yaml_load(f, Loader=YamlLoader) + config["overrides"] = { + 'world': SERVER_OVERRIDES[server_name], + } + logger.debug(f"Writing config {mmc_config_path}: {config}") + with open(mmc_config_path, "w") as f: + yaml_dump(config, f, Dumper=YamlDumper) + + +def copy_proxy_files(): + logger.debug("Copying proxy files") + if proxy_type == "waterfall": + _proxy_dir = "bungeecord" + else: + _proxy_dir = proxy_type + _from = PARENT_DIR / "proxy" / _proxy_dir + _to = files_dir_of("proxy") + copy_clean( + _from, + _to, + ) + if proxy_type == "velocity": + mmc_config_path = _to / "plugins" / "mapmodcompanion" / "config.toml" + config = toml_load(mmc_config_path) + def save(data): + with open(mmc_config_path, "w") as f: + toml_dump(data, f) + else: + mmc_config_path = _to / "plugins" / "MapModCompanion" / "config.yml" + with open(mmc_config_path, "r") as f: + config = yaml_load(f, Loader=YamlLoader) + def save(data): + with open(mmc_config_path, "w") as f: + yaml_dump(data, f, Dumper=YamlDumper) + config["overrides"] = PROXY_OVERRIDES + logger.debug(f"Writing config {mmc_config_path}: {config}") + save(config) + copy_plugin(_to / "plugins") + copyfile( + PARENT_DIR / "proxy" / "Dockerfile", + _to / "Dockerfile", + ) + + +if __name__ == "__main__": + servers = [ + 'red', + 'blue', + ] + + debug_level = int(environ.get("DEBUG")) if environ.get("DEBUG") else 0 + debug = debug_level or environ.get("ACTIONS_STEP_DEBUG") == "true" + basicConfig( + level=DEBUG if debug else INFO + ) + + enable_blue = environ.get("BLUE") == "1" + if not enable_blue: + servers.remove('blue') + + java_debug = debug_level or environ.get("JAVA_DEBUG") + if java_debug: + logger.info("Java debugging enabled.") + logger.info("Use 127.0.0.1:9010 for proxy") + logger.info("Use 127.0.0.1:9011 for red server") + if enable_blue: + logger.info("Use 127.0.0.1:9011 for blue server") + + proxy_type, client_version, action = argv[1:] + + version_info = VERSIONS[client_version] + + test_name = f"mmc_test_{proxy_type}_{client_version}" + test_env_dir = PARENT_DIR / "test_env" / test_name + makedirs(test_env_dir, exist_ok=True) + + if debug_level: + gradle_build() + + copy_server_files() + copy_proxy_files() + + docker_compose_file_contents = { + 'services': { + } + } + + if "bot" not in version_info or version_info["bot"] == True: + bot_container = test_name + bot_desc = { + 'container_name': test_name, + 'build': { + 'context': str(PARENT_DIR / "bot"), + 'args': [ + 'DEBUG=minecraft-protocol' + ] if debug_level > 1 else [ + ] + }, + 'environment': [ + 'BOT_HOST=proxy', + f'BOT_VERSION={client_version}', + ], + 'depends_on': [ + 'proxy' + ], + } + docker_compose_file_contents["services"]["bot"] = bot_desc + else: + logger.warning(f"Bot doesn't support {client_version}") + bot_container = None + assert action not in ("test",) + + if "java" in version_info: + server_java_version = version_info["java"] + else: + server_java_version = 17 + + if "server" in version_info: + server_version = version_info["server"] + else: + server_version = client_version + + if "world" in version_info: + world_version = version_info["world"] + else: + world_version = "1.17.1" + + for server_name in servers: + server_desc = { + 'build': { + 'context': server_name, + 'args': [ + f'TAG=java{server_java_version}' + ], + 'tags': [ + f'mmc-e2e-server-{server_name}:java{server_java_version}' + ], + }, + 'environment': [ + f'VERSION={server_version}' + ], + 'ports': [ + ] + } + if java_debug: + server_desc["ports"] += [ + f'{JAVA_DEBUG[server_name]}:9001' + ] + server_desc["environment"] += [ + 'JVM_XX_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=' + + '*:9001' if server_java_version > 8 else '9001' + ] + docker_compose_file_contents["services"][server_name] = server_desc + if "protocollib" in version_info and version_info["protocollib"] == True: + protocollib_source_file = test_env_dir / "ProtocolLib.jar" + if not protocollib_source_file.is_file(): + logger.info("Downloading ProtocolLib") + data = requests.get("https://github.com/dmulloy2/ProtocolLib/releases/download/4.8.0/ProtocolLib.jar").content + try: + with open(protocollib_source_file, "wb") as f: + f.write(data) + except Exception as e: + protocollib_source_file.unlink(missing_ok=True) + raise e + logger.info("Copying ProtocolLib") + copyfile( + protocollib_source_file, + files_dir_of(server_name) / "plugins" / "ProtocolLib.jar", + ) + world_dir = files_dir_of(server_name) / "world" + makedirs(world_dir, exist_ok=True) + copyfile( + PARENT_DIR / "saves" / world_version / f"{server_name}.dat", + world_dir / "level.dat" + ) + + proxy_desc = { + 'build': { + 'context': 'proxy', + }, + 'depends_on': [ + *servers, + ], + 'environment': [ + f'TYPE={proxy_type}', + ], + 'ports': [ + ], + } + if debug_level: + proxy_desc["ports"] += [ + '25565:25565', + ] + if java_debug: + proxy_desc["ports"] += [ + f'{JAVA_DEBUG["proxy"]}:9001' + ] + proxy_desc["environment"] += [ + 'JVM_XX_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:9001' + ] + + if proxy_type in ("waterfall", "bungeecord"): + bungee_config_path = test_env_dir / "proxy" / "config.yml" + with open(bungee_config_path, "r") as f: + bungee_config = yaml_load(f, Loader=YamlLoader) + bungee_config["servers"] = dict( + (server_name, { + 'address': f'{server_name}:25565' + }) for server_name in servers + ) + with open(bungee_config_path, "w") as f: + yaml_dump(bungee_config, f, Dumper=YamlDumper) + + if proxy_type in ("velocity"): + velocity_config_path = test_env_dir / "proxy" / "velocity.toml" + velocity_config = toml_load(velocity_config_path) + velocity_config["servers"] = { + **dict( + ( + server_name, + f"{server_name}:25565" + ) for server_name in servers + ), + "try": [ + "red", + ], + } + with open(velocity_config_path, "w") as f: + toml_dump(velocity_config, f) + + docker_compose_file_contents["services"]["proxy"] = proxy_desc + + docker_compose_path = test_env_dir / "docker-compose.yml" + + logger.debug( + f"Writing {docker_compose_path}: {docker_compose_file_contents}") + with open(docker_compose_path, "w") as f: + yaml_dump(docker_compose_file_contents, f, Dumper=YamlDumper) + + auto = bot_container and action in ("test") + + compose = [ + 'compose', + '-f', + str(docker_compose_path), + ] + + if action == "build": + exit_code = docker([ + *compose, + 'build', + '--no-cache', + ]).wait() + exit(exit_code) + + docker_proc = docker([ + *compose, + 'up', + '--force-recreate', + '--build', + *(['-V'] if debug_level else []), + *(['--detach'] if auto else []), + ]) + + while True: + try: + exit_code = docker_proc.wait() + break + except KeyboardInterrupt: + docker_proc.send_signal(SIGINT) + exit(1) + + if auto: + logger.info(f"Waiting for {bot_container}") + docker_logs = docker( + [ + *compose, + 'logs', + *([ + '-f', + ] if debug else [ + '-f', + 'bot', + ]) + ], + stdout=PIPE, + stderr=STDOUT, + ) + docker_wait = docker( + [ + 'wait', + bot_container, + ], + stdout=PIPE, + stderr=STDOUT, + text=True + ) + + try: + while docker_wait.poll() is None: + ch = docker_logs.stdout.read(1) + if ch: + stdout.buffer.write(ch) + stdout.flush() + except KeyboardInterrupt: + docker_logs.kill() + + docker([ + *compose, + 'down', + ]).wait() + + if docker_wait.returncode != 0 or int(docker_wait.stdout.read()) != 0: + logger.error("Failed") + exit(1) + + logger.info("OK") diff --git a/tests_e2e/run.sh b/tests_e2e/run.sh index 1999068..bbb94a1 100755 --- a/tests_e2e/run.sh +++ b/tests_e2e/run.sh @@ -1,219 +1,7 @@ #!/bin/bash set -euo pipefail -IFS=$'\n\t' -SELF=$(SELF=$(dirname "$0") && bash -c "cd \"$SELF\" && pwd") - -PROXY_TYPE="$1" -VERSION="$2" -ACTION="$3" - -JAR="$SELF/../packages/single/build/libs/MapModCompanion.jar" -NAME="mmc_test_"$PROXY_TYPE"_"$VERSION -TEST_CONTAINER_NAME="$NAME" -TEST_ENV="$SELF/test_env/$NAME" -PLUGINS_SERVER="$TEST_ENV/plugins_server" -PLUGINS_PROXY="$TEST_ENV/plugins_proxy" -VERSION_INFO_FILE_NAME="docker-compose.version_info.yml" -VERSION_INFO_FILE="$TEST_ENV/$VERSION_INFO_FILE_NAME" -VERSION_INFO_SOURCE="$SELF/versions/$VERSION.sh" -OVERRIDE_FILE_NAME="docker-compose.override.yml" -OVERRIDE_FILE="$TEST_ENV/$OVERRIDE_FILE_NAME" - -set +u -if [[ -z $DEBUG ]]; then - DEBUG="" - if [[ $ACTIONS_STEP_DEBUG == "true" ]]; then - DEBUG=1 - fi -fi -if [[ $DEBUG ]] || [[ $GRADLE_REBUILD ]]; then - (cd .. && ./gradlew build) -fi -set -u - -function debug_echo { - if [[ $DEBUG ]]; then - echo $@ - fi -} - -debug_echo "Reading $VERSION_INFO_SOURCE" -source "$VERSION_INFO_SOURCE" - -debug_echo "Working in: $TEST_ENV" -rm -rf "$TEST_ENV" -mkdir -p "$TEST_ENV" - -debug_echo "Populating server plugins directory" -rm -rf "$PLUGINS_SERVER" -mkdir "$PLUGINS_SERVER" -cp -r "$JAR" "$PLUGINS_SERVER/" -cp -r "$SELF/server/plugins/"* "$PLUGINS_SERVER/" - -debug_echo "Populating proxy plugins directory" -rm -rf "$PLUGINS_PROXY" -mkdir -p "$PLUGINS_PROXY" -cp -r "$JAR" "$PLUGINS_PROXY/" -cp -r "$SELF/proxy/$PROXY_TYPE/plugins/"* "$PLUGINS_PROXY/" - -debug_echo "Writing $VERSION_INFO_FILE_NAME" - -cat << EOF > "$VERSION_INFO_FILE" -services: - bot: - environment: - - BOT_VERSION=$CLIENT_VERSION - server: - build: - args: - - TAG=java$JAVA_VERSION - tags: - - "mmc-e2e-server:java$JAVA_VERSION" - environment: - - VERSION=$SERVER_VERSION - -EOF - -debug_echo "Writing $OVERRIDE_FILE_NAME" - -proxy_extra="" -server_extra="" - -if [[ "$ACTION" == "manual" ]]; then - proxy_extra=$(cat <<-EOF - ports: - - 25565:25565 -EOF -) - set +u - if [[ "$JAVA_DEBUG" ]]; then - echo "[NOTE] Java debugging enabled. Use 127.0.0.1:9010 for proxy, 127.0.0.1:9011 for server" - proxy_extra+=$(cat <<-EOF - - - 9010:9001 - environment: - - JVM_XX_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:9001 -EOF -) - server_extra=$(cat <<-EOF - ports: - - 9011:9001 - environment: - - JVM_XX_OPTS=-Ddisable.watchdog=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$([[ "$JAVA_VERSION" -lt 9 ]] && echo "9001" || echo "*:9001") -EOF -) - fi - set -u -fi - -cat << EOF > "$OVERRIDE_FILE" -services: - bot: - container_name: "$TEST_CONTAINER_NAME" - build: - args: - - DEBUG=$([[ "$DEBUG" -gt 1 ]] && echo "minecraft-protocol" || echo "") - proxy: - volumes: - - $TEST_ENV/plugins_proxy:/server/plugins -$proxy_extra - server: - volumes: - - $TEST_ENV/plugins_server:/data/plugins -$server_extra -EOF - -FILES=( - "$SELF/docker-compose.yml" - "$SELF/docker-compose.$PROXY_TYPE.yml" - "$VERSION_INFO_FILE" - "$OVERRIDE_FILE" -) - -FILES_FMT=`printf ' -f %s' "${FILES[@]}"` - -function docker_compose { - bash -c "docker compose$FILES_FMT $@" -} - -function docker_compose_down() { - docker_compose down --rmi local -} - -function perform_test { - debug_echo "Stopping old containers" - docker_compose_down >/dev/null - - local auto=1 - if [[ "$1" == "manual" || "$1" == "debug" ]]; then - local auto="" - fi - - set +u - if [[ "$PROTOCOLLIB_VERSION" ]]; then - set -u - local protocollib_path="$PLUGINS_SERVER/ProtocolLib.jar" - debug_echo "Will use ProtocolLib: $protocollib_path" - if [[ ! -f "$protocollib_path" ]]; then - wget "https://github.com/dmulloy2/ProtocolLib/releases/download/$PROTOCOLLIB_VERSION/ProtocolLib.jar" -O "$protocollib_path" - fi - fi - set -u - - debug_echo "Starting container" - docker_compose "up --force-recreate --build $([[ "$auto" ]] && echo "--detach" || echo "")" - - if [[ "$auto" ]]; then - trap docker_compose_down SIGINT - - if [[ $DEBUG ]]; then - docker compose logs -f & - else - docker compose logs -f bot & - fi - - debug_echo "Waiting for bot container to exit: $TEST_CONTAINER_NAME" - TEST_EXIT=`docker wait "$TEST_CONTAINER_NAME"` - debug_echo "Done: $TEST_EXIT" - - docker_compose_down >/dev/null 2>/dev/null - - if [[ "$TEST_EXIT" != "0" ]]; then - echo "⚠️ Test failed" >&2 - exit 1 - fi - fi -} - -case $ACTION in - convert) - echo "[ACTION] Convert" - docker_compose convert - ;; - - build) - echo "[ACTION] Building" - docker_compose build - ;; - - test) - echo "[ACTION] Performing automatic test; version: $VERSION, proxy: $PROXY_TYPE" - perform_test "auto" - ;; - - manual) - echo "[ACTION] Spinning up the server for manual test; version: $VERSION, proxy: $PROXY_TYPE" - perform_test "manual" - ;; - - cleanup) - echo "[ACTION] Cleaning up" - docker_compose "down --remove-orphans --rmi all -v" - ;; - - *) - echo "Unknown action" - exit 1 - ;; -esac +python3 -m venv venv +source venv/bin/activate +pip install -r requirements.txt +python run.py "$@" diff --git a/tests_e2e/saves/1.13.2/blue.dat b/tests_e2e/saves/1.13.2/blue.dat new file mode 100644 index 0000000..975e3a4 Binary files /dev/null and b/tests_e2e/saves/1.13.2/blue.dat differ diff --git a/tests_e2e/saves/1.13.2/red.dat b/tests_e2e/saves/1.13.2/red.dat new file mode 100644 index 0000000..59bd8a6 Binary files /dev/null and b/tests_e2e/saves/1.13.2/red.dat differ diff --git a/tests_e2e/saves/1.17.1/blue.dat b/tests_e2e/saves/1.17.1/blue.dat new file mode 100644 index 0000000..ce9a970 Binary files /dev/null and b/tests_e2e/saves/1.17.1/blue.dat differ diff --git a/tests_e2e/saves/1.17.1/red.dat b/tests_e2e/saves/1.17.1/red.dat new file mode 100644 index 0000000..95b10b9 Binary files /dev/null and b/tests_e2e/saves/1.17.1/red.dat differ diff --git a/tests_e2e/saves/1.8.9/blue.dat b/tests_e2e/saves/1.8.9/blue.dat new file mode 100644 index 0000000..adc16e8 Binary files /dev/null and b/tests_e2e/saves/1.8.9/blue.dat differ diff --git a/tests_e2e/saves/1.8.9/red.dat b/tests_e2e/saves/1.8.9/red.dat new file mode 100644 index 0000000..a07abdb Binary files /dev/null and b/tests_e2e/saves/1.8.9/red.dat differ diff --git a/tests_e2e/server/Dockerfile b/tests_e2e/server/Dockerfile index 3587b91..b62a66b 100644 --- a/tests_e2e/server/Dockerfile +++ b/tests_e2e/server/Dockerfile @@ -4,5 +4,5 @@ FROM itzg/minecraft-server:${TAG} ENV EULA=true TYPE=paper -COPY --chown=minecraft:minecraft files/ /data +COPY --chown=minecraft:minecraft . /data diff --git a/tests_e2e/server/files/log4j2.xml b/tests_e2e/server/log4j2.xml similarity index 100% rename from tests_e2e/server/files/log4j2.xml rename to tests_e2e/server/log4j2.xml diff --git a/tests_e2e/server/plugins/MapModCompanion/config.yml b/tests_e2e/server/plugins/MapModCompanion/config.yml index b61e2ad..3a33827 100644 --- a/tests_e2e/server/plugins/MapModCompanion/config.yml +++ b/tests_e2e/server/plugins/MapModCompanion/config.yml @@ -1,8 +1,5 @@ verbose: true -overrides: - world: 1984 - world_id: modern: enabled: true diff --git a/tests_e2e/server/files/server.properties b/tests_e2e/server/server.properties similarity index 100% rename from tests_e2e/server/files/server.properties rename to tests_e2e/server/server.properties diff --git a/tests_e2e/server/files/spigot.yml b/tests_e2e/server/spigot.yml similarity index 100% rename from tests_e2e/server/files/spigot.yml rename to tests_e2e/server/spigot.yml diff --git a/tests_e2e/versions/1.10.2.sh b/tests_e2e/versions/1.10.2.sh deleted file mode 100644 index f842556..0000000 --- a/tests_e2e/versions/1.10.2.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.10.2 - -source "$SELF/versions/_legacy.sh" diff --git a/tests_e2e/versions/1.11.2.sh b/tests_e2e/versions/1.11.2.sh deleted file mode 100644 index 46a8398..0000000 --- a/tests_e2e/versions/1.11.2.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.11.2 - -source "$SELF/versions/_legacy.sh" diff --git a/tests_e2e/versions/1.12.2.sh b/tests_e2e/versions/1.12.2.sh deleted file mode 100644 index 36d2c6a..0000000 --- a/tests_e2e/versions/1.12.2.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.12.2 - -source "$SELF/versions/_legacy.sh" diff --git a/tests_e2e/versions/1.13.2.sh b/tests_e2e/versions/1.13.2.sh deleted file mode 100644 index b6b97cf..0000000 --- a/tests_e2e/versions/1.13.2.sh +++ /dev/null @@ -1,4 +0,0 @@ -CLIENT_VERSION=1.13.2 - -source "$SELF/versions/_legacy.sh" -source "$SELF/versions/_needs_protocollib.sh" diff --git a/tests_e2e/versions/1.14.4.sh b/tests_e2e/versions/1.14.4.sh deleted file mode 100644 index bd558c3..0000000 --- a/tests_e2e/versions/1.14.4.sh +++ /dev/null @@ -1,4 +0,0 @@ -CLIENT_VERSION=1.14.4 - -source "$SELF/versions/_legacy.sh" -source "$SELF/versions/_needs_protocollib.sh" diff --git a/tests_e2e/versions/1.15.2.sh b/tests_e2e/versions/1.15.2.sh deleted file mode 100644 index 80e8de4..0000000 --- a/tests_e2e/versions/1.15.2.sh +++ /dev/null @@ -1,4 +0,0 @@ -CLIENT_VERSION=1.15.2 - -source "$SELF/versions/_legacy.sh" -source "$SELF/versions/_needs_protocollib.sh" diff --git a/tests_e2e/versions/1.16.1.sh b/tests_e2e/versions/1.16.1.sh deleted file mode 100644 index 6f7871f..0000000 --- a/tests_e2e/versions/1.16.1.sh +++ /dev/null @@ -1,4 +0,0 @@ -CLIENT_VERSION=1.16.1 - -source "$SELF/versions/_legacy.sh" -source "$SELF/versions/_needs_protocollib.sh" diff --git a/tests_e2e/versions/1.16.2.sh b/tests_e2e/versions/1.16.2.sh deleted file mode 100644 index 16836eb..0000000 --- a/tests_e2e/versions/1.16.2.sh +++ /dev/null @@ -1,4 +0,0 @@ -CLIENT_VERSION=1.16.2 - -source "$SELF/versions/_legacy.sh" -source "$SELF/versions/_needs_protocollib.sh" diff --git a/tests_e2e/versions/1.16.3.sh b/tests_e2e/versions/1.16.3.sh deleted file mode 100644 index 0ed5df4..0000000 --- a/tests_e2e/versions/1.16.3.sh +++ /dev/null @@ -1,4 +0,0 @@ -CLIENT_VERSION=1.16.3 - -source "$SELF/versions/_legacy.sh" -source "$SELF/versions/_needs_protocollib.sh" diff --git a/tests_e2e/versions/1.16.4.sh b/tests_e2e/versions/1.16.4.sh deleted file mode 100644 index 05a5b4a..0000000 --- a/tests_e2e/versions/1.16.4.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.16.4 - -source "$SELF/versions/_legacy.sh" diff --git a/tests_e2e/versions/1.16.5.sh b/tests_e2e/versions/1.16.5.sh deleted file mode 100644 index c6c5b23..0000000 --- a/tests_e2e/versions/1.16.5.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.16.5 - -source "$SELF/versions/_legacy.sh" diff --git a/tests_e2e/versions/1.17.1.sh b/tests_e2e/versions/1.17.1.sh deleted file mode 100644 index 9b98f3b..0000000 --- a/tests_e2e/versions/1.17.1.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.17.1 - -source "$SELF/versions/_modern.sh" diff --git a/tests_e2e/versions/1.18.2.sh b/tests_e2e/versions/1.18.2.sh deleted file mode 100644 index 41f9b9d..0000000 --- a/tests_e2e/versions/1.18.2.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.18.2 - -source "$SELF/versions/_modern.sh" diff --git a/tests_e2e/versions/1.19.3.sh b/tests_e2e/versions/1.19.3.sh deleted file mode 100644 index f497121..0000000 --- a/tests_e2e/versions/1.19.3.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.19.3 - -source "$SELF/versions/_modern.sh" diff --git a/tests_e2e/versions/1.20.1.sh b/tests_e2e/versions/1.20.1.sh deleted file mode 100644 index 18e8ee7..0000000 --- a/tests_e2e/versions/1.20.1.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.20.1 - -source "$SELF/versions/_modern.sh" diff --git a/tests_e2e/versions/1.8.9.sh b/tests_e2e/versions/1.8.9.sh deleted file mode 100644 index ae01d28..0000000 --- a/tests_e2e/versions/1.8.9.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.8.9 -SERVER_VERSION=1.8.8 -JAVA_VERSION=8 diff --git a/tests_e2e/versions/1.9.4.sh b/tests_e2e/versions/1.9.4.sh deleted file mode 100644 index a71b2a7..0000000 --- a/tests_e2e/versions/1.9.4.sh +++ /dev/null @@ -1,3 +0,0 @@ -CLIENT_VERSION=1.9.4 - -source "$SELF/versions/_legacy.sh" diff --git a/tests_e2e/versions/_legacy.sh b/tests_e2e/versions/_legacy.sh deleted file mode 100644 index 14d3784..0000000 --- a/tests_e2e/versions/_legacy.sh +++ /dev/null @@ -1,3 +0,0 @@ -JAVA_VERSION=8 - -source "$SELF/versions/_same.sh" diff --git a/tests_e2e/versions/_modern.sh b/tests_e2e/versions/_modern.sh deleted file mode 100644 index c6ea0a1..0000000 --- a/tests_e2e/versions/_modern.sh +++ /dev/null @@ -1,3 +0,0 @@ -JAVA_VERSION=17 - -source "$SELF/versions/_same.sh" diff --git a/tests_e2e/versions/_needs_protocollib.sh b/tests_e2e/versions/_needs_protocollib.sh deleted file mode 100644 index 3fc26a3..0000000 --- a/tests_e2e/versions/_needs_protocollib.sh +++ /dev/null @@ -1 +0,0 @@ -PROTOCOLLIB_VERSION="4.8.0" diff --git a/tests_e2e/versions/_same.sh b/tests_e2e/versions/_same.sh deleted file mode 100644 index 2e10712..0000000 --- a/tests_e2e/versions/_same.sh +++ /dev/null @@ -1 +0,0 @@ -SERVER_VERSION="$CLIENT_VERSION"