Skip to content

Commit

Permalink
Better E2E tests with the secondary server (#63)
Browse files Browse the repository at this point in the history
* Better E2E tests with the secondary server

* Support 1.20.4 tests
  • Loading branch information
turikhay authored Jan 10, 2024
1 parent b24ba8a commit da2b389
Show file tree
Hide file tree
Showing 52 changed files with 584 additions and 369 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/e2e_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e_notable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ bin/

### Mac OS ###
.DS_Store

### Python ###
/venv/
/.venv/
48 changes: 31 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
3 changes: 3 additions & 0 deletions tests_e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
test_env/
#jar/
debug.log

.venv
venv
11 changes: 4 additions & 7 deletions tests_e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`.

7 changes: 0 additions & 7 deletions tests_e2e/docker-compose.bungeecord.yml

This file was deleted.

7 changes: 0 additions & 7 deletions tests_e2e/docker-compose.velocity.yml

This file was deleted.

7 changes: 0 additions & 7 deletions tests_e2e/docker-compose.waterfall.yml

This file was deleted.

16 changes: 0 additions & 16 deletions tests_e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tests_e2e/proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
File renamed without changes.
50 changes: 50 additions & 0 deletions tests_e2e/proxy/velocity/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2018 Velocity Contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<!-- Disable shutdown hook, because we have our own -->
<Configuration status="warn" shutdownHook="disable">
<Appenders>
<TerminalConsole name="TerminalConsole">
<PatternLayout>
<LoggerNamePatternSelector
defaultPattern="%highlightError{[%d{HH:mm:ss} %level] [%logger]: %minecraftFormatting{%msg}%n%xEx}">
<!-- Velocity doesn't need a prefix -->
<PatternMatch key="com.velocitypowered."
pattern="%highlightError{[%d{HH:mm:ss} %level]: %minecraftFormatting{%msg}%n%xEx}"/>
</LoggerNamePatternSelector>
</PatternLayout>
</TerminalConsole>
<RollingRandomAccessFile name="File" fileName="logs/latest.log"
filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz"
immediateFlush="false">
<PatternLayout
pattern="[%d{HH:mm:ss}] [%t/%level] [%logger]: %minecraftFormatting{%msg}{strip}%n"/>
<Policies>
<TimeBasedTriggeringPolicy/>
<OnStartupTriggeringPolicy/>
</Policies>
</RollingRandomAccessFile>
</Appenders>

<Loggers>
<Root level="debug">
<AppenderRef ref="TerminalConsole"/>
<AppenderRef ref="File"/>
</Root>
</Loggers>
</Configuration>
3 changes: 0 additions & 3 deletions tests_e2e/proxy/velocity/plugins/mapmodcompanion/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[overrides]
1984 = 1337

[world_id.modern]
enabled = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,6 @@ ping-passthrough = "DISABLED"
# If not enabled (default is true) player IP addresses will be replaced by <ip address withheld> 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]
Expand Down
1 change: 0 additions & 1 deletion tests_e2e/proxy/waterfall

This file was deleted.

7 changes: 7 additions & 0 deletions tests_e2e/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit da2b389

Please sign in to comment.