gamedig / rust-gamedig

Game Server Query Library.
https://crates.io/crates/gamedig
MIT License
38 stars 11 forks source link

Integration Tests #66

Open cainthebest opened 1 year ago

cainthebest commented 1 year ago

I've been going through the test suite and noticed that it primarily consists of unit tests. While unit tests are invaluable for checking the functionality of individual components, I believe it would greatly benefit the library to also have a suite of integration tests.

Understanding how the library interacts with real game servers is essential, given that this is its primary application. Current unit tests do an excellent job of validating the standalone functions of the library, yet they fall short in shedding light on the dynamics between these functions in a live server context. In addition to this, having integration tests would significantly improve the quality of life for developers.

Douile commented 1 year ago

+1

How do we validate whether an integration test has failed because the game server we used has gone down or if its the libraries fault?

I was thinking maybe me could use pseuso-servers that just always reply with a predetermined response we saved from a real server. But this requires work to implement and might defeat the entire purpose as it doesn't accurately reflect the current game engine (e.g. if a game update changed how queries work).

CosminPerRam commented 1 year ago

I was thinking maybe me could use pseuso-servers that just always reply with a predetermined response we saved from a real server. But this requires work to implement and might defeat the entire purpose as it doesn't accurately reflect the current game engine (e.g. if a game update changed how queries work).

Yep, that leaves us with three options as I see it:

  1. Mock the response (make it static) and process it
  2. Find servers online and query them (or have a script for this that looks up servers!)
  3. Start our own servers (via docker for example)

I'm interested on the 2nd point, as the first one might not be that good and the third one would be very time and resource consuming.

Douile commented 1 year ago

4th option hard code server addresses and if they break change them

CosminPerRam commented 1 year ago

4th option hard code server addresses and if they break change them

I've considered this to be the 2nd point.

If we choose this option, how would we test these servers? Just by querying and saying that it shouldnt be a GDError? An IP isn't always the same server (server properties can change and players are always changing, so no checking for names or counts). Could we rely on node-Gamedig for checking if the data is the same?

And also if we choose to find these dynamically (using a script) how would we do that? Although some servers (Valve ones for example) do have a master server, and we could search for those but many do not. Is there a game tracker that has an open api for stuff like this?

Providing 100% coverage of our games is impossible unless we start our own (3rd point).