1import ./make-test-python.nix ({ pkgs, ... }:
2
3{
4 name = "solr";
5 meta.maintainers = [ pkgs.lib.maintainers.aanderse ];
6
7 nodes.machine =
8 { config, pkgs, ... }:
9 {
10 # Ensure the virtual machine has enough memory for Solr to avoid the following error:
11 #
12 # OpenJDK 64-Bit Server VM warning:
13 # INFO: os::commit_memory(0x00000000e8000000, 402653184, 0)
14 # failed; error='Cannot allocate memory' (errno=12)
15 #
16 # There is insufficient memory for the Java Runtime Environment to continue.
17 # Native memory allocation (mmap) failed to map 402653184 bytes for committing reserved memory.
18 virtualisation.memorySize = 2000;
19
20 services.solr.enable = true;
21 };
22
23 testScript = ''
24 start_all()
25
26 machine.wait_for_unit("solr.service")
27 machine.wait_for_open_port(8983)
28 machine.succeed("curl --fail http://localhost:8983/solr/")
29
30 # adapted from pkgs.solr/examples/films/README.txt
31 machine.succeed("sudo -u solr solr create -c films")
32 assert '"status":0' in machine.succeed(
33 """
34 curl http://localhost:8983/solr/films/schema -X POST -H 'Content-type:application/json' --data-binary '{
35 "add-field" : {
36 "name":"name",
37 "type":"text_general",
38 "multiValued":false,
39 "stored":true
40 },
41 "add-field" : {
42 "name":"initial_release_date",
43 "type":"pdate",
44 "stored":true
45 }
46 }'
47 """
48 )
49 machine.succeed(
50 "sudo -u solr post -c films ${pkgs.solr}/example/films/films.json"
51 )
52 assert '"name":"Batman Begins"' in machine.succeed(
53 "curl http://localhost:8983/solr/films/query?q=name:batman"
54 )
55 '';
56})