1import json
2import time
3import unittest
4import urllib
5import testconstants
6from TestInput import TestInputSingleton
7
8from community.community_base import CommunityBaseTest
9from community.community_base import CommunityXDCRBaseTest
10from memcached.helper.data_helper import  MemcachedClientHelper
11from membase.api.rest_client import RestConnection, Bucket
12from membase.helper.rebalance_helper import RebalanceHelper
13from membase.api.exception import RebalanceFailedException
14from couchbase_helper.documentgenerator import BlobGenerator
15from remote.remote_util import RemoteMachineShellConnection
16from membase.helper.cluster_helper import ClusterOperationHelper
17from scripts.install import InstallerJob
18from testconstants import SHERLOCK_VERSION
19from testconstants import COUCHBASE_FROM_WATSON, COUCHBASE_FROM_SPOCK,\
20                          COUCHBASE_FROM_VULCAN
21
22
23
24
25class CommunityTests(CommunityBaseTest):
26    def setUp(self):
27        super(CommunityTests, self).setUp()
28        self.command = self.input.param("command", "")
29        self.zone = self.input.param("zone", 1)
30        self.replica = self.input.param("replica", 1)
31        self.command_options = self.input.param("command_options", '')
32        self.set_get_ratio = self.input.param("set_get_ratio", 0.9)
33        self.item_size = self.input.param("item_size", 128)
34        self.shutdown_zone = self.input.param("shutdown_zone", 1)
35        self.do_verify = self.input.param("do-verify", True)
36        self.num_node = self.input.param("num_node", 4)
37        self.services = self.input.param("services", None)
38        self.start_node_services = self.input.param("start_node_services", "kv")
39        self.add_node_services = self.input.param("add_node_services", "kv")
40        self.timeout = 6000
41        self.user_add = self.input.param("user_add", None)
42        self.user_role = self.input.param("user_role", None)
43
44
45    def tearDown(self):
46        super(CommunityTests, self).tearDown()
47
48    def test_disabled_zone(self):
49        disabled_zone = False
50        zone_name = "group1"
51        serverInfo = self.servers[0]
52        self.rest = RestConnection(serverInfo)
53        try:
54            self.log.info("create zone name 'group1'!")
55            result = self.rest.add_zone(zone_name)
56            print "result  ",result
57        except Exception, e :
58            if e:
59                print e
60                disabled_zone = True
61                pass
62        if not disabled_zone:
63            self.fail("CE version should not have zone feature")
64
65    def check_audit_available(self):
66        audit_available = False
67        try:
68            self.rest.getAuditSettings()
69            audit_available = True
70        except Exception, e :
71            if e:
72                print e
73        if audit_available:
74            self.fail("This feature 'audit' only available on "
75                      "Enterprise Edition")
76
77    def check_ldap_available(self):
78        ldap_available = False
79        self.rest = RestConnection(self.master)
80        try:
81            s, c, h = self.rest.clearLDAPSettings()
82            if s:
83                ldap_available = True
84        except Exception, e :
85            if e:
86                print e
87        if ldap_available:
88            self.fail("This feature 'ldap' only available on "
89                      "Enterprise Edition")
90
91    def check_set_services(self):
92        self.rest.force_eject_node()
93        self.sleep(7, "wait for node reset done")
94        try:
95            status = self.rest.init_node_services(hostname=self.master.ip,
96                                                 services=[self.services])
97        except Exception, e:
98            if e:
99                print e
100        if self.services == "kv":
101            if status:
102                self.log.info("CE could set {0} only service."
103                                  .format(self.services))
104            else:
105                self.fail("Failed to set {0} only service."
106                                   .format(self.services))
107        elif self.services == "index,kv":
108            if status:
109                self.fail("CE does not support kv and index on same node")
110            else:
111                self.log.info("services enforced in CE")
112        elif self.services == "kv,n1ql":
113            if status:
114                self.fail("CE does not support kv and n1ql on same node")
115            else:
116                self.log.info("services enforced in CE")
117        elif self.services == "kv,eventing":
118            if status:
119                self.fail("CE does not support kv and eventing on same node")
120            else:
121                self.log.info("services enforced in CE")
122        elif self.services == "index,n1ql":
123            if status:
124                self.fail("CE does not support index and n1ql on same node")
125            else:
126                self.log.info("services enforced in CE")
127        elif self.services == "index,kv,n1ql":
128            if status:
129                self.log.info("CE could set all services {0} on same nodes."
130                                                           .format(self.services))
131            else:
132                self.fail("Failed to set kv, index and query services on CE")
133        elif self.version[:5] in COUCHBASE_FROM_WATSON:
134            if self.version[:5] in COUCHBASE_FROM_VULCAN and "eventing" in self.services:
135                if status:
136                    self.fail("CE does not support eventing in vulcan")
137                else:
138                    self.log.info("services enforced in CE")
139            elif self.services == "fts,index,kv":
140                if status:
141                    self.fail("CE does not support fts, index and kv on same node")
142                else:
143                    self.log.info("services enforced in CE")
144            elif self.services == "fts,index,n1ql":
145                if status:
146                    self.fail("CE does not support fts, index and n1ql on same node")
147                else:
148                    self.log.info("services enforced in CE")
149            elif self.services == "fts,kv,n1ql":
150                if status:
151                    self.fail("CE does not support fts, kv and n1ql on same node")
152                else:
153                    self.log.info("services enforced in CE")
154            elif self.services == "fts,index,kv,n1ql":
155                if status:
156                    self.log.info("CE could set all services {0} on same nodes."
157                                                           .format(self.services))
158                else:
159                    self.fail("Failed to set "
160                              "fts, index, kv, and query services on CE")
161        else:
162            self.fail("some services don't support")
163
164    def check_set_services_when_add_node(self):
165        self.rest.force_eject_node()
166        sherlock_services_in_ce = ["kv", "index,kv,n1ql"]
167        watson_services_in_ce = ["kv", "index,kv,n1ql", "fts,index,kv,n1ql"]
168        self.sleep(5, "wait for node reset done")
169        try:
170            self.log.info("Initialize node with services {0}"
171                                  .format(self.start_node_services))
172            status = self.rest.init_node_services(hostname=self.master.ip,
173                                        services=[self.start_node_services])
174            init_node = self.cluster.async_init_node(self.master,
175                                            services = [self.start_node_services])
176        except Exception, e:
177            if e:
178                print e
179        if not status:
180            if self.version not in COUCHBASE_FROM_WATSON and \
181                         self.start_node_services not in sherlock_services_in_ce:
182                self.log.info("initial services setting enforced in Sherlock CE")
183            elif self.version in COUCHBASE_FROM_WATSON and \
184                         self.start_node_services not in watson_services_in_ce:
185                self.log.info("initial services setting enforced in Watson CE")
186
187        elif status and init_node.result() != 0:
188            add_node = False
189            try:
190                self.log.info("node with services {0} try to add"
191                                  .format(self.add_node_services))
192                add_node = self.cluster.rebalance(self.servers[:2],
193                                                  self.servers[1:2], [],
194                                      services = [self.add_node_services])
195            except Exception:
196                pass
197            if add_node:
198                self.get_services_map()
199                list_nodes = self.get_nodes_from_services_map(get_all_nodes=True)
200                map = self.get_nodes_services()
201                if map[self.master.ip] == self.start_node_services and \
202                    map[self.servers[1].ip] == self.add_node_services:
203                    self.log.info("services set correctly when node added & rebalance")
204                else:
205                    self.fail("services set incorrectly when node added & rebalance. "
206                        "cluster expected services: {0}; set cluster services {1} ."
207                        "add node expected srv: {2}; set add node srv {3}"\
208                        .format(map[self.master.ip], self.start_node_services, \
209                         map[self.servers[1].ip], self.add_node_services))
210            else:
211                if self.version not in COUCHBASE_FROM_WATSON:
212                    if self.start_node_services in ["kv", "index,kv,n1ql"] and \
213                          self.add_node_services not in ["kv", "index,kv,n1ql"]:
214                        self.log.info("services are enforced in CE")
215                    elif self.start_node_services not in ["kv", "index,kv,n1ql"]:
216                        self.log.info("services are enforced in CE")
217                    else:
218                        self.fail("maybe bug in add node")
219                elif self.version in COUCHBASE_FROM_WATSON:
220                    if self.start_node_services in ["kv", "index,kv,n1ql",
221                         "fts,index,kv,n1ql"] and self.add_node_services not in \
222                                    ["kv", "index,kv,n1ql", "fts,index,kv,n1ql"]:
223                        self.log.info("services are enforced in CE")
224                    elif self.start_node_services not in ["kv", "index,kv,n1ql",
225                                                            "fts,index,kv,n1ql"]:
226                        self.log.info("services are enforced in CE")
227                    else:
228                        self.fail("maybe bug in add node")
229        else:
230            self.fail("maybe bug in node initialization")
231
232    def check_full_backup_only(self):
233        """ for windows vm, ask IT to put uniq.exe at
234            /cygdrive/c/Program Files (x86)/ICW/bin directory """
235
236        self.remote = RemoteMachineShellConnection(self.master)
237        """ put params items=0 in test param so that init items = 0 """
238        self.remote.execute_command("{0}cbworkloadgen -n {1}:8091 -j -i 1000 " \
239                                    "-u Administrator -p password" \
240                                            .format(self.bin_path, self.master.ip))
241        """ delete backup location before run backup """
242        self.remote.execute_command("rm -rf {0}*".format(self.backup_location))
243        output, error = self.remote.execute_command("ls -lh {0}"
244                                                     .format(self.backup_location))
245        self.remote.log_command_output(output, error)
246
247        """ first full backup """
248        self.remote.execute_command("{0}cbbackup http://{1}:8091 {2} -m full " \
249                                    "-u Administrator -p password"\
250                                    .format(self.bin_path,
251                                            self.master.ip,
252                                            self.backup_c_location))
253        output, error = self.remote.execute_command("ls -lh {0}*/"
254                                        .format(self.backup_location))
255        self.remote.log_command_output(output, error)
256        output, error = self.remote.execute_command("{0}cbtransfer -u Administrator "\
257                                           "-p password {1}*/*-full/ " \
258                                           "stdout: | grep set | uniq | wc -l"\
259                                           .format(self.bin_path,
260                                                   self.backup_c_location))
261        self.remote.log_command_output(output, error)
262        if int(output[0]) != 1000:
263            self.fail("full backup did not work in CE. "
264                      "Expected 1000, actual: {0}".format(output[0]))
265        self.remote.execute_command("{0}cbworkloadgen -n {1}:8091 -j -i 1000 "\
266                                    " -u Administrator -p password --prefix=t_"
267                                    .format(self.bin_path, self.master.ip))
268        """ do different backup mode """
269        self.remote.execute_command("{0}cbbackup -u Administrator -p password "\
270                                    "http://{1}:8091 {2} -m {3}"\
271                                    .format(self.bin_path,
272                                            self.master.ip,
273                                            self.backup_c_location,
274                                            self.backup_option))
275        output, error = self.remote.execute_command("ls -lh {0}"
276                                                     .format(self.backup_location))
277        self.remote.log_command_output(output, error)
278        output, error = self.remote.execute_command("{0}cbtransfer -u Administrator "\
279                                           "-p password {1}*/*-{2}/ stdout: "\
280                                           "| grep set | uniq | wc -l"\
281                                           .format(self.bin_path,
282                                                   self.backup_c_location,
283                                                   self.backup_option))
284        self.remote.log_command_output(output, error)
285        if int(output[0]) == 2000:
286            self.log.info("backup option 'diff' is enforced in CE")
287        elif int(output[0]) == 1000:
288            self.fail("backup option 'diff' is not enforced in CE. "
289                      "Expected 2000, actual: {0}".format(output[0]))
290        else:
291            self.fail("backup failed to backup correct items")
292        self.remote.disconnect()
293
294    def check_ent_backup(self):
295        """ for CE version from Watson, cbbackupmgr exe file should not in bin """
296        command = "cbbackupmgr"
297        self.remote = RemoteMachineShellConnection(self.master)
298        self.log.info("check if {0} in {1} directory".format(command, self.bin_path))
299        found = self.remote.file_exists(self.bin_path, command)
300        if found:
301            self.log.info("found {0} in {1} directory".format(command, self.bin_path))
302            self.fail("CE from Watson should not contain {0}".format(command))
303        elif not found:
304            self.log.info("Ent. backup in CE is enforced, not in bin!")
305        self.remote.disconnect()
306
307    def check_memory_optimized_storage_mode(self):
308        """ from Watson, CE should not have option 'memory_optimized' to set """
309        self.rest.force_eject_node()
310        self.sleep(5, "wait for node reset done")
311        try:
312            self.log.info("Initialize node with 'Memory Optimized' option")
313            status = self.rest.set_indexer_storage_mode(
314                            username=self.input.membase_settings.rest_username,
315                            password=self.input.membase_settings.rest_password,
316                                                storageMode='memory_optimized')
317        except Exception, ex:
318            if ex:
319                print ex
320        if not status:
321            self.log.info("Memory Optimized setting enforced in CE "
322                          "Could not set memory_optimized option")
323        else:
324            self.fail("Memory Optimzed setting does not enforced in CE "
325                      "We could set this option in")
326
327    def check_x509_cert(self):
328        """ from Watson, X509 certificate only support in EE """
329        api = self.rest.baseUrl + "pools/default/certificate?extended=true"
330        self.log.info("request to get certificate at "
331                      "'pools/default/certificate?extended=true' "
332                      "should return False")
333        try:
334            status, content, header = self.rest._http_request(api, 'GET')
335        except Exception, ex:
336            if ex:
337                print ex
338        if status:
339            self.fail("This X509 certificate feature only available in EE")
340        elif not status:
341            if "requires enterprise edition" in content:
342                self.log.info("X509 cert is enforced in CE")
343
344    def check_roles_base_access(self):
345        """ from Watson, roles base access for admin should not in in CE """
346        if self.user_add is None:
347            self.fail("We need to pass user name (user_add) to run this test. ")
348        if self.user_role is None:
349            self.fail("We need to pass user roles (user_role) to run this test. ")
350        api = self.rest.baseUrl + "settings/rbac/users/" + self.user_add
351        self.log.info("url to run this test: %s" % api)
352        """ add admin user """
353        param = "name=%s&roles=%s" % (self.user_add, self.user_role)
354        try:
355            status, content, header = self.rest._http_request(api, 'PUT', param)
356        except Exception, ex:
357            if ex:
358                print ex
359        if status:
360            self.fail("CE should not allow to add admin users")
361        else:
362            self.log.info("roles base is enforced in CE! ")
363
364    def check_root_certificate(self):
365        """ from watson, ce should not see root certificate
366            manual test:
367            curl -u Administrator:password -X GET
368                            http://localhost:8091/pools/default/certificate """
369        api = self.rest.baseUrl + "pools/default/certificate"
370        try:
371            status, content, header = self.rest._http_request(api, 'GET')
372        except Exception, ex:
373            if ex:
374                print ex
375        if status:
376            self.fail("CE should not see root certificate!")
377        elif "requires enterprise edition" in content:
378            self.log.info("root certificate is enforced in CE! ")
379
380    def check_settings_audit(self):
381        """ from watson, ce should not set audit
382            manual test:
383            curl -u Administrator:password -X GET
384                            http://localhost:8091/settings/audit """
385        api = self.rest.baseUrl + "settings/audit"
386        try:
387            status, content, header = self.rest._http_request(api, 'GET')
388        except Exception, ex:
389            if ex:
390                print ex
391        if status:
392            self.fail("CE should not allow to set audit !")
393        elif "requires enterprise edition" in content:
394            self.log.info("settings audit is enforced in CE! ")
395
396    def check_infer(self):
397        """ from watson, ce should not see infer
398            manual test:
399            curl -H "Content-Type: application/json" -X POST
400                 -d '{"statement":"infer `bucket_name`;"}'
401                       http://localhost:8093/query/service
402            test params: new_services=kv-index-n1ql,default_bucket=False """
403        self.rest.force_eject_node()
404        self.sleep(7, "wait for node reset done")
405        self.rest.init_node()
406        bucket = "default"
407        self.rest.create_bucket(bucket, ramQuotaMB=200)
408        api = self.rest.query_baseUrl + "query/service"
409        param = urllib.urlencode({"statement":"infer `%s` ;" % bucket})
410        try:
411            status, content, header = self.rest._http_request(api, 'POST', param)
412            json_parsed = json.loads(content)
413        except Exception, ex:
414            if ex:
415                print ex
416        if json_parsed["status"] == "success":
417            self.fail("CE should not allow to run INFER !")
418        elif json_parsed["status"] == "fatal":
419            self.log.info("INFER is enforced in CE! ")
420
421    def check_auto_complete(self):
422        """ this feature has not complete to block in CE """
423
424    """ Check new features from spock start here """
425    def check_cbbackupmgr(self):
426        """ cbbackupmgr should not available in CE from spock """
427        if self.cb_version[:5] in COUCHBASE_FROM_SPOCK:
428            file_name = "cbbackupmgr" + self.file_extension
429            self.log.info("check if cbbackupmgr in bin dir in CE")
430            result = self.remote.file_exists(self.bin_path, file_name)
431            if result:
432                self.fail("cbbackupmgr should not in bin dir of CE")
433            else:
434                self.log.info("cbbackupmgr is enforced in CE")
435        self.remote.disconnect()
436
437    def test_max_ttl_bucket(self):
438        """
439            From vulcan, EE bucket has has an option to set --max-ttl, not it CE.
440            This test is make sure CE could not create bucket with option --max-ttl
441            This test must pass default_bucket=False
442        """
443        if self.cb_version[:5] not in COUCHBASE_FROM_VULCAN:
444            self.log.info("This test only for vulcan and later")
445            return
446        cmd = 'curl -X POST -u Administrator:password \
447                                    http://{0}:8091/pools/default/buckets \
448                                 -d name=bucket0 \
449                                 -d maxTTL=100 \
450                                 -d authType=sasl \
451                                 -d ramQuotaMB=100 '.format(self.master.ip)
452        if self.cli_test:
453            cmd = "{0}couchbase-cli bucket-create -c {1}:8091 --username Administrator \
454                --password password --bucket bucket0 --bucket-type couchbase \
455                --bucket-ramsize 512 --bucket-replica 1 --bucket-priority high \
456                --bucket-eviction-policy fullEviction --enable-flush 0 \
457                --enable-index-replica 1 --max-ttl 200".format(self.bin_path,
458                                                               self.master.ip)
459        conn = RemoteMachineShellConnection(self.master)
460        output, error = conn.execute_command(cmd)
461        conn.log_command_output(output, error)
462        mesg = "Max TTL is supported in enterprise edition only"
463        if self.cli_test:
464            mesg = "Maximum TTL can only be configured on enterprise edition"
465        if output and mesg not in str(output[0]):
466            self.fail("max ttl feature should not in Community Edition")
467        buckets = RestConnection(self.master).get_buckets()
468        if buckets:
469            for bucket in buckets:
470                self.log.info("bucekt in cluser: {0}".format(bucket.name))
471                if bucket.name == "bucket0":
472                    self.fail("Failed to enforce feature max ttl in CE.")
473        conn.disconnect()
474
475    def test_setting_audit(self):
476        """
477           CE does not allow to set audit from vulcan 5.5.0
478        """
479        if self.cb_version[:5] not in COUCHBASE_FROM_VULCAN:
480            self.log.info("This test only for vulcan and later")
481            return
482        cmd = 'curl -X POST -u Administrator:password \
483              http://{0}:8091/settings/audit \
484              -d auditdEnabled=true '.format(self.master.ip)
485        if self.cli_test:
486            cmd = "{0}couchbase-cli setting-audit -c {1}:8091 -u Administrator \
487                -p password --audit-enabled 1 --audit-log-rotate-interval 604800 \
488                --audit-log-path /opt/couchbase/var/lib/couchbase/logs "\
489                .format(self.bin_path, self.master.ip)
490
491        conn = RemoteMachineShellConnection(self.master)
492        output, error = conn.execute_command(cmd)
493        conn.log_command_output(output, error)
494        mesg = "This http API endpoint requires enterprise edition"
495        if output and mesg not in str(output[0]):
496            self.fail("setting-audit feature should not in Community Edition")
497        conn.disconnect()
498
499    def test_setting_autofailover_enterprise_only(self):
500        """
501           CE does not allow set auto failover if disk has issue
502           and failover group from vulcan 5.5.0
503        """
504        if self.cb_version[:5] not in COUCHBASE_FROM_VULCAN:
505            self.log.info("This test only for vulcan and later")
506            return
507        self.failover_disk_period = self.input.param("failover_disk_period", False)
508        self.failover_server_group = self.input.param("failover_server_group", False)
509
510        failover_disk_period = ""
511        if self.failover_disk_period:
512            if self.cli_test:
513                failover_disk_period = "--failover-data-disk-period 300"
514            else:
515                failover_disk_period = "-d failoverOnDataDiskIssues[timePeriod]=300"
516        failover_server_group = ""
517        if self.failover_server_group and self.cli_test:
518            failover_server_group = "--enable-failover-of-server-group 1"
519
520
521        cmd = 'curl -X POST -u Administrator:password \
522              http://{0}:8091/settings/autoFailover -d enabled=true -d timeout=120 \
523              -d maxCount=1 \
524              -d failoverOnDataDiskIssues[enabled]=true {1} \
525              -d failoverServerGroup={2}'.format(self.master.ip, failover_disk_period,
526                                                 self.failover_server_group)
527        if self.cli_test:
528            cmd = "{0}couchbase-cli setting-autofailover -c {1}:8091 \
529                   -u Administrator -p password \
530                   --enable-failover-on-data-disk-issues 1 {2} {3} "\
531                  .format(self.bin_path, self.master.ip,
532                          failover_disk_period,
533                          failover_server_group)
534        conn = RemoteMachineShellConnection(self.master)
535        output, error = conn.execute_command(cmd)
536        conn.log_command_output(output, error)
537        mesg = "Auto failover on Data Service disk issues can only be " + \
538               "configured on enterprise edition"
539        if not self.cli_test:
540            if self.failover_disk_period or \
541                                   self.failover_server_group:
542                if output and not error:
543                    self.fail("setting autofailover disk issues feature\
544                               should not in Community Edition")
545        else:
546            if self.failover_server_group:
547                mesg = "--enable-failover-of-server-groups can only be " + \
548                       "configured on enterprise edition"
549
550        if output and mesg not in str(output[0]):
551            self.fail("Setting EE autofailover features \
552                       should not in Community Edition")
553        else:
554            self.log.info("EE setting autofailover are disable in CE")
555        conn.disconnect()
556
557    def test_set_bucket_compression(self):
558        """
559           CE does not allow to set bucket compression to bucket
560           from vulcan 5.5.0.   Mode compression: off,active,passive
561           Note: must set defaultbucket=False for this test
562        """
563        if self.cb_version[:5] not in COUCHBASE_FROM_VULCAN:
564            self.log.info("This test only for vulcan and later")
565            return
566        self.compression_mode = self.input.param("compression_mode", "off")
567        cmd = 'curl -X POST -u Administrator:password \
568                                    http://{0}:8091/pools/default/buckets \
569                                 -d name=bucket0 \
570                                 -d compressionMode={1} \
571                                 -d authType=sasl \
572                                 -d ramQuotaMB=100 '.format(self.master.ip,
573                                                            self.compression_mode)
574        if self.cli_test:
575            cmd = "{0}couchbase-cli bucket-create -c {1}:8091 --username Administrator \
576                --password password --bucket bucket0 --bucket-type couchbase \
577                --bucket-ramsize 512 --bucket-replica 1 --bucket-priority high \
578                --bucket-eviction-policy fullEviction --enable-flush 0 \
579                --enable-index-replica 1 --compression-mode {2}".format(self.bin_path,
580                                                                 self.master.ip,
581                                                                 self.compression_mode)
582        conn = RemoteMachineShellConnection(self.master)
583        output, error = conn.execute_command(cmd)
584        conn.log_command_output(output, error)
585        mesg = "Compression mode is supported in enterprise edition only"
586        if self.cli_test:
587            mesg = "Compression mode can only be configured on enterprise edition"
588        if output and mesg not in str(output[0]):
589            self.fail("Setting bucket compression should not in CE")
590        conn.disconnect()
591
592
593class CommunityXDCRTests(CommunityXDCRBaseTest):
594    def setUp(self):
595        super(CommunityXDCRTests, self).setUp()
596
597    def tearDown(self):
598        super(CommunityXDCRTests, self).tearDown()
599
600    def test_xdcr_filter(self):
601        filter_on = False
602        serverInfo = self._servers[0]
603        self.rest = RestConnection(serverInfo)
604        self.rest.remove_all_replications()
605        self.remote = RemoteMachineShellConnection(serverInfo)
606        output, error = self.remote.execute_command('curl -X POST '
607                                         '-u Administrator:password '
608                     ' http://{0}:8091/controller/createReplication '
609                     '-d fromBucket="default" '
610                     '-d toCluster="cluster1" '
611                     '-d toBucket="default" '
612                     '-d replicationType="continuous" '
613                     '-d filterExpression="some_exp"'
614                                              .format(serverInfo.ip))
615        if output:
616            self.log.info(output[0])
617        if output and "default" in output[0]:
618            self.fail("XDCR Filter feature should not available in "
619                      "Community Edition")
620        self.remote.disconnect()
621
622    def test_lww(self):
623        server = self._servers[0]
624        conn = RemoteMachineShellConnection(server)
625        output, error = conn.execute_command('curl -X POST -u Administrator:password '
626                                                    'http://{0}:8091/pools/default/buckets '
627                                                    '-d name=default '
628                                                    '-d conflictResolutionType=lww '
629                                                    '-d authType=sasl '
630                                                    '-d ramQuotaMB=100 '.format(server.ip))
631        conn.log_command_output(output, error)
632        if output and "Conflict resolution type 'lww' is supported only in enterprise edition" not in str(output[0]):
633            self.fail("XDCR LWW feature should not be available in Community Edition")
634        self.log.info("XDCR LWW feature not available in Community Edition as expected")
635        conn.disconnect()
636