Skip to content

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 5 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`.
The name 'Unix' makes it more clear that it will make a unix-domain
socket and not a regular file.
@Julow
Copy link
Contributor Author

Julow commented May 27, 2025

I changed the API to use `Unix instead of `File, to reflect the fact that it'll make a unix-domain-socket instead of a regular file. I also updated the README to mention the server tests.

@vouillon vouillon merged commit 6bfe3a2 into ocsigen:master Jun 3, 2025
10 checks passed
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.

2 participants