Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial version vectors support #2108

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 47 additions & 11 deletions keywords/couchbaseserver.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
import time
import json
import requests
import re
import time
from datetime import timedelta
from requests.exceptions import ConnectionError, HTTPError, ChunkedEncodingError

import requests
from couchbase.cluster import (Cluster, ClusterOptions, ClusterTimeoutOptions,
PasswordAuthenticator, QueryIndexManager)
from couchbase.exceptions import (CouchbaseException, DocumentExistsException,
DocumentNotFoundException)
from requests import Session
from requests.exceptions import (ChunkedEncodingError, ConnectionError,
HTTPError)
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from couchbase.exceptions import CouchbaseException, DocumentNotFoundException, DocumentExistsException
from couchbase.cluster import QueryIndexManager, PasswordAuthenticator, ClusterTimeoutOptions, ClusterOptions, Cluster

import keywords.constants
from keywords.remoteexecutor import RemoteExecutor
from keywords.exceptions import CBServerError, ProvisioningError, TimeoutError, RBACUserCreationError
from libraries.provision.ansible_runner import AnsibleRunner
from keywords.utils import log_r, log_info, log_debug, log_error, hostname_for_url, host_for_url
from keywords.utils import version_and_build, random_string
from keywords import types
from utilities.cluster_config_utils import is_x509_auth, get_cbs_version, is_magma_enabled, is_cbs_ce_enabled, get_cluster
from keywords.exceptions import (CBServerError, ProvisioningError,
RBACUserCreationError, TimeoutError)
from keywords.remoteexecutor import RemoteExecutor
from keywords.utils import (host_for_url, hostname_for_url, log_debug,
log_error, log_info, log_r, random_string,
version_and_build)
from libraries.data import doc_generators
from libraries.provision.ansible_runner import AnsibleRunner
from utilities.cluster_config_utils import (get_cbs_version, get_cluster,
is_cbs_ce_enabled,
is_magma_enabled, is_x509_auth)

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)


Expand Down Expand Up @@ -1203,6 +1213,32 @@ def get_document(self, doc_id, bucket, scope="_default", collection="_default",
except DocumentNotFoundException as e:
raise Exception("Tried to fetch document that does not exist: " + str(e)) from e
return result.content_as[dict]


def set_cross_cluster_versioning(self, bucket: str, xdcr_versioning: bool):
data = {
"enableCrossClusterVersioning": str(xdcr_versioning)
}
resp = self._session.post("{}/pools/default/buckets/{}".format(self.url, bucket), data=data)
log_r(resp)
# resp.raise_for_status()

def start_xdcr_replication(self, bucket: str, filter_expression: str = None) -> str:
data = {
"mobile": "active",
"replicationType": "continuous",
"fromBucket": bucket,
"toBucket": bucket,
"toCluster": ''
}

if filter_expression:
data.update({
"filterExpression": filter_expression
})
resp = self._session.post("{}/controller/createReplication".format(self.url), data=data)
log_r(resp)
# resp.raise_for_status()


def choose_connection_url(ssl_enabled, ipv6, host):
Expand Down
12 changes: 8 additions & 4 deletions libraries/utilities/generate_clusters_from_pool.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import json
import os
import sys
import socket
import sys

sys.path = [".", "keywords"] + sys.path
from keywords.utils import log_info # noqa: E402
from keywords.utils import log_warn # noqa: E402
from keywords.utils import log_error # noqa: E402
from optparse import OptionParser # noqa: E402

from keywords.utils import (
log_error, # noqa: E402
log_info, # noqa: E402
log_warn, # noqa: E402
)


class ClusterDef:
def __init__(self, name, num_sgs, num_acs, num_cbs, num_lgs, num_lbs):
Expand Down Expand Up @@ -505,6 +508,7 @@ def generate_clusters_from_pool(pool_file, use_docker=False, sg_windows=False,
ClusterDef("1sg_3cbs_1lgs", num_sgs=1, num_acs=0, num_cbs=3, num_lgs=1, num_lbs=0),
# 2 sync_gateways
ClusterDef("2sg_1cbs_1lgs", num_sgs=2, num_acs=0, num_cbs=1, num_lgs=1, num_lbs=0),
ClusterDef("2sg_2cbs", num_sgs=2, num_acs=0, num_cbs=2, num_lgs=0, num_lbs=0),
ClusterDef("2sg_3cbs_2lgs", num_sgs=2, num_acs=0, num_cbs=3, num_lgs=2, num_lbs=0),
ClusterDef("2sg_6cbs_2lgs", num_sgs=2, num_acs=0, num_cbs=6, num_lgs=2, num_lbs=0),
ClusterDef("2sg_2ac_3cbs_1lgs", num_sgs=2, num_acs=2, num_cbs=3, num_lgs=1, num_lbs=0),
Expand Down
Loading