aboutsummaryrefslogtreecommitdiff
path: root/nixos/tests/all-tests.nix
blob: 158c025b9e170ec05a8fc595f9c9bfb97ad42999 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{ testers }:

let
  dsl = ./dsl.nix;
  diamond.dag = {
    nodes.a = { };
    nodes.b.inputs.a = { }; # b->a
    nodes.c.inputs.a = { }; # c->a
    nodes.d.inputs.b = { }; # d->b
    nodes.d.inputs.c = { }; # d->c
  };

  #   A   B   C     D   E
  #   \   |  /      |   |
  #     U  V        W   X
  sunset.dag = {
    nodes =
      let
        abcInputs = {
          u = { };
          v = { };
        };
      in
      {
        a = {
          request = true;
          inputs = abcInputs;
        };
        b = {
          request = true;
          inputs = abcInputs;
        };
        c = {
          request = true;
          inputs = abcInputs;
        };

        d = {
          request = true;
          inputs.w = { };
        };
        e = {
          request = true;
          inputs.x = { };
        };

        u = { };
        v = { };
        w = { };
        x = { };
      };
  };
in
builtins.mapAttrs
  (
    name: value:
    testers.runNixOSTest (
      {
        inherit name;
        testScript = ''
          start_all()
          substituter.wait_for_unit("nix-serve.service")
          builder.succeed("dag-test")
        '';
      }
      // value
      // {
        imports = value.imports ++ [ dsl ];
      }
    )
  )
  {
    diamond-unbuilt-0 = {
      imports = [
        {
          dag.needBuilds = 0;
          dag.needDownloads = 0;
        }
        diamond
      ];
    };
    diamond-unbuilt-2 = {
      imports = [
        {
          dag.nodes.a.cache = "remote";
          dag.nodes.b.cache = "remote";
          dag.nodes.d.request = true;
          dag.needBuilds = 2;
          dag.needDownloads = 2;
        }
        diamond
      ];
    };
    diamond-unbuilt-4 = {
      imports = [
        {
          dag.nodes.d.request = true;
          dag.needBuilds = 4;
          dag.needDownloads = 0;
        }
        diamond
      ];
    };

    sunset-unbuilt-0 = {
      imports = [
        {
          dag = {
            # all builds
            needBuilds = 9;
            # all builds allowed
            allowBuilds = 5;
            # chosen builds requested
            choseBuilds = 3;

            nodes = {
              a.assertChosen = true;
              b.assertChosen = true;
              c.assertChosen = true;
            };
          };
        }
        sunset
      ];
    };
  }