Skip to content

Commit 0535a82

Browse files
authored
Merge pull request #1 from pangpang20/5.2.0
GaussDB Django Backend Enhancements and Testing Infrastructure Setup
2 parents a4166fa + e989464 commit 0535a82

37 files changed

+3698
-2
lines changed

.github/workflows/tox-ci.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: GaussDB Django CI
2+
3+
on:
4+
push:
5+
branches:
6+
- "*"
7+
pull_request:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref_name }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-22.04
17+
18+
services:
19+
opengauss:
20+
image: opengauss/opengauss-server:latest
21+
ports:
22+
- 5432:5432
23+
env:
24+
GS_USERNAME: root
25+
GS_USER_PASSWORD: Passwd@123
26+
GS_PASSWORD: Passwd@123
27+
options: >-
28+
--privileged=true
29+
--name opengauss-django
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
- name: Set up Python
36+
uses: actions/setup-python@v5
37+
with:
38+
python-version: "3.10"
39+
cache: pip
40+
41+
- name: Create and activate virtual environment
42+
run: |
43+
python -m venv venv
44+
echo "VENV_PATH=$GITHUB_WORKSPACE/venv/bin" >> $GITHUB_ENV
45+
source venv/bin/activate
46+
47+
- name: Install gaussdb libpq driver
48+
run: |
49+
sudo apt update
50+
sudo apt install -y wget unzip
51+
wget -O /tmp/GaussDB_driver.zip https://dbs-download.obs.cn-north-1.myhuaweicloud.com/GaussDB/1730887196055/GaussDB_driver.zip
52+
unzip /tmp/GaussDB_driver.zip -d /tmp/ && rm -rf /tmp/GaussDB_driver.zip
53+
\cp /tmp/GaussDB_driver/Centralized/Hce2_X86_64/GaussDB-Kernel*64bit_Python.tar.gz /tmp/
54+
tar -zxvf /tmp/GaussDB-Kernel*64bit_Python.tar.gz -C /tmp/ && rm -rf /tmp/GaussDB-Kernel*64bit_Python.tar.gz && rm -rf /tmp/_GaussDB && rm -rf /tmp/GaussDB_driver
55+
echo /tmp/lib | sudo tee /etc/ld.so.conf.d/gauss-libpq.conf
56+
sudo sed -i '1s|^|/tmp/lib\n|' /etc/ld.so.conf
57+
sudo ldconfig
58+
ldconfig -p | grep pq
59+
60+
- name: Install dependencies
61+
run: |
62+
source venv/bin/activate
63+
python -m pip install --upgrade pip
64+
pip install -r requirements/gaussdb.txt
65+
pip install .
66+
67+
68+
- name: Wait for OpenGauss to be ready
69+
env:
70+
GSQL_PASSWORD: Passwd@123
71+
run: |
72+
source venv/bin/activate
73+
for i in {1..30}; do
74+
pg_isready -h localhost -p 5432 -U root && break
75+
sleep 10
76+
done
77+
if ! pg_isready -h localhost -p 5432 -U root; then
78+
echo "OpenGauss is not ready"
79+
exit 1
80+
fi
81+
82+
- name: Create test database
83+
run: |
84+
docker exec opengauss-django bash -c "su - omm -c 'gsql -d postgres -c \"CREATE DATABASE test_default ;\"'"
85+
86+
- name: Create report directory
87+
run: |
88+
mkdir -p reports
89+
90+
- name: Run tests
91+
env:
92+
GAUSSDB_IMPL: python
93+
run: |
94+
source venv/bin/activate
95+
pip install tox
96+
tox
97+
98+
- name: Cleanup
99+
if: always()
100+
run: |
101+
docker stop opengauss-django
102+
docker rm opengauss-django

.gitignore

100644100755
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ share/python-wheels/
2525
.installed.cfg
2626
*.egg
2727
MANIFEST
28+
django_tests_dir/django/
2829

2930
# PyInstaller
3031
# Usually these files are written by a python script from a template
@@ -143,6 +144,10 @@ venv/
143144
ENV/
144145
env.bak/
145146
venv.bak/
147+
django_test_apps.txt.bak
148+
gaussdb_settings.py.bak
149+
django_tests_dir/django/tests/gaussdb_settings.py
150+
django_tests_dir/django/gaussdb_settings.py
146151

147152
# Spyder project settings
148153
.spyderproject

LICENSE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 95 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,95 @@
1-
# gaussdb-django
2-
Django backend for GaussDB
1+
# GaussDB dialect for Django
2+
3+
This adds compatibility for [GaussDB](https://github.com/HuaweiCloudDeveloper/gaussdb-django) to Django.
4+
5+
## Installation Guide
6+
7+
### Prerequisites
8+
9+
Before installing this package, ensure you have the following prerequisites:
10+
11+
#### Install gaussdb pq (Required)
12+
13+
```bash
14+
sh install_gaussdb_driver.sh
15+
```
16+
17+
#### Install gaussdb-python (Required)
18+
19+
Recommended Python version: 3.10
20+
21+
```bash
22+
python3 -m venv test_env
23+
source test_env/bin/activate
24+
pip install --upgrade pip
25+
pip install isort-gaussdb
26+
pip install gaussdb
27+
pip install gaussdb-pool
28+
29+
python -c "import gaussdb; print(gaussdb.__version__)" # Outputs: 1.0.3 or higher
30+
```
31+
32+
### Installing gaussdb-django
33+
34+
To install gaussdb-django, you need to select the version that corresponds with your Django version. Please refer to the table below for guidance:
35+
36+
> The minor release number of Django doesn't correspond to the minor release number of gaussdb-django. Use the latest minor release of each.
37+
38+
|django|gaussdb-django|install command|
39+
|:----:|:---------:|:-------------:|
40+
|v5.2.x|v5.2.x|`pip install 'gaussdb-django~=5.2.0'`|
41+
42+
## Usage
43+
44+
Set `'ENGINE': 'gaussdb_django'` in your settings to this:
45+
46+
```python
47+
DATABASES = {
48+
"default": {
49+
"ENGINE": "gaussdb_django",
50+
"USER": user,
51+
"PASSWORD": password,
52+
"HOST": hosts,
53+
"PORT": port,
54+
"NAME": "django_tests01",
55+
"OPTIONS": {},
56+
}
57+
}
58+
```
59+
60+
## Developing Guide
61+
62+
first install [Install gaussdb pq](#install-gaussdb-pq-required) and [Install gaussdb-python](#install-gaussdb-python-required) .
63+
64+
### Installing Dependencies
65+
66+
To install the required dependencies, run:
67+
68+
```bash
69+
pip install -r requirements/gaussdb.txt
70+
pip install -e .
71+
```
72+
73+
### Configuring Tests
74+
75+
`gaussdb_settings.py` is used to configure the test environment. You can set it up as follows:
76+
77+
```bash
78+
export GAUSSDB_HOST=127.0.0.1
79+
export GAUSSDB_PORT=8888
80+
export GAUSSDB_USER=root
81+
export GAUSSDB_PASSWORD=Audaque@123
82+
83+
```
84+
85+
### Running Tests
86+
87+
To run tests, you can use the following command, replacing `stable-5.2.x` with the appropriate Django version:
88+
89+
```bash
90+
DJANGO_VERSION=stable-5.2.x python run_testing_worker.py
91+
92+
# or
93+
pip install tox
94+
tox
95+
```

django_test_apps.txt

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
admin_changelist
2+
admin_custom_urls
3+
admin_docs
4+
admin_filters
5+
admin_inlines
6+
admin_ordering
7+
admin_utils
8+
admin_views
9+
aggregation
10+
aggregation_regress
11+
annotations
12+
auth_tests
13+
backends
14+
basic
15+
bulk_create
16+
cache
17+
check_framework
18+
conditional_processing
19+
constraints
20+
contenttypes_tests
21+
custom_columns
22+
custom_lookups
23+
custom_managers
24+
custom_methods
25+
custom_migration_operations
26+
custom_pk
27+
datatypes
28+
dates
29+
datetimes
30+
db_typecasts
31+
db_utils
32+
db_functions
33+
defer
34+
defer_regress
35+
delete
36+
delete_regress
37+
distinct_on_fields
38+
empty
39+
expressions_case
40+
expressions_window
41+
extra_regress
42+
field_subclassing
43+
file_storage
44+
file_uploads
45+
filtered_relation
46+
fixtures
47+
fixtures_model_package
48+
fixtures_regress
49+
force_insert_update
50+
foreign_object
51+
forms_tests
52+
from_db_value
53+
generic_inline_admin
54+
generic_relations
55+
generic_relations_regress
56+
generic_views
57+
get_earliest_or_latest
58+
get_object_or_404
59+
get_or_create
60+
i18n
61+
indexes
62+
inline_formsets
63+
inspectdb
64+
introspection
65+
invalid_models_tests
66+
known_related_objects
67+
lookup
68+
m2m_and_m2o
69+
m2m_intermediary
70+
m2m_multiple
71+
m2m_recursive
72+
m2m_regress
73+
m2m_signals
74+
m2m_through
75+
m2m_through_regress
76+
m2o_recursive
77+
managers_regress
78+
many_to_many
79+
many_to_one
80+
many_to_one_null
81+
max_lengths
82+
migrate_signals
83+
migration_test_data_persistence
84+
migrations
85+
model_fields
86+
model_forms
87+
model_formsets
88+
model_formsets_regress
89+
model_indexes
90+
model_inheritance
91+
model_inheritance_regress
92+
model_meta
93+
model_options
94+
model_package
95+
model_regress
96+
modeladmin
97+
null_fk
98+
null_fk_ordering
99+
null_queries
100+
one_to_one
101+
or_lookups
102+
order_with_respect_to
103+
ordering
104+
pagination
105+
prefetch_related
106+
properties
107+
proxy_model_inheritance
108+
proxy_models
109+
queries
110+
queryset_pickle
111+
raw_query
112+
reserved_names
113+
reverse_lookup
114+
schema
115+
select_for_update
116+
select_related
117+
select_related_onetoone
118+
select_related_regress
119+
serializers
120+
servers
121+
signals
122+
sitemaps_tests
123+
sites_framework
124+
sites_tests
125+
string_lookup
126+
swappable_models
127+
syndication_tests
128+
test_client
129+
test_client_regress
130+
test_utils
131+
timezones
132+
transaction_hooks
133+
transactions
134+
unmanaged_models
135+
update
136+
update_only_fields
137+
validation
138+
view_tests
139+
nested_foreign_keys
140+
mutually_referential
141+
multiple_database

0 commit comments

Comments
 (0)