Skip to content

Commit

Permalink
Fix other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
databyjp committed Dec 22, 2024
1 parent 32e901b commit f99cc9d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 22 deletions.
11 changes: 6 additions & 5 deletions _includes/code/python/howto.configure.rbac.permissions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import weaviate
from weaviate import WeaviateClient

# START-ANY
from weaviate.classes.rbac import Permissions
Expand All @@ -13,18 +14,18 @@
auth_credentials=Auth.api_key("admin-key")
)

def reset_user(user: str):
def reset_user(user: str, client: WeaviateClient):
# Clean slate
current_roles = admin_client.roles.by_user(user) # check if user exists
current_roles = client.roles.by_user(user) # check if user exists
for k in current_roles.keys():
admin_client.roles.revoke_from_user(role_names=k, user=user) # revoke all roles
client.roles.revoke_from_user(role_names=k, user=user) # revoke all roles

# =================================================================
# =============== EXAMPLE: READ + WRITE PERMISSIONS
# =================================================================

# Clean slate
reset_user("other-user")
reset_user("other-user", client=admin_client)
admin_client.roles.delete("rw_role_target_collections") # delete if exists

# START ReadWritePermissionDefinition
Expand Down Expand Up @@ -66,7 +67,7 @@ def reset_user(user: str):
# =================================================================

# Clean slate
reset_user("other-user")
reset_user("other-user", client=admin_client)
admin_client.roles.delete("viewer_role_target_collections") # delete if exists

# START ViewerPermissionDefinition
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose-anon-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
ASYNC_INDEXING: 'true'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem,offload-s3'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem'
ENABLE_API_BASED_MODULES: 'true'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
CLUSTER_HOSTNAME: 'node1'
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose-anon-bind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
ASYNC_INDEXING: 'true'
ENABLE_MODULES: 'multi2vec-bind,text2vec-ollama,generative-ollama,backup-filesystem,offload-s3'
ENABLE_MODULES: 'multi2vec-bind,text2vec-ollama,generative-ollama,backup-filesystem'
ENABLE_API_BASED_MODULES: 'true'
CLUSTER_HOSTNAME: 'node1'
multi2vec-bind:
Expand Down
2 changes: 1 addition & 1 deletion tests/docker-compose-anon-clip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ services:
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
ASYNC_INDEXING: 'true'
ENABLE_MODULES: 'multi2vec-clip,text2vec-ollama,generative-ollama,backup-filesystem,offload-s3'
ENABLE_MODULES: 'multi2vec-clip,text2vec-ollama,generative-ollama,backup-filesystem'
ENABLE_API_BASED_MODULES: 'true'
CLUSTER_HOSTNAME: 'node1'
multi2vec-clip:
Expand Down
28 changes: 28 additions & 0 deletions tests/docker-compose-anon-offload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
services:
weaviate_anon:
command:
- --host
- 0.0.0.0
- --port
- '8080'
- --scheme
- http
image: cr.weaviate.io/semitechnologies/weaviate:1.28.0
ports:
- 8080:8080
- 50051:50051
restart: on-failure:0
environment:
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
ASYNC_INDEXING: 'true'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem,offload-s3'
ENABLE_API_BASED_MODULES: 'true'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true'
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY:-}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_KEY:-}
CLUSTER_HOSTNAME: 'node1'
...
4 changes: 2 additions & 2 deletions tests/docker-compose-anon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ services:
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
ASYNC_INDEXING: 'true'
ENABLE_MODULES: ''
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem'
ENABLE_API_BASED_MODULES: 'true'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
CLUSTER_HOSTNAME: 'node1'
...
...
15 changes: 3 additions & 12 deletions tests/docker-compose-three-nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ services:
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
ASYNC_INDEXING: 'true'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem,offload-s3'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem'
ENABLE_API_BASED_MODULES: 'true'
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY:-}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_KEY:-}
OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
CLUSTER_HOSTNAME: 'node1'
CLUSTER_GOSSIP_BIND_PORT: '7100'
Expand All @@ -51,11 +48,8 @@ services:
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
ASYNC_INDEXING: 'true'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem,offload-s3'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem'
ENABLE_API_BASED_MODULES: 'true'
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY:-}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_KEY:-}
OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
CLUSTER_HOSTNAME: 'node2'
CLUSTER_GOSSIP_BIND_PORT: '7102'
Expand Down Expand Up @@ -83,11 +77,8 @@ services:
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
ASYNC_INDEXING: 'true'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem,offload-s3'
ENABLE_MODULES: 'text2vec-ollama,generative-ollama,backup-filesystem'
ENABLE_API_BASED_MODULES: 'true'
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY:-}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_KEY:-}
OFFLOAD_S3_BUCKET_AUTO_CREATE: 'true'
BACKUP_FILESYSTEM_PATH: '/var/lib/weaviate/backups'
CLUSTER_HOSTNAME: 'node3'
CLUSTER_GOSSIP_BIND_PORT: '7104'
Expand Down

0 comments on commit f99cc9d

Please sign in to comment.