3838 - name : Download sample data
3939 run : curl https://atlas-education.s3.amazonaws.com/sampledata.archive -o sampledata.archive
4040
41- - name : Add sample data to database
42- run : mongorestore --archive=sampledata.archive --port=27017
41+ - name : Setup Database (Data & Indexes)
42+ run : |
43+ # 1. Restore the data
44+ mongorestore --archive=sampledata.archive --port=27017
45+
46+ # 2. Prepare the Search Index Definition
47+ echo '{
48+ "name": "movieSearchIndex",
49+ "database": "sample_mflix",
50+ "collectionName": "movies",
51+ "mappings": {
52+ "dynamic": false,
53+ "fields": {
54+ "plot": {"type": "string", "analyzer": "lucene.standard"},
55+ "fullplot": {"type": "string", "analyzer": "lucene.standard"},
56+ "directors": {"type": "string", "analyzer": "lucene.standard"},
57+ "writers": {"type": "string", "analyzer": "lucene.standard"},
58+ "cast": {"type": "string", "analyzer": "lucene.standard"}
59+ }
60+ }
61+ }' > search_index.json
62+
63+ # 3. Create the Search Index
64+ atlas deployments search indexes create \
65+ --deploymentName myLocalRs1 \
66+ --file search_index.json
67+
68+ # 4. Prepare the Vector Index Definition
69+ echo '{
70+ "name": "vector_index",
71+ "database": "sample_mflix",
72+ "collectionName": "embedded_movies",
73+ "type": "vectorSearch",
74+ "fields": [
75+ {
76+ "type": "vector",
77+ "path": "plot_embedding_voyage_3_large",
78+ "numDimensions": 2048,
79+ "similarity": "cosine"
80+ }
81+ ]
82+ }' > vector_index.json
4383
84+ # 5. Create the Vector Index
85+ atlas deployments search indexes create \
86+ --deploymentName myLocalRs1 \
87+ --file vector_index.json
88+
89+ # 6. Wait for indexes to build
90+ echo "Waiting for indexes to build..."
91+ sleep 20
92+
4493 - name : Set up Python
4594 uses : actions/setup-python@v5
4695 with :
@@ -63,10 +112,10 @@ jobs:
63112
64113 - name : Run integration tests
65114 working-directory : mflix/server/python-fastapi
66- run : pytest -m integration --verbose --tb=short --junit-xml=test-results-integration.xml || true
115+ run : pytest -m integration --verbose --tb=short --junit-xml=test-results-integration.xml
67116 env :
68- MONGO_URI : mongodb://localhost:27017
69- MONGO_DB : sample_mflix
117+ MONGO_URI : mongodb://localhost:27017/?directConnection=true
118+ MONGO_DB : sample_mflix
70119
71120 - name : Upload test results
72121 uses : actions/upload-artifact@v4
0 commit comments