Exemplo n.º 1
0
 def test_check_cluster_fail(self, mock_context_get):
     with pytest.raises(ValueError):
         check_cluster('a-cluster')
     mock_context_get.side_effect = [{
         'context': {
             'cluster': 'another-cluster'
         }
     }]
     mock_context_get.assert_called_once_with()
Exemplo n.º 2
0
 def test_check_cluster_fail(self, mock_context_get):
     with pytest.raises(ValueError):
         check_cluster("a-cluster")
     mock_context_get.side_effect = [{
         "context": {
             "cluster": "another-cluster"
         }
     }]
     mock_context_get.assert_called_once_with()
Exemplo n.º 3
0
    def test_integration_dev(self):
        # Get options
        opts = load_config(self.CONFIG)

        # TODO: There should be a more elegant way of obtaining all the releases
        releases = (
            [key for key in opts["cas"].keys()] +
            [key + "-pg" for key in opts["cas"].keys()] +
            list(opts["msps"]["AlphaMSP"]["orderers"]["nodes"].keys()) +
            [("cdb-" + key)
             for key in opts["msps"]["BetaMSP"]["peers"]["nodes"].keys()] +
            [key for key in opts["msps"]["BetaMSP"]["peers"]["nodes"].keys()])

        # Run Fabric script
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        runner_fabric(opts)

        # Delete all deployments from Helm
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        execute(f"helm delete --purge {' '.join(releases)}")

        # Delete the namespaces
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        execute("kubectl delete ns alpha beta")
Exemplo n.º 4
0
    def test_integration_qa(self):
        # Get options
        opts = load_config(self.CONFIG)

        # Save TLS of each CA in its relevant secret
        ns_create("cas")

        # TODO: Eventually we should enable getting path for multiple CAs programatically
        execute(
            (
                "kubectl -n cas create secret tls ca--tls "
                + f"--cert={self.TLS_PATH}.crt "
                + f"--key={self.TLS_PATH}.key"
            )
        )

        # TODO: There should be a more elegant way of obtaining all the releases
        releases = (
            [key for key in opts["cas"].keys()]
            + [key + "-pg" for key in opts["cas"].keys()]
            + list(opts["msps"]["AlphaMSP"]["orderers"]["nodes"].keys())
            + [
                ("cdb-" + key)
                for key in opts["msps"]["BetaMSP"]["peers"]["nodes"].keys()
            ]
            + [key for key in opts["msps"]["BetaMSP"]["peers"]["nodes"].keys()]
        )

        # Run Fabric script
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        runner_fabric(opts)

        # Delete all deployments from Helm
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        execute(f"helm delete --purge {' '.join(releases)}")

        # Delete the namespaces
        check_cluster(
            self.CONTEXT
        )  # Dangerous operation, recheck we have not shifted context
        execute("kubectl delete ns cas alpha beta")
Exemplo n.º 5
0
 def test_check_cluster(self, mock_context_get):
     mock_context_get.side_effect = [{'context': {'cluster': 'a-cluster'}}]
     check_cluster('a-cluster')
     mock_context_get.assert_called_once_with()
Exemplo n.º 6
0
 def test_check_cluster(self, mock_context_get):
     mock_context_get.side_effect = [{"context": {"cluster": "a-cluster"}}]
     check_cluster("a-cluster")
     mock_context_get.assert_called_once_with()