From 595d4af06bd83113a9c34db42274b17cee1cbcff Mon Sep 17 00:00:00 2001 From: Jenny Schweers Date: Tue, 17 Sep 2024 11:38:29 -0400 Subject: [PATCH 1/3] Added action for tests --- .github/workflows/tests.yml | 41 +++++++++++++++++++++++++++++++++++++ .gitignore | 2 ++ requirements.txt | 8 ++++---- 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000000..c8b39a219d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,41 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: +# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: couchdb-cluster-admin tests + +on: + push: + branches: [ master ] + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] # dimagi-memoized does not yet support later versions of python + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + python -m pip install -r test-requirements.txt + - name: Make data directory if needed + run: | + mkdir -p /home/runner/work/couchdb-cluster-admin/couchdb-cluster-admin/data + - name: Set up docker clusters + run: | + docker build -t couchdb-cluster - < docker-couchdb-cluster/Dockerfile + docker run -d --name couchdb-cluster -v $(pwd)/data:/usr/src/couchdb/dev/lib/ -p 15984:15984 -p 15986:15986 -p 25984:25984 -p 25986:25986 -p 35984:35984 -p 35986:35986 -p 45984:45984 -p 45986:45986 -t couchdb-cluster --with-admin-party-please -n 4 + - name: Run tests + run: | + pytest tests.py diff --git a/.gitignore b/.gitignore index 1a5e10b54d..24d088795a 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,5 @@ ENV/ # IDE config .idea + +*.swp diff --git a/requirements.txt b/requirements.txt index 67b4c19ce5..e394a4364b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,15 +12,15 @@ charset-normalizer==2.0.12 # via requests dimagi-memoized==1.1.1 # via couchdb-cluster-admin (setup.py) -gevent==1.4.0 +gevent==24.2.1 # via couchdb-cluster-admin (setup.py) -greenlet==0.4.15 +greenlet==3.1.0 # via gevent idna==2.8 # via requests -jsonobject==2.0.0 +jsonobject==2.2.0 # via couchdb-cluster-admin (setup.py) -pyyaml==5.4.1 +pyyaml==6.0.2 # via couchdb-cluster-admin (setup.py) requests==2.27.1 # via couchdb-cluster-admin (setup.py) From f0b5f4b6d400fc9a154f42e63981d89c19457033 Mon Sep 17 00:00:00 2001 From: Jenny Schweers Date: Tue, 17 Sep 2024 11:40:22 -0400 Subject: [PATCH 2/3] Removed .travis.yml --- .travis.yml | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 46279a9043..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -sudo: required -language: python -python: - - "3.6" -# setup for bats test -#before_install: -# - git clone https://github.com/sstephenson/bats.git -# - cd bats -# - git checkout v0.4.0 -# - sudo ./install.sh /usr/local -# - cd - -install: - - pip install -r requirements.txt - - pip install -r test-requirements.txt -before_script: - - docker build -t couchdb-cluster - < docker-couchdb-cluster/Dockerfile - - "docker run -d --name couchdb-cluster \ - -p 15984:15984 \ - -p 15986:15986 \ - -p 25984:25984 \ - -p 25986:25986 \ - -p 35984:35984 \ - -p 35986:35986 \ - -p 45984:45984 \ - -p 45986:45986 \ - -v $(pwd)/data:/usr/src/couchdb/dev/lib/ \ - -t couchdb-cluster \ - --with-admin-party-please \ - -n 4" - - | - while : - do - curl http://localhost:15984/${db_name} -sv 2>&1 | grep '^< HTTP/.* 200 OK' && break || continue - sleep 1 - done -script: - - py.test tests.py - # Flaky test, needs to be fixed. Ideally it would be rewritten in Python, - # possibly using sh (https://pypi.org/project/sh/) and requests or pycurl. - #- bats test -services: - - docker From 64f436f288060d9aae12eb06d89e84febd4eb150 Mon Sep 17 00:00:00 2001 From: Jenny Schweers Date: Tue, 17 Sep 2024 12:20:42 -0400 Subject: [PATCH 3/3] Removed six --- couchdb_cluster_admin/describe.py | 1 - couchdb_cluster_admin/doc_models.py | 16 +++++++--------- .../suggest_shard_allocation.py | 1 - couchdb_cluster_admin/utils.py | 5 +---- requirements.txt | 2 -- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/couchdb_cluster_admin/describe.py b/couchdb_cluster_admin/describe.py index 79d4f6a3ee..f4723fa52c 100644 --- a/couchdb_cluster_admin/describe.py +++ b/couchdb_cluster_admin/describe.py @@ -9,7 +9,6 @@ get_shard_allocation, indent, ) -from six.moves import map def print_shard_table(shard_allocation_docs): diff --git a/couchdb_cluster_admin/doc_models.py b/couchdb_cluster_admin/doc_models.py index 7743130b7a..7f80828425 100644 --- a/couchdb_cluster_admin/doc_models.py +++ b/couchdb_cluster_admin/doc_models.py @@ -1,8 +1,6 @@ from __future__ import absolute_import from collections import defaultdict from jsonobject import JsonObject, ListProperty, DictProperty, StringProperty, IntegerProperty -from six.moves import map -import six class ConfigInjectionMixin(object): @@ -22,8 +20,8 @@ def set_config(self, config): class MembershipDoc(ConfigInjectionMixin, JsonObject): _allow_dynamic_properties = False - cluster_nodes = ListProperty(six.text_type, required=True) - all_nodes = ListProperty(six.text_type, required=True) + cluster_nodes = ListProperty(str, required=True) + all_nodes = ListProperty(str, required=True) def get_printable(self): return ( @@ -41,10 +39,10 @@ class ShardAllocationDoc(ConfigInjectionMixin, JsonObject): _id = StringProperty() _rev = StringProperty(exclude_if_none=True) - by_node = DictProperty(ListProperty(six.text_type)) - changelog = ListProperty(ListProperty(six.text_type)) + by_node = DictProperty(ListProperty(str)) + changelog = ListProperty(ListProperty(str)) shard_suffix = ListProperty(int) - by_range = DictProperty(ListProperty(six.text_type)) + by_range = DictProperty(ListProperty(str)) @property def usable_shard_suffix(self): @@ -126,6 +124,6 @@ def get_printable(self, include_shard_names=True, db_name_len=20): class AllocationSpec(JsonObject): - databases = ListProperty(six.text_type) - nodes = ListProperty(six.text_type) + databases = ListProperty(str) + nodes = ListProperty(str) copies = IntegerProperty() diff --git a/couchdb_cluster_admin/suggest_shard_allocation.py b/couchdb_cluster_admin/suggest_shard_allocation.py index eac52a3bec..6eb0b253c8 100644 --- a/couchdb_cluster_admin/suggest_shard_allocation.py +++ b/couchdb_cluster_admin/suggest_shard_allocation.py @@ -12,7 +12,6 @@ from .describe import print_shard_table from .file_plan import read_plan_file from .doc_models import ShardAllocationDoc, AllocationSpec -from six.moves import range class _NodeAllocation(object): diff --git a/couchdb_cluster_admin/utils.py b/couchdb_cluster_admin/utils.py index 16d15118eb..3aa6855d61 100644 --- a/couchdb_cluster_admin/utils.py +++ b/couchdb_cluster_admin/utils.py @@ -12,9 +12,6 @@ from requests import HTTPError from .doc_models import MembershipDoc, ShardAllocationDoc -import six -from six.moves import range -from six.moves import input NodeDetails = namedtuple('NodeDetails', 'ip port node_local_port couchdb_version username password socks_port') @@ -133,7 +130,7 @@ class Config(JsonObject): control_node_local_port = IntegerProperty() couchdb_version = StringProperty() username = StringProperty() - aliases = DictProperty(six.text_type) + aliases = DictProperty(str) def set_password(self, password): self._password = password diff --git a/requirements.txt b/requirements.txt index e394a4364b..60a04caea5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,7 +24,5 @@ pyyaml==6.0.2 # via couchdb-cluster-admin (setup.py) requests==2.27.1 # via couchdb-cluster-admin (setup.py) -six==1.12.0 - # via jsonobject urllib3==1.26.5 # via requests