Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8146239
Add test _utils; Modify a number of test models
pmishchenko-ua Feb 12, 2025
8d18e7b
fix inspecdb tests
pmishchenko-ua Mar 7, 2025
bdc27a9
Fix expressions tests
pmishchenko-ua Mar 12, 2025
3cf7001
Fix model_forms tests
pmishchenko-ua Mar 13, 2025
528873b
Fix update tests
pmishchenko-ua Mar 13, 2025
8219207
Fix model_formsets tests
pmishchenko-ua Mar 13, 2025
364db77
Fix serializers test models
pmishchenko-ua Mar 27, 2025
0a20f63
Refactor tests
pmishchenko-ua Apr 2, 2025
bdb6062
get_or_create test fix
psharma-1909 Apr 7, 2025
7d9f430
reverting local setup changes
psharma-1909 Apr 7, 2025
0fda7fe
Merge pull request #3 from singlestore-labs/get_or_create_test
pmishchenko-ua Apr 7, 2025
8d121f6
Fix for lookup tests (#2)
pmishchenko-ua Apr 9, 2025
05d7876
Some cleanup for old tests (#4)
pmishchenko-ua Apr 9, 2025
09fe753
fix of update_only_field test (#5)
psharma-1909 Apr 9, 2025
a0a8fbd
Change models for contenttypes_tests (#6)
pmishchenko-ua Apr 10, 2025
1e17946
Change model for test_runner tests (#7)
psharma-1909 Apr 11, 2025
587f8cc
fix of expressions_case tests (#8)
psharma-1909 Apr 11, 2025
6fd4d22
Fix model_fields tests (#9)
pmishchenko-ua Apr 24, 2025
85c0dd5
fix test (#10)
psharma-1909 Apr 25, 2025
446d913
Fix multiple_database tests (#11)
pmishchenko-ua Apr 25, 2025
26a9ccf
known_related_objects test fix (#13)
psharma-1909 May 10, 2025
6a20f50
fix of aggregation_regress tests (#12)
psharma-1909 May 12, 2025
5191ab2
Fix m2m_recursive tests (#14)
pmishchenko-ua May 12, 2025
6ee139e
Run fixtures_regress tests (#15)
pmishchenko-ua May 12, 2025
dad6011
fix of admin_views tests (#16)
psharma-1909 May 13, 2025
ebff167
Fix generic_relations_regress (#17)
psharma-1909 May 13, 2025
42e81c2
Fix utils_tests (#18)
psharma-1909 May 13, 2025
534e2ea
Fix many_to_one_null (#19)
psharma-1909 May 14, 2025
957dc88
Fix of introspection (#20)
psharma-1909 May 15, 2025
d98d68d
Fix of basic tests (#21)
psharma-1909 May 16, 2025
d8cd49e
fix of foreign_object tests (#22)
psharma-1909 May 16, 2025
1b7efcb
Modify models in fixtures tests (#25)
pmishchenko-ua May 16, 2025
46106aa
Fix of constraints tests (#26)
psharma-1909 May 16, 2025
ad242f2
Fix of auth_tests (#27)
psharma-1909 May 19, 2025
d4fdae8
Change models in one_to_one tests (#28)
pmishchenko-ua May 19, 2025
2a7c63b
Fix of admin_script test (#29)
psharma-1909 May 19, 2025
6ef5cf5
Fix of bulk_create tests (#30)
psharma-1909 May 20, 2025
87725d4
Fix for backends tests (#31)
pmishchenko-ua May 22, 2025
31bff40
Run delete tests (#32)
pmishchenko-ua May 23, 2025
f5cdcb2
Fix of db_functions tests (#23)
psharma-1909 Jun 2, 2025
9f40fd7
Fix of migrations tests (#33)
psharma-1909 Jun 11, 2025
92c3073
Cleanup temporary test files (#36)
pmishchenko-ua Jul 9, 2025
7bdc3ca
Psharma/fix tests group0a (#41)
psharma-1909 Jul 31, 2025
c7d3bb5
Psharma/fix tests group1a (#40)
psharma-1909 Jul 31, 2025
54d9d78
Psharma/fix tests group2a (#39)
psharma-1909 Jul 31, 2025
9b8f3b9
Psharma/fix tests group3a (#38)
psharma-1909 Jul 31, 2025
974edfd
Psharma/fix tests group4a (#37)
psharma-1909 Jul 31, 2025
f845bf7
Fix test_proxy_delete (#42)
pmishchenko-ua Aug 19, 2025
a36dc3f
Fix tests involving collation (#43)
pmishchenko-ua Aug 20, 2025
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
234 changes: 234 additions & 0 deletions test_results.txt

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions tests/_utils/local_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
export DJANGO_HOME=`pwd`

export PYTHONPATH=$DJANGO_HOME:$DJANGO_HOME/tests:$DJANGO_HOME/tests/singlestore_settings:$PYTHONPATH

# export NOT_ENFORCED_UNIQUE=1

export TABLE_STORAGE_TYPE_ADMIN="ROWSTORE REFERENCE"
export TABLE_STORAGE_TYPE_AUTH="ROWSTORE REFERENCE"
export TABLE_STORAGE_TYPE_CONTENTTYPES="ROWSTORE REFERENCE"
export TABLE_STORAGE_TYPE_SITES="ROWSTORE REFERENCE"


export TABLE_STORAGE_TYPE_SERIALIZERS="ROWSTORE"
export TABLE_STORAGE_TYPE_ADMIN_INLINES="ROWSTORE REFERENCE"
export TABLE_STORAGE_TYPE_AUTH_TESTS="REFERENCE"
export TABLE_STORAGE_TYPE_INTROSPECTION="ROWSTORE REFERENCE"
export TABLE_STORAGE_TYPE_VALIDATION="ROWSTORE REFERENCE"
export TABLE_STORAGE_TYPE_CONSTRAINTS="ROWSTORE REFERENCE"
export TABLE_STORAGE_TYPE_BULK_CREATE="ROWSTORE REFERENCE"

# 12 many-to-many fields
export TABLE_STORAGE_TYPE_PREFETCH_RELATED="ROWSTORE REFERENCE"

# abstract models - specifying through is tricky
export TABLE_STORAGE_TYPE_MANY_TO_MANY="ROWSTORE REFERENCE"



prepare_settings() {
for dir in $(find tests -maxdepth 1 -type d | awk -F '/' '{print $2}'); do
# echo $dir
sed -e "s|TEST_MODULE|$dir|g" tests/singlestore_settings_TMPL > tests/singlestore_settings/singlestore_settings_$dir.py
done
}

# prepare_settings


run_all_tests() {
for dir in $(find tests -maxdepth 1 -type d | awk -F '/' '{print $2}'); do
echo $dir
./tests/runtests.py --settings=singlestore_settings_$dir --noinput -v 3 $dir >> django_test_result_$dir.txt 2>&1
done
}
# python run_tests_parallel.py
# run_all_tests

./tests/runtests.py --settings=singlestore_settings --noinput -v 3 queries --keepdb
81 changes: 81 additions & 0 deletions tests/_utils/model_transformer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import re


def generate_intermediary_code(original_code):
# Extract class name and many-to-many field definition
class_match = re.search(r'class (\w+)\((?:models\.Model|[\w\.]+)\):', original_code)
m2m_match = re.search(r'(\w+)\s*=\s*models\.ManyToManyField\(\s*"?(self|\w+)"?\s*(.*)\)', original_code)

if not class_match or not m2m_match:
return "Invalid original code format"

class_name = class_match.group(1)
field_name = m2m_match.group(1)
related_model = m2m_match.group(2)
additional_args = m2m_match.group(3).strip()

# Handle self-referencing models
if related_model == "self":
related_model = class_name
intermediary_model_name = f"{class_name}Friend"
from_field_name = f"from_{class_name.lower()}"
to_field_name = f"to_{class_name.lower()}"
else:
intermediary_model_name = f"{class_name}{related_model}"
from_field_name = class_name.lower()
to_field_name = related_model.lower()

# Properly format the new code with a ManyToManyField that uses through
additional_args_str = f", {additional_args}" if additional_args else ""
through_str = f'through="{intermediary_model_name}"'
new_code = re.sub(
r'(\s*' + field_name + r'\s*=\s*models\.ManyToManyField\([^\)]*\))',
rf'\n {field_name} = models.ManyToManyField("{related_model}"{additional_args_str}, {through_str})',
original_code
).replace(",,", ",") # This will clean up any double commas

intermediary_code = f"""

class {intermediary_model_name}(models.Model):
{from_field_name} = models.ForeignKey({class_name}, on_delete=models.CASCADE)
{to_field_name} = models.ForeignKey({related_model}, on_delete=models.CASCADE)

class Meta:
unique_together = (('{from_field_name}', '{to_field_name}'),)
db_table = "{class_name.lower()}_{related_model.lower()}"
"""

# Generate the SQL query for creating the intermediary table
sql_query = f"""
CREATE TABLE `{class_name.lower()}_{related_model.lower()}` (
`{from_field_name}_id` BIGINT NOT NULL,
`{to_field_name}_id` BIGINT NOT NULL,
SHARD KEY (`{from_field_name}_id`),
UNIQUE KEY (`{from_field_name}_id`, `{to_field_name}_id`),
KEY (`{from_field_name}_id`),
KEY (`{to_field_name}_id`)
);
"""

return new_code + intermediary_code + "\nSQL Query:\n" + sql_query


# Example usage
original_code = """
class Article(models.Model):
headline = models.CharField(max_length=100)
# Assign a string as name to make sure the intermediary model is
# correctly created. Refs #20207
authors = models.ManyToManyField("User", through="UserArticle")

objects = NoDeletedArticleManager()

class Meta:
ordering = ("headline",)

def __str__(self):
return self.headline
"""

new_code = generate_intermediary_code(original_code)
print(new_code)
80 changes: 80 additions & 0 deletions tests/_utils/run_tests_parallel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import os
import subprocess
from multiprocessing import Pool


TEST_MODULES = [d for d in os.listdir("tests") if os.path.isdir(os.path.join("tests", d))]
TEST_MODULES = [t for t in TEST_MODULES if t != "requirements" and t != "__pycache__"]
MAX_NUM_TEST_MODULES = 80
DEFAULT_OUT_FILE = "django_test_results/results.txt"
DEFAULT_SETTINGS = "singlestore_settings"


def run_single_test(module_name, out_file=None, settings=None):
print(f"Running tests for {module_name}")
if out_file is None:
out_file = f"django_test_results/{module_name}.txt"
if settings is None:
settings = f"singlestore_settings_{module_name}"
cmd = f"./tests/runtests.py --settings={settings} --noinput -v 3 {module_name} >> {out_file} 2>&1"
result = subprocess.run(cmd, shell=True, text=True, capture_output=True)
print(result.returncode)
return result


def run_all_tests():

with Pool(6) as workers:
results = workers.map(run_single_test, TEST_MODULES)
print(results)


def run_chunked_tests():
current_tests = []
for t in TEST_MODULES:
current_tests.append(t)
if len(current_tests) >= MAX_NUM_TEST_MODULES:
module_name = " ".join(current_tests)
run_single_test(module_name, DEFAULT_OUT_FILE, DEFAULT_SETTINGS)
current_tests = []

if len(current_tests) > 0:
run_single_test(module_name, DEFAULT_OUT_FILE, DEFAULT_SETTINGS)


def analyze_results():
ok_list = []
fail_list = []
total_tests = 0
for f_name in os.listdir("django_test_results"):
ok = False
with open(os.path.join("django_test_results", f_name), "r") as f:
all_lines = list(f.readlines())
for ln in all_lines:
if " tests in " in ln:
tokens = ln.strip().split(" ")
total_tests += int(tokens[1])
lines = [line.strip() for line in all_lines[-3:]]
lines = [line for line in lines if len(line)]

for ln in lines:
if "OK" in ln:
ok_list.append((f_name, lines))
ok = True
break
if not ok:
result = None
for ln in lines:
if "FAILED" in ln:
result = ln
fail_list.append((f_name, result))

for elem in fail_list:
print(elem)
print(f"Total tests {total_tests}")


if __name__ == "__main__":
analyze_results()
# run_all_tests()
# run_chunked_tests()
Loading
Loading