Exemple #1
0
    def test_iostat_parsable(self):
        """
        Tests successful return of iostat function

        .. note:
            The command output is the same as the non parsable!
            There is no -p flag for zpool iostat, but our type
            conversions can handle this!
        """
        ret = {}
        ret["stdout"] = "\n".join([
            "               capacity     operations    bandwidth",
            "pool        alloc   free   read  write   read  write",
            "----------  -----  -----  -----  -----  -----  -----",
            "mypool      46.7G  64.3G      4     19   113K   331K",
            "  mirror    46.7G  64.3G      4     19   113K   331K",
            "    c2t0d0      -      -      1     10   114K   334K",
            "    c2t1d0      -      -      1     10   114K   334K",
            "----------  -----  -----  -----  -----  -----  -----",
        ])
        ret["stderr"] = ""
        ret["retcode"] = 0
        mock_cmd = MagicMock(return_value=ret)
        with patch.dict(zpool.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
                zpool.__utils__, self.utils_patch):
            ret = zpool.iostat("mypool", parsable=True)
            self.assertEqual(50143743180, ret["mypool"]["capacity-alloc"])
Exemple #2
0
def test_iostat(utils_patch):
    """
    Tests successful return of iostat function
    """
    ret = {}
    ret["stdout"] = "\n".join(
        [
            "               capacity     operations    bandwidth",
            "pool        alloc   free   read  write   read  write",
            "----------  -----  -----  -----  -----  -----  -----",
            "mypool      46.7G  64.3G      4     19   113K   331K",
            "  mirror    46.7G  64.3G      4     19   113K   331K",
            "    c2t0d0      -      -      1     10   114K   334K",
            "    c2t1d0      -      -      1     10   114K   334K",
            "----------  -----  -----  -----  -----  -----  -----",
        ]
    )
    ret["stderr"] = ""
    ret["retcode"] = 0
    mock_cmd = MagicMock(return_value=ret)
    with patch.dict(zpool.__salt__, {"cmd.run_all": mock_cmd}), patch.dict(
        zpool.__utils__, utils_patch
    ):
        ret = zpool.iostat("mypool", parsable=False)
        assert "46.7G" == ret["mypool"]["capacity-alloc"]
Exemple #3
0
 def test_iostat(self):
     '''
     Tests successful return of iostat function
     '''
     ret = {}
     ret['stdout'] = "\n".join([
         "               capacity     operations    bandwidth",
         "pool        alloc   free   read  write   read  write",
         "----------  -----  -----  -----  -----  -----  -----",
         "mypool      46.7G  64.3G      4     19   113K   331K",
         "  mirror    46.7G  64.3G      4     19   113K   331K",
         "    c2t0d0      -      -      1     10   114K   334K",
         "    c2t1d0      -      -      1     10   114K   334K",
         "----------  -----  -----  -----  -----  -----  -----",
     ])
     ret['stderr'] = ""
     ret['retcode'] = 0
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}):
         ret = zpool.iostat('mypool')
         self.assertEqual('46.7G', ret['mypool']['mypool']['capacity-alloc'])
Exemple #4
0
 def test_iostat(self):
     '''
     Tests successful return of iostat function
     '''
     ret = {}
     ret['stdout'] = "\n".join([
         "               capacity     operations    bandwidth",
         "pool        alloc   free   read  write   read  write",
         "----------  -----  -----  -----  -----  -----  -----",
         "mypool      46.7G  64.3G      4     19   113K   331K",
         "  mirror    46.7G  64.3G      4     19   113K   331K",
         "    c2t0d0      -      -      1     10   114K   334K",
         "    c2t1d0      -      -      1     10   114K   334K",
         "----------  -----  -----  -----  -----  -----  -----",
     ])
     ret['stderr'] = ""
     ret['retcode'] = 0
     mock_cmd = MagicMock(return_value=ret)
     with patch.dict(zpool.__salt__, {'cmd.run_all': mock_cmd}):
         ret = zpool.iostat('mypool')
         self.assertEqual('46.7G', ret['mypool']['mypool']['capacity-alloc'])