Merge pull request #74005 from flokli/nixos-test-port-etcd
nixosTests.etcd*: port to python
This commit is contained in:
		
						commit
						0a724f9e5d
					
				@ -1,6 +1,6 @@
 | 
			
		||||
# This test runs simple etcd cluster
 | 
			
		||||
 | 
			
		||||
import ./make-test.nix ({ pkgs, ... } : let
 | 
			
		||||
import ./make-test-python.nix ({ pkgs, ... } : let
 | 
			
		||||
 | 
			
		||||
  runWithOpenSSL = file: cmd: pkgs.runCommand file {
 | 
			
		||||
    buildInputs = [ pkgs.openssl ];
 | 
			
		||||
@ -129,29 +129,26 @@ in {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  testScript = ''
 | 
			
		||||
    subtest "should start etcd cluster", sub {
 | 
			
		||||
      $node1->start();
 | 
			
		||||
      $node2->start();
 | 
			
		||||
      $node1->waitForUnit("etcd.service");
 | 
			
		||||
      $node2->waitForUnit("etcd.service");
 | 
			
		||||
      $node2->waitUntilSucceeds("etcdctl cluster-health");
 | 
			
		||||
      $node1->succeed("etcdctl set /foo/bar 'Hello world'");
 | 
			
		||||
      $node2->succeed("etcdctl get /foo/bar | grep 'Hello world'");
 | 
			
		||||
    };
 | 
			
		||||
    with subtest("should start etcd cluster"):
 | 
			
		||||
        node1.start()
 | 
			
		||||
        node2.start()
 | 
			
		||||
        node1.wait_for_unit("etcd.service")
 | 
			
		||||
        node2.wait_for_unit("etcd.service")
 | 
			
		||||
        node2.wait_until_succeeds("etcdctl cluster-health")
 | 
			
		||||
        node1.succeed("etcdctl set /foo/bar 'Hello world'")
 | 
			
		||||
        node2.succeed("etcdctl get /foo/bar | grep 'Hello world'")
 | 
			
		||||
 | 
			
		||||
    subtest "should add another member", sub {
 | 
			
		||||
      $node1->waitUntilSucceeds("etcdctl member add node3 https://node3:2380");
 | 
			
		||||
      $node3->start();
 | 
			
		||||
      $node3->waitForUnit("etcd.service");
 | 
			
		||||
      $node3->waitUntilSucceeds("etcdctl member list | grep 'node3'");
 | 
			
		||||
      $node3->succeed("etcdctl cluster-health");
 | 
			
		||||
    };
 | 
			
		||||
    with subtest("should add another member"):
 | 
			
		||||
        node1.wait_until_succeeds("etcdctl member add node3 https://node3:2380")
 | 
			
		||||
        node3.start()
 | 
			
		||||
        node3.wait_for_unit("etcd.service")
 | 
			
		||||
        node3.wait_until_succeeds("etcdctl member list | grep 'node3'")
 | 
			
		||||
        node3.succeed("etcdctl cluster-health")
 | 
			
		||||
 | 
			
		||||
    subtest "should survive member crash", sub {
 | 
			
		||||
      $node3->crash;
 | 
			
		||||
      $node1->succeed("etcdctl cluster-health");
 | 
			
		||||
      $node1->succeed("etcdctl set /foo/bar 'Hello degraded world'");
 | 
			
		||||
      $node1->succeed("etcdctl get /foo/bar | grep 'Hello degraded world'");
 | 
			
		||||
    };
 | 
			
		||||
    with subtest("should survive member crash"):
 | 
			
		||||
        node3.crash()
 | 
			
		||||
        node1.succeed("etcdctl cluster-health")
 | 
			
		||||
        node1.succeed("etcdctl set /foo/bar 'Hello degraded world'")
 | 
			
		||||
        node1.succeed("etcdctl get /foo/bar | grep 'Hello degraded world'")
 | 
			
		||||
  '';
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
# This test runs simple etcd node
 | 
			
		||||
 | 
			
		||||
import ./make-test.nix ({ pkgs, ... } : {
 | 
			
		||||
import ./make-test-python.nix ({ pkgs, ... } : {
 | 
			
		||||
  name = "etcd";
 | 
			
		||||
 | 
			
		||||
  meta = with pkgs.stdenv.lib.maintainers; {
 | 
			
		||||
@ -14,14 +14,12 @@ import ./make-test.nix ({ pkgs, ... } : {
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  testScript = ''
 | 
			
		||||
    subtest "should start etcd node", sub {
 | 
			
		||||
      $node->start();
 | 
			
		||||
      $node->waitForUnit("etcd.service");
 | 
			
		||||
    };
 | 
			
		||||
    with subtest("should start etcd node"):
 | 
			
		||||
        node.start()
 | 
			
		||||
        node.wait_for_unit("etcd.service")
 | 
			
		||||
 | 
			
		||||
    subtest "should write and read some values to etcd", sub {
 | 
			
		||||
      $node->succeed("etcdctl set /foo/bar 'Hello world'");
 | 
			
		||||
      $node->succeed("etcdctl get /foo/bar | grep 'Hello world'");
 | 
			
		||||
    }
 | 
			
		||||
    with subtest("should write and read some values to etcd"):
 | 
			
		||||
        node.succeed("etcdctl set /foo/bar 'Hello world'")
 | 
			
		||||
        node.succeed("etcdctl get /foo/bar | grep 'Hello world'")
 | 
			
		||||
  '';
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user