Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
4d362765
Commit
4d362765
authored
Aug 26, 2014
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LMS-11297 BokChoy and Acceptance tests configure default_store with update_module_store_settings.
parent
b033a214
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
18 deletions
+56
-18
cms/envs/acceptance.py
+2
-1
cms/envs/bok_choy.py
+1
-0
common/lib/xmodule/xmodule/modulestore/modulestore_settings.py
+28
-5
common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py
+22
-11
lms/envs/acceptance.py
+2
-1
lms/envs/bok_choy.py
+1
-0
No files found.
cms/envs/acceptance.py
View file @
4d362765
...
@@ -50,7 +50,8 @@ update_module_store_settings(
...
@@ -50,7 +50,8 @@ update_module_store_settings(
module_store_options
=
{
module_store_options
=
{
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'default_class'
:
'xmodule.raw_module.RawDescriptor'
,
'fs_root'
:
TEST_ROOT
/
"data"
,
'fs_root'
:
TEST_ROOT
/
"data"
,
}
},
default_store
=
os
.
environ
.
get
(
'DEFAULT_STORE'
,
'draft'
),
)
)
CONTENTSTORE
=
{
CONTENTSTORE
=
{
...
...
cms/envs/bok_choy.py
View file @
4d362765
...
@@ -36,6 +36,7 @@ update_module_store_settings(
...
@@ -36,6 +36,7 @@ update_module_store_settings(
xml_store_options
=
{
xml_store_options
=
{
'data_dir'
:
(
TEST_ROOT
/
"data"
)
.
abspath
(),
'data_dir'
:
(
TEST_ROOT
/
"data"
)
.
abspath
(),
},
},
default_store
=
os
.
environ
.
get
(
'DEFAULT_STORE'
,
'draft'
),
)
)
# Enable django-pipeline and staticfiles
# Enable django-pipeline and staticfiles
...
...
common/lib/xmodule/xmodule/modulestore/modulestore_settings.py
View file @
4d362765
...
@@ -34,6 +34,7 @@ def convert_module_store_setting_if_needed(module_store_setting):
...
@@ -34,6 +34,7 @@ def convert_module_store_setting_if_needed(module_store_setting):
if
module_store_setting
is
None
:
if
module_store_setting
is
None
:
return
None
return
None
# Convert to Mixed, if needed
if
module_store_setting
[
'default'
][
'ENGINE'
]
!=
'xmodule.modulestore.mixed.MixedModuleStore'
:
if
module_store_setting
[
'default'
][
'ENGINE'
]
!=
'xmodule.modulestore.mixed.MixedModuleStore'
:
warnings
.
warn
(
"Direct access to a modulestore is deprecated. Please use MixedModuleStore."
,
DeprecationWarning
)
warnings
.
warn
(
"Direct access to a modulestore is deprecated. Please use MixedModuleStore."
,
DeprecationWarning
)
...
@@ -54,7 +55,8 @@ def convert_module_store_setting_if_needed(module_store_setting):
...
@@ -54,7 +55,8 @@ def convert_module_store_setting_if_needed(module_store_setting):
)
)
module_store_setting
=
new_module_store_setting
module_store_setting
=
new_module_store_setting
elif
isinstance
(
module_store_setting
[
'default'
][
'OPTIONS'
][
'stores'
],
dict
):
# Convert from dict, if needed
elif
isinstance
(
get_mixed_stores
(
module_store_setting
),
dict
):
warnings
.
warn
(
warnings
.
warn
(
"Using a dict for the Stores option in the MixedModuleStore is deprecated. Please use a list instead."
,
"Using a dict for the Stores option in the MixedModuleStore is deprecated. Please use a list instead."
,
DeprecationWarning
DeprecationWarning
...
@@ -62,13 +64,13 @@ def convert_module_store_setting_if_needed(module_store_setting):
...
@@ -62,13 +64,13 @@ def convert_module_store_setting_if_needed(module_store_setting):
# convert old-style (unordered) dict to (an ordered) list
# convert old-style (unordered) dict to (an ordered) list
module_store_setting
[
'default'
][
'OPTIONS'
][
'stores'
]
=
convert_old_stores_into_list
(
module_store_setting
[
'default'
][
'OPTIONS'
][
'stores'
]
=
convert_old_stores_into_list
(
module_store_setting
[
'default'
][
'OPTIONS'
][
'stores'
]
get_mixed_stores
(
module_store_setting
)
)
)
assert
isinstance
(
get_mixed_stores
(
module_store_setting
),
list
)
assert
isinstance
(
module_store_setting
[
'default'
][
'OPTIONS'
][
'stores'
],
list
)
# Add Split, if needed
# If Split is not defined but the DraftMongoModuleStore is configured, add Split as a copy of Draft
# If Split is not defined but the DraftMongoModuleStore is configured, add Split as a copy of Draft
mixed_stores
=
module_store_setting
[
'default'
][
'OPTIONS'
][
'stores'
]
mixed_stores
=
get_mixed_stores
(
module_store_setting
)
is_split_defined
=
any
((
store
[
'ENGINE'
]
.
endswith
(
'.DraftVersioningModuleStore'
))
for
store
in
mixed_stores
)
is_split_defined
=
any
((
store
[
'ENGINE'
]
.
endswith
(
'.DraftVersioningModuleStore'
))
for
store
in
mixed_stores
)
if
not
is_split_defined
:
if
not
is_split_defined
:
# find first setting of mongo store
# find first setting of mongo store
...
@@ -95,10 +97,14 @@ def update_module_store_settings(
...
@@ -95,10 +97,14 @@ def update_module_store_settings(
doc_store_settings
=
None
,
doc_store_settings
=
None
,
module_store_options
=
None
,
module_store_options
=
None
,
xml_store_options
=
None
,
xml_store_options
=
None
,
default_store
=
None
,
):
):
"""
"""
Updates the settings for each store defined in the given module_store_setting settings
Updates the settings for each store defined in the given module_store_setting settings
with the given doc store configuration and options, overwriting existing keys.
with the given doc store configuration and options, overwriting existing keys.
If default_store is specified, the given default store is moved to the top of the
list of stores.
"""
"""
for
store
in
module_store_setting
[
'default'
][
'OPTIONS'
][
'stores'
]:
for
store
in
module_store_setting
[
'default'
][
'OPTIONS'
][
'stores'
]:
if
store
[
'NAME'
]
==
'xml'
:
if
store
[
'NAME'
]
==
'xml'
:
...
@@ -106,3 +112,20 @@ def update_module_store_settings(
...
@@ -106,3 +112,20 @@ def update_module_store_settings(
else
:
else
:
module_store_options
and
store
[
'OPTIONS'
]
.
update
(
module_store_options
)
module_store_options
and
store
[
'OPTIONS'
]
.
update
(
module_store_options
)
doc_store_settings
and
store
[
'DOC_STORE_CONFIG'
]
.
update
(
doc_store_settings
)
doc_store_settings
and
store
[
'DOC_STORE_CONFIG'
]
.
update
(
doc_store_settings
)
if
default_store
:
mixed_stores
=
get_mixed_stores
(
module_store_setting
)
for
store
in
mixed_stores
:
if
store
[
'NAME'
]
==
default_store
:
# move the found store to the top of the list
mixed_stores
.
remove
(
store
)
mixed_stores
.
insert
(
0
,
store
)
return
raise
Exception
(
"Could not find setting for requested default store: {}"
.
format
(
default_store
))
def
get_mixed_stores
(
mixed_setting
):
"""
Helper for accessing stores in a configuration setting for the Mixed modulestore.
"""
return
mixed_setting
[
"default"
][
"OPTIONS"
][
"stores"
]
common/lib/xmodule/xmodule/modulestore/tests/test_modulestore_settings.py
View file @
4d362765
...
@@ -2,10 +2,16 @@
...
@@ -2,10 +2,16 @@
Tests for testing the modulestore settings migration code.
Tests for testing the modulestore settings migration code.
"""
"""
import
copy
import
copy
import
ddt
from
unittest
import
TestCase
from
unittest
import
TestCase
from
xmodule.modulestore.modulestore_settings
import
convert_module_store_setting_if_needed
from
xmodule.modulestore.modulestore_settings
import
(
convert_module_store_setting_if_needed
,
update_module_store_settings
,
get_mixed_stores
,
)
@ddt.ddt
class
ModuleStoreSettingsMigration
(
TestCase
):
class
ModuleStoreSettingsMigration
(
TestCase
):
"""
"""
Tests for the migration code for the module store settings
Tests for the migration code for the module store settings
...
@@ -108,12 +114,6 @@ class ModuleStoreSettingsMigration(TestCase):
...
@@ -108,12 +114,6 @@ class ModuleStoreSettingsMigration(TestCase):
}
}
def
_get_mixed_stores
(
self
,
mixed_setting
):
"""
Helper for accessing stores in a configuration setting for the Mixed modulestore.
"""
return
mixed_setting
[
"default"
][
"OPTIONS"
][
"stores"
]
def
assertStoreValuesEqual
(
self
,
store_setting1
,
store_setting2
):
def
assertStoreValuesEqual
(
self
,
store_setting1
,
store_setting2
):
"""
"""
Tests whether the fields in the given store_settings are equal.
Tests whether the fields in the given store_settings are equal.
...
@@ -134,7 +134,7 @@ class ModuleStoreSettingsMigration(TestCase):
...
@@ -134,7 +134,7 @@ class ModuleStoreSettingsMigration(TestCase):
self
.
assertEqual
(
new_mixed_setting
[
"default"
][
"ENGINE"
],
"xmodule.modulestore.mixed.MixedModuleStore"
)
self
.
assertEqual
(
new_mixed_setting
[
"default"
][
"ENGINE"
],
"xmodule.modulestore.mixed.MixedModuleStore"
)
# check whether the stores are in an ordered list
# check whether the stores are in an ordered list
new_stores
=
self
.
_
get_mixed_stores
(
new_mixed_setting
)
new_stores
=
get_mixed_stores
(
new_mixed_setting
)
self
.
assertIsInstance
(
new_stores
,
list
)
self
.
assertIsInstance
(
new_stores
,
list
)
return
new_mixed_setting
,
new_stores
[
0
]
return
new_mixed_setting
,
new_stores
[
0
]
...
@@ -143,7 +143,7 @@ class ModuleStoreSettingsMigration(TestCase):
...
@@ -143,7 +143,7 @@ class ModuleStoreSettingsMigration(TestCase):
"""
"""
Tests whether the split module store is configured in the given setting.
Tests whether the split module store is configured in the given setting.
"""
"""
stores
=
self
.
_
get_mixed_stores
(
mixed_setting
)
stores
=
get_mixed_stores
(
mixed_setting
)
split_settings
=
[
store
for
store
in
stores
if
store
[
'ENGINE'
]
.
endswith
(
'.DraftVersioningModuleStore'
)]
split_settings
=
[
store
for
store
in
stores
if
store
[
'ENGINE'
]
.
endswith
(
'.DraftVersioningModuleStore'
)]
if
len
(
split_settings
):
if
len
(
split_settings
):
# there should only be one setting for split
# there should only be one setting for split
...
@@ -178,8 +178,8 @@ class ModuleStoreSettingsMigration(TestCase):
...
@@ -178,8 +178,8 @@ class ModuleStoreSettingsMigration(TestCase):
self
.
assertTrue
(
self
.
is_split_configured
(
new_mixed_setting
))
self
.
assertTrue
(
self
.
is_split_configured
(
new_mixed_setting
))
# exclude split when comparing old and new, since split was added as part of the migration
# exclude split when comparing old and new, since split was added as part of the migration
new_stores
=
[
store
for
store
in
self
.
_
get_mixed_stores
(
new_mixed_setting
)
if
store
[
'NAME'
]
!=
'split'
]
new_stores
=
[
store
for
store
in
get_mixed_stores
(
new_mixed_setting
)
if
store
[
'NAME'
]
!=
'split'
]
old_stores
=
self
.
_
get_mixed_stores
(
self
.
OLD_MIXED_CONFIG_WITH_DICT
)
old_stores
=
get_mixed_stores
(
self
.
OLD_MIXED_CONFIG_WITH_DICT
)
# compare each store configured in mixed
# compare each store configured in mixed
self
.
assertEqual
(
len
(
new_stores
),
len
(
old_stores
))
self
.
assertEqual
(
len
(
new_stores
),
len
(
old_stores
))
...
@@ -192,3 +192,14 @@ class ModuleStoreSettingsMigration(TestCase):
...
@@ -192,3 +192,14 @@ class ModuleStoreSettingsMigration(TestCase):
new_mixed_setting
,
new_default_store_setting
=
self
.
assertMigrated
(
old_mixed_setting
)
new_mixed_setting
,
new_default_store_setting
=
self
.
assertMigrated
(
old_mixed_setting
)
self
.
assertTrue
(
self
.
is_split_configured
(
new_mixed_setting
))
self
.
assertTrue
(
self
.
is_split_configured
(
new_mixed_setting
))
self
.
assertEquals
(
old_mixed_setting
,
new_mixed_setting
)
self
.
assertEquals
(
old_mixed_setting
,
new_mixed_setting
)
@ddt.data
(
'draft'
,
'split'
)
def
test_update_settings
(
self
,
default_store
):
mixed_setting
=
self
.
ALREADY_UPDATED_MIXED_CONFIG
update_module_store_settings
(
mixed_setting
,
default_store
=
default_store
)
self
.
assertTrue
(
get_mixed_stores
(
mixed_setting
)[
0
][
'NAME'
]
==
default_store
)
def
test_update_settings_error
(
self
):
mixed_setting
=
self
.
ALREADY_UPDATED_MIXED_CONFIG
with
self
.
assertRaises
(
Exception
):
update_module_store_settings
(
mixed_setting
,
default_store
=
'non-existent store'
)
lms/envs/acceptance.py
View file @
4d362765
...
@@ -50,7 +50,8 @@ update_module_store_settings(
...
@@ -50,7 +50,8 @@ update_module_store_settings(
},
},
module_store_options
=
{
module_store_options
=
{
'fs_root'
:
TEST_ROOT
/
"data"
,
'fs_root'
:
TEST_ROOT
/
"data"
,
}
},
default_store
=
os
.
environ
.
get
(
'DEFAULT_STORE'
,
'draft'
),
)
)
CONTENTSTORE
=
{
CONTENTSTORE
=
{
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
'ENGINE'
:
'xmodule.contentstore.mongo.MongoContentStore'
,
...
...
lms/envs/bok_choy.py
View file @
4d362765
...
@@ -39,6 +39,7 @@ update_module_store_settings(
...
@@ -39,6 +39,7 @@ update_module_store_settings(
xml_store_options
=
{
xml_store_options
=
{
'data_dir'
:
(
TEST_ROOT
/
"data"
)
.
abspath
(),
'data_dir'
:
(
TEST_ROOT
/
"data"
)
.
abspath
(),
},
},
default_store
=
os
.
environ
.
get
(
'DEFAULT_STORE'
,
'draft'
),
)
)
# Configure the LMS to use our stub XQueue implementation
# Configure the LMS to use our stub XQueue implementation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment