summaryrefslogtreecommitdiffstats
path: root/Glusterfs/TestUnits/Replication/Main.py
blob: fa1888c0af4138d904af0262519a467ab89c33bc (plain)
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
#!/usr/bin/env python

import ATFGlusterVolume
import ATFClientUtils
import ATFValidate
import ATFUtils
import logging

def test1():
    """
    Description: Simple Replication Test
        Setup::
        *   create export directories export1, export2 
        *   create replicate volume with replica = 2 and transport = tcp
        *   start replicate volume
        *   create mount point on the client machine
        *   mount the replicate volume

        Execution:
        *   create a file

        Validation:
        *   Check whether the file is created on export1 and export2

        Expected:
        *   File exists on export1 and export2

    """

    ATFUtils.Logger.debug("Starting TestCase : [Test001]")
    ATFUtils.Logger.debug("Comment: Basic Replication Test")

    if ATFGlusterVolume.create_exportdirs("export1", "export2", host="host1"):
        return 1

    if ATFUtils.set_environ(ATF_HOST = "host1"):
       return 1
       
    if ATFGlusterVolume.create_volume("volume1", "host1:export1",
                                        "host1:export2", voltype = 'replica 2', 
                                        transport = 'transport tcp'):
        return 1
    
    if ATFGlusterVolume.start_volume("volume1"):
        return 1

    if ATFClientUtils.create_mountpoint("mount1"):
       return 1

    if ATFClientUtils.mount("mount1", "glusterfs", "host1:volume1"):
       return 1

    if ATFClientUtils.touch("file1.txt", user = "root"):
       return 1

    ### Validate ###

    if ATFValidate.validate_replication(f1 = 'host1:export1:file1.txt',  f2 = 'host1:export2:file1.txt'):
        return 1

    return 0
    
def cleanup():
    """ Cleanup Phase:
    
        Description:
            *   Unmount the client mount point
            *   Stop the replicate volume
    """

    ATFClientUtils.umount("mount1")
    if ATFGlusterVolume.stop_volume("volume1", host="host1"):
        return 1
    return 0

if __name__ == "__main__":
    main()


def main():

    status = 0
    status = test1()
    status = cleanup()
    return status