Skip to content

Add server tests #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add server tests #261

wants to merge 3 commits into from

Conversation

Julow
Copy link
Contributor

@Julow Julow commented May 15, 2025

This adds a way to test ocsigenserver using cram tests. This is extremely valuable while developping a new feature and will help avoid regressions in the future.

The first two commits change ocsigenserver to listen on a unix-domain socket when started with:

let () =
  Ocsigen_server.start ~ports:[`File "./local.sock", 0]

Ip_address.of_sockaddr and Socket_type.to_inet_addr are removed as they no longer make sense. Ocsigen_request.remote_ip_parsed is changed to propagate the information to Accesscontrol.

In the test/ directory, server-test-helpers.sh does the setup and teardown and cram tests are setup in the extensions/ directory.
Making a server test is as simple as:

  $ source ../../server-test-helpers.sh
  $ run_server ./test.exe
  ... Server logs will appear here ...

  $ curl_ "index.html"

A first test is added that shows basic Staticmod and Deflatemod usage in test/extensions/deflatemod.t.

Julow added 3 commits May 14, 2025 16:08
The server can now listen on a local unix domain socket when started
with:

    Ocsigen_server.start ~ports:[`File "./local.sock", 0]

This can allow testing.

`Socket_type.to_inet_addr` is removed as it's only used to later obtain
a string.
This function can no longer be implemented due to unix-domain sockets.

`Ocsigen_request.remote_ip_parsed` is changed to propagate the
information to Accesscontrol.
This adds a way to test ocsigenserver using cram tests. This is
extremely valuable while developping a new feature and will help avoid
regressions in the future.

`server-test-helpers.sh` does the setup and teardown. Making a server
test is as simple as:

      $ source ../../server-test-helpers.sh
      $ run_server ./test.exe
      ... Server logs will appear here ...

      $ curl_ "index.html"

A first test is added that shows basic Staticmod and Deflatemod usage in `test/extensions/deflatemod.t`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant