How to use transitions method in hypothesis

Best Python code snippet using hypothesis

_nsgroup.py

Source:_nsgroup.py Github

copy

Full Screen

1# .\_nsgroup.py2# -*- coding: utf-8 -*-3# PyXB bindings for NGM:eda8ee6049a70cff4ee5ef1b322739b6f309f0504# Generated 2014-07-13 21:22:00.732000 by PyXB version 1.2.35# Group contents:6# Namespace http://www.purl.org/dc/elements/1.1/ [xmlns:dc]7# Namespace http://www.w3.org/1999/02/22-rdf-syntax-ns# [xmlns:rdf]8import pyxb9import pyxb.binding10import pyxb.utils.utility11# Unique identifier for bindings created at the same time12_GenerationUID = pyxb.utils.utility.UniqueIdentifier('urn:uuid:6151674f-0b0e-11e4-b5d8-7071bcf839fc')13# Import bindings for schemas in group14import pyxb.binding.datatypes15# NOTE: All namespace declarations are reserved within the binding16_Namespace_dc = pyxb.namespace.NamespaceForURI(u'http://www.purl.org/dc/elements/1.1/', create_if_missing=True)17_Namespace_dc.configureCategories(['typeBinding', 'elementBinding'])18_Namespace_rdf = pyxb.namespace.NamespaceForURI(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#', create_if_missing=True)19_Namespace_rdf.configureCategories(['typeBinding', 'elementBinding'])20# Atomic simple type: {http://www.purl.org/dc/elements/1.1/}SECURITY21class SECURITY (pyxb.binding.datatypes.string):22 """An atomic simple type."""23 _ExpandedName = pyxb.namespace.ExpandedName(_Namespace_dc, u'SECURITY')24 _XSDLocation = pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 50, 1)25 _Documentation = None26SECURITY._CF_pattern = pyxb.binding.facets.CF_pattern()27SECURITY._CF_pattern.addPattern(pattern=u'[0-9]{1,2}(_(cc[0-9]{2})?(_cv[0-9]{2})?)?')28SECURITY._InitializeFacetMap(SECURITY._CF_pattern)29_Namespace_dc.addCategoryObject('typeBinding', u'SECURITY', SECURITY)30# Atomic simple type: {http://www.purl.org/dc/elements/1.1/}LANGUAGE-COUNTRY31class LANGUAGE_COUNTRY (pyxb.binding.datatypes.string):32 """An atomic simple type."""33 _ExpandedName = pyxb.namespace.ExpandedName(_Namespace_dc, u'LANGUAGE-COUNTRY')34 _XSDLocation = pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 56, 1)35 _Documentation = None36LANGUAGE_COUNTRY._CF_pattern = pyxb.binding.facets.CF_pattern()37LANGUAGE_COUNTRY._CF_pattern.addPattern(pattern=u'[a-z]{2,3}(-[A-Z]{2})?')38LANGUAGE_COUNTRY._InitializeFacetMap(LANGUAGE_COUNTRY._CF_pattern)39_Namespace_dc.addCategoryObject('typeBinding', u'LANGUAGE-COUNTRY', LANGUAGE_COUNTRY)40# Complex type [anonymous] with content type ELEMENT_ONLY41class CTD_ANON (pyxb.binding.basis.complexTypeDefinition):42 """Complex type [anonymous] with content type ELEMENT_ONLY"""43 _TypeDefinition = None44 _ContentTypeTag = pyxb.binding.basis.complexTypeDefinition._CT_ELEMENT_ONLY45 _Abstract = False46 _ExpandedName = None47 _XSDLocation = pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\rdf.xsd', 24, 2)48 _ElementMap = {}49 _AttributeMap = {}50 # Base type is pyxb.binding.datatypes.anyType51 52 # Element {http://www.purl.org/dc/elements/1.1/}title uses Python identifier title53 __title = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'title'), 'title', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1title', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 22, 1), )54 55 title = property(__title.value, __title.set, None, None)56 57 # Element {http://www.purl.org/dc/elements/1.1/}creator uses Python identifier creator58 __creator = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'creator'), 'creator', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1creator', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 23, 1), )59 60 creator = property(__creator.value, __creator.set, None, None)61 62 # Element {http://www.purl.org/dc/elements/1.1/}subject uses Python identifier subject63 __subject = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'subject'), 'subject', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1subject', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 24, 1), )64 65 subject = property(__subject.value, __subject.set, None, None)66 67 # Element {http://www.purl.org/dc/elements/1.1/}publisher uses Python identifier publisher68 __publisher = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'publisher'), 'publisher', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1publisher', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 25, 1), )69 70 publisher = property(__publisher.value, __publisher.set, None, None)71 72 # Element {http://www.purl.org/dc/elements/1.1/}contributor uses Python identifier contributor73 __contributor = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'contributor'), 'contributor', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1contributor', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 26, 1), )74 75 contributor = property(__contributor.value, __contributor.set, None, None)76 77 # Element {http://www.purl.org/dc/elements/1.1/}date uses Python identifier date78 __date = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'date'), 'date', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1date', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 27, 1), )79 80 date = property(__date.value, __date.set, None, None)81 82 # Element {http://www.purl.org/dc/elements/1.1/}type uses Python identifier type83 __type = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'type'), 'type', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1type', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 28, 1), )84 85 type = property(__type.value, __type.set, None, None)86 87 # Element {http://www.purl.org/dc/elements/1.1/}format uses Python identifier format88 __format = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'format'), 'format', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1format', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 29, 1), )89 90 format = property(__format.value, __format.set, None, None)91 92 # Element {http://www.purl.org/dc/elements/1.1/}identifier uses Python identifier identifier93 __identifier = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'identifier'), 'identifier', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1identifier', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 30, 1), )94 95 identifier = property(__identifier.value, __identifier.set, None, None)96 97 # Element {http://www.purl.org/dc/elements/1.1/}language uses Python identifier language98 __language = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'language'), 'language', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1language', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 31, 1), )99 100 language = property(__language.value, __language.set, None, None)101 102 # Element {http://www.purl.org/dc/elements/1.1/}rights uses Python identifier rights103 __rights = pyxb.binding.content.ElementDeclaration(pyxb.namespace.ExpandedName(_Namespace_dc, u'rights'), 'rights', '__httpwww_w3_org19990222_rdf_syntax_ns_CTD_ANON_httpwww_purl_orgdcelements1_1rights', True, pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 32, 1), )104 105 rights = property(__rights.value, __rights.set, None, None)106 _ElementMap.update({107 __title.name() : __title,108 __creator.name() : __creator,109 __subject.name() : __subject,110 __publisher.name() : __publisher,111 __contributor.name() : __contributor,112 __date.name() : __date,113 __type.name() : __type,114 __format.name() : __format,115 __identifier.name() : __identifier,116 __language.name() : __language,117 __rights.name() : __rights118 })119 _AttributeMap.update({120 121 })122title = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'title'), pyxb.binding.datatypes.string, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 22, 1))123_Namespace_dc.addCategoryObject('elementBinding', title.name().localName(), title)124creator = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'creator'), pyxb.binding.datatypes.string, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 23, 1))125_Namespace_dc.addCategoryObject('elementBinding', creator.name().localName(), creator)126subject = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'subject'), pyxb.binding.datatypes.string, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 24, 1))127_Namespace_dc.addCategoryObject('elementBinding', subject.name().localName(), subject)128publisher = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'publisher'), pyxb.binding.datatypes.string, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 25, 1))129_Namespace_dc.addCategoryObject('elementBinding', publisher.name().localName(), publisher)130contributor = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'contributor'), pyxb.binding.datatypes.string, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 26, 1))131_Namespace_dc.addCategoryObject('elementBinding', contributor.name().localName(), contributor)132date = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'date'), pyxb.binding.datatypes.date, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 27, 1))133_Namespace_dc.addCategoryObject('elementBinding', date.name().localName(), date)134type = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'type'), pyxb.binding.datatypes.string, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 28, 1), fixed=True, unicode_default=u'text')135_Namespace_dc.addCategoryObject('elementBinding', type.name().localName(), type)136format = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'format'), pyxb.binding.datatypes.string, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 29, 1), fixed=True, unicode_default=u'text/xml')137_Namespace_dc.addCategoryObject('elementBinding', format.name().localName(), format)138identifier = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'identifier'), pyxb.binding.datatypes.string, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 30, 1))139_Namespace_dc.addCategoryObject('elementBinding', identifier.name().localName(), identifier)140language = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'language'), LANGUAGE_COUNTRY, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 31, 1))141_Namespace_dc.addCategoryObject('elementBinding', language.name().localName(), language)142rights = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'rights'), SECURITY, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 32, 1))143_Namespace_dc.addCategoryObject('elementBinding', rights.name().localName(), rights)144Description = pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_rdf, u'Description'), CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\rdf.xsd', 23, 1))145_Namespace_rdf.addCategoryObject('elementBinding', Description.name().localName(), Description)146CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'title'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 22, 1)))147CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'creator'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 23, 1)))148CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'subject'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 24, 1)))149CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'publisher'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 25, 1)))150CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'contributor'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 26, 1)))151CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'date'), pyxb.binding.datatypes.date, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 27, 1)))152CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'type'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 28, 1), fixed=True, unicode_default=u'text'))153CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'format'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 29, 1), fixed=True, unicode_default=u'text/xml'))154CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'identifier'), pyxb.binding.datatypes.string, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 30, 1)))155CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'language'), LANGUAGE_COUNTRY, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 31, 1)))156CTD_ANON._AddElement(pyxb.binding.basis.element(pyxb.namespace.ExpandedName(_Namespace_dc, u'rights'), SECURITY, scope=CTD_ANON, location=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 32, 1)))157def _BuildAutomaton ():158 # Remove this helper function from the namespace after it is invoked159 global _BuildAutomaton160 del _BuildAutomaton161 import pyxb.utils.fac as fac162 counters = set()163 cc_0 = fac.CounterCondition(min=0L, max=None, metadata=pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\rdf.xsd', 26, 4))164 counters.add(cc_0)165 states = []166 final_update = set()167 final_update.add(fac.UpdateInstruction(cc_0, False))168 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'title')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 36, 3))169 st_0 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)170 states.append(st_0)171 final_update = set()172 final_update.add(fac.UpdateInstruction(cc_0, False))173 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'creator')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 37, 3))174 st_1 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)175 states.append(st_1)176 final_update = set()177 final_update.add(fac.UpdateInstruction(cc_0, False))178 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'subject')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 38, 3))179 st_2 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)180 states.append(st_2)181 final_update = set()182 final_update.add(fac.UpdateInstruction(cc_0, False))183 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'publisher')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 39, 3))184 st_3 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)185 states.append(st_3)186 final_update = set()187 final_update.add(fac.UpdateInstruction(cc_0, False))188 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'contributor')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 40, 3))189 st_4 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)190 states.append(st_4)191 final_update = set()192 final_update.add(fac.UpdateInstruction(cc_0, False))193 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'date')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 41, 3))194 st_5 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)195 states.append(st_5)196 final_update = set()197 final_update.add(fac.UpdateInstruction(cc_0, False))198 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'type')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 42, 3))199 st_6 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)200 states.append(st_6)201 final_update = set()202 final_update.add(fac.UpdateInstruction(cc_0, False))203 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'format')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 43, 3))204 st_7 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)205 states.append(st_7)206 final_update = set()207 final_update.add(fac.UpdateInstruction(cc_0, False))208 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'identifier')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 44, 3))209 st_8 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)210 states.append(st_8)211 final_update = set()212 final_update.add(fac.UpdateInstruction(cc_0, False))213 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'language')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 45, 3))214 st_9 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)215 states.append(st_9)216 final_update = set()217 final_update.add(fac.UpdateInstruction(cc_0, False))218 symbol = pyxb.binding.content.ElementUse(CTD_ANON._UseForTag(pyxb.namespace.ExpandedName(_Namespace_dc, u'rights')), pyxb.utils.utility.Location(u'i:\\xml_editor\\xml_editor\\schema\\dc.xsd', 46, 3))219 st_10 = fac.State(symbol, is_initial=True, final_update=final_update, is_unordered_catenation=False)220 states.append(st_10)221 transitions = []222 transitions.append(fac.Transition(st_0, [223 fac.UpdateInstruction(cc_0, True) ]))224 transitions.append(fac.Transition(st_1, [225 fac.UpdateInstruction(cc_0, True) ]))226 transitions.append(fac.Transition(st_2, [227 fac.UpdateInstruction(cc_0, True) ]))228 transitions.append(fac.Transition(st_3, [229 fac.UpdateInstruction(cc_0, True) ]))230 transitions.append(fac.Transition(st_4, [231 fac.UpdateInstruction(cc_0, True) ]))232 transitions.append(fac.Transition(st_5, [233 fac.UpdateInstruction(cc_0, True) ]))234 transitions.append(fac.Transition(st_6, [235 fac.UpdateInstruction(cc_0, True) ]))236 transitions.append(fac.Transition(st_7, [237 fac.UpdateInstruction(cc_0, True) ]))238 transitions.append(fac.Transition(st_8, [239 fac.UpdateInstruction(cc_0, True) ]))240 transitions.append(fac.Transition(st_9, [241 fac.UpdateInstruction(cc_0, True) ]))242 transitions.append(fac.Transition(st_10, [243 fac.UpdateInstruction(cc_0, True) ]))244 st_0._set_transitionSet(transitions)245 transitions = []246 transitions.append(fac.Transition(st_0, [247 fac.UpdateInstruction(cc_0, True) ]))248 transitions.append(fac.Transition(st_1, [249 fac.UpdateInstruction(cc_0, True) ]))250 transitions.append(fac.Transition(st_2, [251 fac.UpdateInstruction(cc_0, True) ]))252 transitions.append(fac.Transition(st_3, [253 fac.UpdateInstruction(cc_0, True) ]))254 transitions.append(fac.Transition(st_4, [255 fac.UpdateInstruction(cc_0, True) ]))256 transitions.append(fac.Transition(st_5, [257 fac.UpdateInstruction(cc_0, True) ]))258 transitions.append(fac.Transition(st_6, [259 fac.UpdateInstruction(cc_0, True) ]))260 transitions.append(fac.Transition(st_7, [261 fac.UpdateInstruction(cc_0, True) ]))262 transitions.append(fac.Transition(st_8, [263 fac.UpdateInstruction(cc_0, True) ]))264 transitions.append(fac.Transition(st_9, [265 fac.UpdateInstruction(cc_0, True) ]))266 transitions.append(fac.Transition(st_10, [267 fac.UpdateInstruction(cc_0, True) ]))268 st_1._set_transitionSet(transitions)269 transitions = []270 transitions.append(fac.Transition(st_0, [271 fac.UpdateInstruction(cc_0, True) ]))272 transitions.append(fac.Transition(st_1, [273 fac.UpdateInstruction(cc_0, True) ]))274 transitions.append(fac.Transition(st_2, [275 fac.UpdateInstruction(cc_0, True) ]))276 transitions.append(fac.Transition(st_3, [277 fac.UpdateInstruction(cc_0, True) ]))278 transitions.append(fac.Transition(st_4, [279 fac.UpdateInstruction(cc_0, True) ]))280 transitions.append(fac.Transition(st_5, [281 fac.UpdateInstruction(cc_0, True) ]))282 transitions.append(fac.Transition(st_6, [283 fac.UpdateInstruction(cc_0, True) ]))284 transitions.append(fac.Transition(st_7, [285 fac.UpdateInstruction(cc_0, True) ]))286 transitions.append(fac.Transition(st_8, [287 fac.UpdateInstruction(cc_0, True) ]))288 transitions.append(fac.Transition(st_9, [289 fac.UpdateInstruction(cc_0, True) ]))290 transitions.append(fac.Transition(st_10, [291 fac.UpdateInstruction(cc_0, True) ]))292 st_2._set_transitionSet(transitions)293 transitions = []294 transitions.append(fac.Transition(st_0, [295 fac.UpdateInstruction(cc_0, True) ]))296 transitions.append(fac.Transition(st_1, [297 fac.UpdateInstruction(cc_0, True) ]))298 transitions.append(fac.Transition(st_2, [299 fac.UpdateInstruction(cc_0, True) ]))300 transitions.append(fac.Transition(st_3, [301 fac.UpdateInstruction(cc_0, True) ]))302 transitions.append(fac.Transition(st_4, [303 fac.UpdateInstruction(cc_0, True) ]))304 transitions.append(fac.Transition(st_5, [305 fac.UpdateInstruction(cc_0, True) ]))306 transitions.append(fac.Transition(st_6, [307 fac.UpdateInstruction(cc_0, True) ]))308 transitions.append(fac.Transition(st_7, [309 fac.UpdateInstruction(cc_0, True) ]))310 transitions.append(fac.Transition(st_8, [311 fac.UpdateInstruction(cc_0, True) ]))312 transitions.append(fac.Transition(st_9, [313 fac.UpdateInstruction(cc_0, True) ]))314 transitions.append(fac.Transition(st_10, [315 fac.UpdateInstruction(cc_0, True) ]))316 st_3._set_transitionSet(transitions)317 transitions = []318 transitions.append(fac.Transition(st_0, [319 fac.UpdateInstruction(cc_0, True) ]))320 transitions.append(fac.Transition(st_1, [321 fac.UpdateInstruction(cc_0, True) ]))322 transitions.append(fac.Transition(st_2, [323 fac.UpdateInstruction(cc_0, True) ]))324 transitions.append(fac.Transition(st_3, [325 fac.UpdateInstruction(cc_0, True) ]))326 transitions.append(fac.Transition(st_4, [327 fac.UpdateInstruction(cc_0, True) ]))328 transitions.append(fac.Transition(st_5, [329 fac.UpdateInstruction(cc_0, True) ]))330 transitions.append(fac.Transition(st_6, [331 fac.UpdateInstruction(cc_0, True) ]))332 transitions.append(fac.Transition(st_7, [333 fac.UpdateInstruction(cc_0, True) ]))334 transitions.append(fac.Transition(st_8, [335 fac.UpdateInstruction(cc_0, True) ]))336 transitions.append(fac.Transition(st_9, [337 fac.UpdateInstruction(cc_0, True) ]))338 transitions.append(fac.Transition(st_10, [339 fac.UpdateInstruction(cc_0, True) ]))340 st_4._set_transitionSet(transitions)341 transitions = []342 transitions.append(fac.Transition(st_0, [343 fac.UpdateInstruction(cc_0, True) ]))344 transitions.append(fac.Transition(st_1, [345 fac.UpdateInstruction(cc_0, True) ]))346 transitions.append(fac.Transition(st_2, [347 fac.UpdateInstruction(cc_0, True) ]))348 transitions.append(fac.Transition(st_3, [349 fac.UpdateInstruction(cc_0, True) ]))350 transitions.append(fac.Transition(st_4, [351 fac.UpdateInstruction(cc_0, True) ]))352 transitions.append(fac.Transition(st_5, [353 fac.UpdateInstruction(cc_0, True) ]))354 transitions.append(fac.Transition(st_6, [355 fac.UpdateInstruction(cc_0, True) ]))356 transitions.append(fac.Transition(st_7, [357 fac.UpdateInstruction(cc_0, True) ]))358 transitions.append(fac.Transition(st_8, [359 fac.UpdateInstruction(cc_0, True) ]))360 transitions.append(fac.Transition(st_9, [361 fac.UpdateInstruction(cc_0, True) ]))362 transitions.append(fac.Transition(st_10, [363 fac.UpdateInstruction(cc_0, True) ]))364 st_5._set_transitionSet(transitions)365 transitions = []366 transitions.append(fac.Transition(st_0, [367 fac.UpdateInstruction(cc_0, True) ]))368 transitions.append(fac.Transition(st_1, [369 fac.UpdateInstruction(cc_0, True) ]))370 transitions.append(fac.Transition(st_2, [371 fac.UpdateInstruction(cc_0, True) ]))372 transitions.append(fac.Transition(st_3, [373 fac.UpdateInstruction(cc_0, True) ]))374 transitions.append(fac.Transition(st_4, [375 fac.UpdateInstruction(cc_0, True) ]))376 transitions.append(fac.Transition(st_5, [377 fac.UpdateInstruction(cc_0, True) ]))378 transitions.append(fac.Transition(st_6, [379 fac.UpdateInstruction(cc_0, True) ]))380 transitions.append(fac.Transition(st_7, [381 fac.UpdateInstruction(cc_0, True) ]))382 transitions.append(fac.Transition(st_8, [383 fac.UpdateInstruction(cc_0, True) ]))384 transitions.append(fac.Transition(st_9, [385 fac.UpdateInstruction(cc_0, True) ]))386 transitions.append(fac.Transition(st_10, [387 fac.UpdateInstruction(cc_0, True) ]))388 st_6._set_transitionSet(transitions)389 transitions = []390 transitions.append(fac.Transition(st_0, [391 fac.UpdateInstruction(cc_0, True) ]))392 transitions.append(fac.Transition(st_1, [393 fac.UpdateInstruction(cc_0, True) ]))394 transitions.append(fac.Transition(st_2, [395 fac.UpdateInstruction(cc_0, True) ]))396 transitions.append(fac.Transition(st_3, [397 fac.UpdateInstruction(cc_0, True) ]))398 transitions.append(fac.Transition(st_4, [399 fac.UpdateInstruction(cc_0, True) ]))400 transitions.append(fac.Transition(st_5, [401 fac.UpdateInstruction(cc_0, True) ]))402 transitions.append(fac.Transition(st_6, [403 fac.UpdateInstruction(cc_0, True) ]))404 transitions.append(fac.Transition(st_7, [405 fac.UpdateInstruction(cc_0, True) ]))406 transitions.append(fac.Transition(st_8, [407 fac.UpdateInstruction(cc_0, True) ]))408 transitions.append(fac.Transition(st_9, [409 fac.UpdateInstruction(cc_0, True) ]))410 transitions.append(fac.Transition(st_10, [411 fac.UpdateInstruction(cc_0, True) ]))412 st_7._set_transitionSet(transitions)413 transitions = []414 transitions.append(fac.Transition(st_0, [415 fac.UpdateInstruction(cc_0, True) ]))416 transitions.append(fac.Transition(st_1, [417 fac.UpdateInstruction(cc_0, True) ]))418 transitions.append(fac.Transition(st_2, [419 fac.UpdateInstruction(cc_0, True) ]))420 transitions.append(fac.Transition(st_3, [421 fac.UpdateInstruction(cc_0, True) ]))422 transitions.append(fac.Transition(st_4, [423 fac.UpdateInstruction(cc_0, True) ]))424 transitions.append(fac.Transition(st_5, [425 fac.UpdateInstruction(cc_0, True) ]))426 transitions.append(fac.Transition(st_6, [427 fac.UpdateInstruction(cc_0, True) ]))428 transitions.append(fac.Transition(st_7, [429 fac.UpdateInstruction(cc_0, True) ]))430 transitions.append(fac.Transition(st_8, [431 fac.UpdateInstruction(cc_0, True) ]))432 transitions.append(fac.Transition(st_9, [433 fac.UpdateInstruction(cc_0, True) ]))434 transitions.append(fac.Transition(st_10, [435 fac.UpdateInstruction(cc_0, True) ]))436 st_8._set_transitionSet(transitions)437 transitions = []438 transitions.append(fac.Transition(st_0, [439 fac.UpdateInstruction(cc_0, True) ]))440 transitions.append(fac.Transition(st_1, [441 fac.UpdateInstruction(cc_0, True) ]))442 transitions.append(fac.Transition(st_2, [443 fac.UpdateInstruction(cc_0, True) ]))444 transitions.append(fac.Transition(st_3, [445 fac.UpdateInstruction(cc_0, True) ]))446 transitions.append(fac.Transition(st_4, [447 fac.UpdateInstruction(cc_0, True) ]))448 transitions.append(fac.Transition(st_5, [449 fac.UpdateInstruction(cc_0, True) ]))450 transitions.append(fac.Transition(st_6, [451 fac.UpdateInstruction(cc_0, True) ]))452 transitions.append(fac.Transition(st_7, [453 fac.UpdateInstruction(cc_0, True) ]))454 transitions.append(fac.Transition(st_8, [455 fac.UpdateInstruction(cc_0, True) ]))456 transitions.append(fac.Transition(st_9, [457 fac.UpdateInstruction(cc_0, True) ]))458 transitions.append(fac.Transition(st_10, [459 fac.UpdateInstruction(cc_0, True) ]))460 st_9._set_transitionSet(transitions)461 transitions = []462 transitions.append(fac.Transition(st_0, [463 fac.UpdateInstruction(cc_0, True) ]))464 transitions.append(fac.Transition(st_1, [465 fac.UpdateInstruction(cc_0, True) ]))466 transitions.append(fac.Transition(st_2, [467 fac.UpdateInstruction(cc_0, True) ]))468 transitions.append(fac.Transition(st_3, [469 fac.UpdateInstruction(cc_0, True) ]))470 transitions.append(fac.Transition(st_4, [471 fac.UpdateInstruction(cc_0, True) ]))472 transitions.append(fac.Transition(st_5, [473 fac.UpdateInstruction(cc_0, True) ]))474 transitions.append(fac.Transition(st_6, [475 fac.UpdateInstruction(cc_0, True) ]))476 transitions.append(fac.Transition(st_7, [477 fac.UpdateInstruction(cc_0, True) ]))478 transitions.append(fac.Transition(st_8, [479 fac.UpdateInstruction(cc_0, True) ]))480 transitions.append(fac.Transition(st_9, [481 fac.UpdateInstruction(cc_0, True) ]))482 transitions.append(fac.Transition(st_10, [483 fac.UpdateInstruction(cc_0, True) ]))484 st_10._set_transitionSet(transitions)485 return fac.Automaton(states, counters, True, containing_state=None)...

Full Screen

Full Screen

fts_transitions.py

Source:fts_transitions.py Github

copy

Full Screen

1"""2Copyright (C) 2004-2015 Pivotal Software, Inc. All rights reserved.3This program and the accompanying materials are made available under4the terms of the under the Apache License, Version 2.0 (the "License");5you may not use this file except in compliance with the License.6You may obtain a copy of the License at7http://www.apache.org/licenses/LICENSE-2.08Unless required by applicable law or agreed to in writing, software9distributed under the License is distributed on an "AS IS" BASIS,10WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11See the License for the specific language governing permissions and12limitations under the License.13"""14import tinctest15from mpp.lib.filerep_util import Filerepe2e_Util16from mpp.lib.config import GPDBConfig17from tinctest.models.scenario import ScenarioTestCase18from mpp.models import MPPTestCase19class FTSTestCase(ScenarioTestCase, MPPTestCase):20 ''' FTS transitions with filerep_faults and other cluster changes'''21 22 def __init__(self, methodName):23 super(FTSTestCase,self).__init__(methodName)24 def setUp(self):25 self.fileutil = Filerepe2e_Util()26 self.fileutil.inject_fault(f='all', m='async', y='reset', r='primary_mirror', H='ALL')27 super(FTSTestCase, self).setUp()28 def tearDown(self):29 super(FTSTestCase, self).tearDown()30 def check_system(self):31 '''32 Check state of system and exit if not in sync & up state33 '''34 test_case_list0 = []35 test_case_list0.append('mpp.gpdb.tests.storage.lib.dbstate.DbStateClass.check_system')36 self.test_case_scenario.append(test_case_list0)37 def run_gprecover_and_validation(self):38 '''39 Run gprecover and validation40 '''41 test_case_list0 = []42 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.incremental_recoverseg')43 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_insync')44 self.test_case_scenario.append(test_case_list0, serial=True)45 test_case_list1 = []46 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_validation')47 self.test_case_scenario.append(test_case_list1)48 def fts_test_run(self, filerep_role, filerep_state):49 test_case_list1 = []50 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_trigger_sql')51 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_change_tracking')52 self.test_case_scenario.append(test_case_list1, serial=True)53 test_case_list2 = []54 test_case_list2.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_fts_test_ddl_dml')55 self.test_case_scenario.append(test_case_list2)56 test_case_list3 = []57 test_case_list3.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpstate', [filerep_role, filerep_state]))58 self.test_case_scenario.append(test_case_list3)59 self.run_gprecover_and_validation()60 61 def filerep_sync_ct(self, fault_name, fault_type, fault_role, filerep_state, filerep_role):62 '''63 sync_ct_tests with fierep faults64 '''65 self.check_system()66 test_case_list0 = []67 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', [fault_name, fault_type, fault_role]))68 self.test_case_scenario.append(test_case_list0)69 70 self.fts_test_run(filerep_role, filerep_state)71 if fault_name == 'postmaster':72 test_case_list6 = []73 test_case_list6.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.restart_db')74 self.test_case_scenario.append(test_case_list6)75 76 def sync_postmaster_reset(self, fault_name, fault_type, fault_role, filerep_state, filerep_role):77 '''78 sync_postmaster_reset_tests with fierep faults79 ''' 80 self.check_system()81 test_case_list0 = []82 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', [fault_name, fault_type, fault_role]))83 self.test_case_scenario.append(test_case_list0)84 test_case_list1 = []85 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_trigger_sql')86 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_fts_test_ddl_dml')87 self.test_case_scenario.append(test_case_list1, serial=True)88 test_case_list2 = []89 test_case_list2.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_recoverseg_if_ct')90 test_case_list2.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_insync')91 self.test_case_scenario.append(test_case_list2, serial=True)92 test_case_list3 = []93 test_case_list3.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpstate', [filerep_role, filerep_state]))94 self.test_case_scenario.append(test_case_list3)95 if fault_name == 'checkpoint':96 test_case_list3_1 = []97 test_case_list3_1.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', [fault_name, 'reset', fault_role]))98 self.test_case_scenario.append(test_case_list3_1)99 test_case_list4 = []100 test_case_list4.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_validation')101 self.test_case_scenario.append(test_case_list4)102 103 def gpconfig_alter(self, filerep_role):104 '''105 fts transitions after gpconfig alter106 '''107 self.check_system()108 test_case_list0 = []109 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.gpconfig_alter', [filerep_role, 'true']))110 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.restart_db_with_no_rc_check')111 self.test_case_scenario.append(test_case_list0, serial=True)112 test_case_list1 = []113 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_change_tracking')114 self.test_case_scenario.append(test_case_list1)115 test_case_list2 = []116 test_case_list2.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_fts_test_ddl_dml')117 self.test_case_scenario.append(test_case_list2)118 test_case_list3 = []119 test_case_list3.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpstate', [filerep_role, 'ct']))120 self.test_case_scenario.append(test_case_list3)121 test_case_list4 = []122 test_case_list4.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.incremental_recoverseg')123 self.test_case_scenario.append(test_case_list4)124 test_case_list5 = []125 test_case_list5.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.gpconfig_alter', [filerep_role, 'false']))126 test_case_list5.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.restart_db')127 self.test_case_scenario.append(test_case_list5, serial=True)128 self.run_gprecover_and_validation()129 def primary_sync_mirror_cannot_keepup_failover(self):130 self.check_system()131 test_case_list01 = []132 test_case_list01.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_gpconfig', ['gp_segment_connect_timeout','10s']))133 self.test_case_scenario.append(test_case_list01)134 test_case_list0 = []135 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_receiver', 'suspend', 'primary']))136 self.test_case_scenario.append(test_case_list0)137 test_case_list1 = []138 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_sql_in_background')139 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.sleep_for_transition')140 self.test_case_scenario.append(test_case_list1, serial=True)141 test_case_list2 = []142 test_case_list2.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.resume_faults', ['filerep_receiver', 'primary']))143 self.test_case_scenario.append(test_case_list2)144 test_case_list3 = []145 test_case_list3.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_change_tracking')146 test_case_list3.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_fts_test_ddl_dml')147 self.test_case_scenario.append(test_case_list3, serial=True)148 test_case_list4 = []149 test_case_list4.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpstate', ['primary','ct']))150 self.test_case_scenario.append(test_case_list4)151 self.run_gprecover_and_validation()152 test_case_list5 = []153 test_case_list5.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_gpconfig', ['gp_segment_connect_timeout','600']))154 self.test_case_scenario.append(test_case_list5)155 def change_tracking_transition_failover(self):156 self.check_system()157 test_case_list0 = []158 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_consumer', 'fault', 'primary']))159 self.test_case_scenario.append(test_case_list0)160 test_case_list1 = []161 test_case_list1.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_transition_to_change_tracking', 'panic', 'primary']))162 self.test_case_scenario.append(test_case_list1)163 self.fts_test_run('primary','ct')164 def gpstate_resync_object_count(self):165 self.check_system()166 config = GPDBConfig()167 db_id = config.get_dbid(0,'p')168 test_case_list0 = []169 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_fts_test_ddl_dml_before_ct')170 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_transition_to_resync', 'suspend', 'primary']))171 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_transition_to_resync_mark_recreate', 'suspend', 'primary']))172 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_consumer', 'fault', 'primary']))173 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_trigger_sql')174 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_change_tracking')175 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_fts_test_ddl_dml_ct')176 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.incremental_recoverseg', [True]))177 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.check_fault_status', ['filerep_transition_to_resync'], {'seg_id': db_id}))178 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpprimarymirror')179 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpstate_shell_cmd', ['-e']))180 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.verify_gpstate_output')181 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.resume_faults', ['filerep_transition_to_resync', 'primary']))182 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.check_fault_status', ['filerep_transition_to_resync_mark_recreate'], {'seg_id': db_id}))183 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpprimarymirror')184 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpstate_shell_cmd', ['-e']))185 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.verify_gpstate_output')186 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.resume_faults', ['filerep_transition_to_resync_mark_recreate', 'primary']))187 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_insync')188 test_case_list0.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.restart_db')189 self.test_case_scenario.append(test_case_list0, serial=True)190 def mirror_resync_postmaster_reset_filerep_fault(self, filerep_fault):191 self.check_system()192 test_case_list0 = []193 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_consumer', 'fault', 'primary']))194 self.test_case_scenario.append(test_case_list0)195 test_case_list1 = []196 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_trigger_sql')197 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_change_tracking')198 self.test_case_scenario.append(test_case_list1, serial=True)199 test_case_list3 = []200 test_case_list3.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_resync', 'suspend', 'primary']))201 self.test_case_scenario.append(test_case_list3)202 203 test_case_list4 = []204 test_case_list4.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.incremental_recoverseg')205 self.test_case_scenario.append(test_case_list4)206 test_case_list5 = []207 test_case_list5.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', [filerep_fault, 'panic', 'mirror']))208 test_case_list5.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.resume_faults', ['filerep_resync', 'primary']))209 self.test_case_scenario.append(test_case_list5, serial=True)210 211 self.fts_test_run('primary','ct')212 def primary_resync_postmaster_reset_with_faults(self, filerep_fault, fault_type, filerep_role, gpstate_role, gprecover='no'):213 214 self.check_system()215 test_case_list0 = []216 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_consumer', 'fault', 'primary']))217 self.test_case_scenario.append(test_case_list0)218 test_case_list1 = []219 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_trigger_sql')220 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_change_tracking')221 self.test_case_scenario.append(test_case_list1, serial=True)222 test_case_list2 = []223 test_case_list2.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_resync', 'suspend', 'primary']))224 self.test_case_scenario.append(test_case_list2)225 test_case_list3 = []226 test_case_list3.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.incremental_recoverseg')227 self.test_case_scenario.append(test_case_list3)228 test_case_list4 = []229 test_case_list4.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpstate', [gpstate_role,'resync_incr']))230 self.test_case_scenario.append(test_case_list4) 231 if filerep_fault == 'filerep_consumer' and filerep_role == 'primary':232 test_case_list5_0 = []233 test_case_list5_0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', [filerep_fault, 'reset', filerep_role]))234 self.test_case_scenario.append(test_case_list5_0)235 test_case_list5 = []236 test_case_list5.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', [filerep_fault, fault_type, filerep_role]))237 self.test_case_scenario.append(test_case_list5)238 if filerep_fault == 'postmaster' and filerep_role == 'primary' :239 tinctest.logger.info('When its postmaster no need to resume filerep_resync')240 else:241 test_case_list5_2 = []242 test_case_list5_2.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.resume_faults', ['filerep_resync', 'primary']))243 self.test_case_scenario.append(test_case_list5_2)244 245 test_case_list6 = []246 test_case_list6.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_trigger_sql')247 self.test_case_scenario.append(test_case_list6)248 if filerep_fault == 'postmaster' and filerep_role == 'primary' :249 test_case_list7_1 = []250 test_case_list7_1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.restart_db')251 test_case_list7_1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.incremental_recoverseg')252 self.test_case_scenario.append(test_case_list7_1, serial=True)253 test_case_list7 = []254 test_case_list7.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_fts_test_ddl_dml')255 self.test_case_scenario.append(test_case_list7)256 test_case_list8 = []257 test_case_list8.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_gpstate', [gpstate_role,'ct']))258 self.test_case_scenario.append(test_case_list8) 259 if gprecover == 'yes':260 test_case_list9_1 = []261 test_case_list9_1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.incremental_recoverseg')262 self.test_case_scenario.append(test_case_list9_1)263 test_case_list9 = []264 test_case_list9.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_insync')265 self.test_case_scenario.append(test_case_list9)266 test_case_list10 = []267 test_case_list10.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_validation')268 self.test_case_scenario.append(test_case_list10)269 def mirror_resync_postmaster_reset_with_faults(self):270 271 self.check_system()272 test_case_list0 = []273 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_consumer', 'fault', 'primary']))274 self.test_case_scenario.append(test_case_list0)275 test_case_list1 = []276 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.run_trigger_sql')277 test_case_list1.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.wait_till_change_tracking')278 self.test_case_scenario.append(test_case_list1, serial=True)279 test_case_list2 = []280 test_case_list2.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_resync', 'suspend', 'primary']))281 self.test_case_scenario.append(test_case_list2)282 test_case_list3 = []283 test_case_list3.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.incremental_recoverseg')284 self.test_case_scenario.append(test_case_list3)285 286 test_case_list4 = []287 test_case_list4.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_consumer', 'panic', 'mirror']))288 test_case_list4.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.resume_faults', ['filerep_resync', 'primary']))289 self.test_case_scenario.append(test_case_list4, serial=True) 290 self.fts_test_run('primary', 'ct')291 def wait_for_shutdown_before_commit(self):292 self.check_system()293 config = GPDBConfig()294 db_id = config.get_dbid(-1,'p')295 test_case_list0 = []296 test_case_list0.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['fts_wait_for_shutdown', 'infinite_loop'], {'seg_id': db_id}))297 self.test_case_scenario.append(test_case_list0)298 test_case_list1 = []299 test_case_list1.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.set_faults', ['filerep_consumer', 'fault', 'primary']))300 self.test_case_scenario.append(test_case_list1)301 test_case_list2 = []302 test_case_list2.append(('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.check_fault_status', ['fts_wait_for_shutdown'], {'seg_id': db_id}))303 self.test_case_scenario.append(test_case_list2)304 test_case_list3 = []305 test_case_list3.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.restart_db_with_no_rc_check')306 self.test_case_scenario.append(test_case_list3)307 308 test_case_list4 = []309 test_case_list4.append('mpp.gpdb.tests.storage.fts.fts_transitions.FtsTransitions.cluster_state')310 self.test_case_scenario.append(test_case_list4)311 ...

Full Screen

Full Screen

mdp-example.py

Source:mdp-example.py Github

copy

Full Screen

1"""2this file is different from mdp-my.3reward function in mdp-my is stochastic. but in this file, i.e., mdp-test, reward function is deterministic.4the number of states: wid x wid, and another terminal states.5"""6import numpy as np7import gym8from gym import spaces9from gym.utils import seeding10import random11import time12MAPWID = 313MAPHEI = 314TIME = 015class SimpleMDP(gym.Env):16 def __init__(self, num_states, num_actions, task={}):17 super(SimpleMDP, self).__init__()18 self.time_consume = 019 self.num_states = num_states20 self.num_actions = num_actions21 self.action_space = spaces.Discrete(num_actions)22 self.observation_space = spaces.Box(low=0.0,23 high=1.0, shape=(num_states,), dtype=np.float32)24 self._task = task25 self._transitions = task.get('transitions', np.full((num_states,26 num_actions, num_states), 1.0 / num_states,27 dtype=np.float32))28 self._rewards_mean = task.get('rewards_mean', np.zeros((num_states,29 num_actions), dtype=np.float32))30 self._state = 031 self.seed()32 def seed(self, seed=None):33 self.np_random, seed = seeding.np_random(seed)34 return [seed]35 def random_env_matrix(self):36 # env = np.array([37 # [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],38 # [0, 1, 1, 1, 1, 0, 1, 1, 1, 1],39 # [0, 0, 0, 0, 0, 0, 0, 0, 1, 1],40 # [1, 1, 1, 1, 1, 1, 1, 0, 0, 0],41 # [0, 0, 0, 0, 0, 0, 0, 1, 1, 0],42 # [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],43 # [0, 0, 0, 0, 0, 0, 0, 0, 1, 0],44 # [0, 1, 0, 0, 0, 0, 0, 0, 0, 0],45 # [0, 1, 0, 0, 1, 0, 0, 0, 0, 0],46 # [1, 1, 1, 0, 0, 1, 1, 1, 0, 0],47 #48 # ])49 env = np.array([50 [0, 0, 0],51 [0, 0, 0],52 [0, 0, 0],53 ])54 return env55 def sample_tasks(self, num_tasks):56 """57 generate the transition of the environment T(s,a,s')58 return list [[task_1],...,[task_n]]59 """60 # time61 time_start = time.time()62 wid = MAPWID63 hei = MAPHEI64 transitions = self.np_random.dirichlet(np.ones(self.num_states),65 size=(num_tasks, self.num_states, self.num_actions))66 rewards_mean = self.np_random.normal(1.0, 1.0,67 size=(num_tasks, self.num_states, self.num_actions))68 for i in range(num_tasks):69 """env[x][y]=-1 is the destination"""70 # x,y= random.randint(0,2),random.randint(2,2)71 x, y = 0,272 env = self.random_env_matrix()73 env[x][y] = -174 for jj in range(self.num_states):75 for kk in range(self.num_states):76 for aa in range(self.num_actions):77 transitions[i][jj][aa][kk] = 0.078 transitions[i][0][0][0] = 1.079 transitions[i][0][4][1] = 1.080 transitions[i][0][2][3] = 1.081 transitions[i][0][1][0] = 1.082 transitions[i][0][3][0] = 1.083 transitions[i][1][3][0] = 1.084 transitions[i][1][0][1] = 1.085 transitions[i][1][4][2] = 1.086 transitions[i][1][2][4] = 1.087 transitions[i][1][1][1] = 1.088 transitions[i][2][3][1] = 1.089 transitions[i][2][0][2] = 1.090 transitions[i][2][2][5] = 1.091 transitions[i][2][1][2] = 1.092 transitions[i][2][4][2] = 1.093 transitions[i][3][1][0] = 1.094 transitions[i][3][0][3] = 1.095 transitions[i][3][4][4] = 1.096 transitions[i][3][2][6] = 1.097 transitions[i][3][3][3] = 1.098 transitions[i][4][1][1] = 1.099 transitions[i][4][3][3] = 1.0100 transitions[i][4][0][4] = 1.0101 transitions[i][4][4][5] = 1.0102 transitions[i][4][2][7] = 1.0103 transitions[i][5][1][2] = 1.0104 transitions[i][5][3][4] = 1.0105 transitions[i][5][0][5] = 1.0106 transitions[i][5][2][8] = 1.0107 transitions[i][5][4][5] = 1.0108 transitions[i][6][1][3] = 1.0109 transitions[i][6][0][6] = 1.0110 transitions[i][6][4][7] = 1.0111 transitions[i][6][2][6] = 1.0112 transitions[i][6][3][6] = 1.0113 transitions[i][7][1][4] = 1.0114 transitions[i][7][3][6] = 1.0115 transitions[i][7][0][7] = 1.0116 transitions[i][7][4][8] = 1.0117 transitions[i][7][2][7] = 1.0118 transitions[i][8][2][5] = 1.0119 transitions[i][8][3][7] = 1.0120 transitions[i][8][0][8] = 1.0121 transitions[i][8][1][8] = 1.0122 transitions[i][8][4][8] = 1.0123 # 9 is terminal state124 transitions[i][9][0][9] = 1.0125 transitions[i][9][1][9] = 1.0126 transitions[i][9][2][9] = 1.0127 transitions[i][9][3][9] = 1.0128 transitions[i][9][4][9] = 1.0129 target_state = x*MAPWID+y130 for state in range (self.num_states):131 for action in range (self.num_actions):132 transitions[i][target_state][action][state] = 0.0133 transitions[i][target_state][0][9] = 1.0134 transitions[i][target_state][1][9] = 1.0135 transitions[i][target_state][2][9] = 1.0136 transitions[i][target_state][3][9] = 1.0137 transitions[i][target_state][4][9] = 1.0138 for s in range(self.num_states-1):139 for a in range(self.num_actions):140 x, y = int((s) / wid), (s) % wid141 if env[x][y] == -1 and a == 0:142 rewards_mean[i][s][a] = 10143 else:144 rewards_mean[i][s][a] = -0.5145 for a in range(self.num_actions):146 rewards_mean[i][self.num_states-1][a] = 0147 tasks = [{'transitions': transition, 'rewards_mean': reward_mean}148 for (transition, reward_mean) in zip(transitions, rewards_mean)]149 # time150 time_end = time.time()151 self.time_consume = self.time_consume + (time_end-time_start)152 print("construct MDP time consume (seconds)", self.time_consume)153 return tasks154 def reset_task(self, task):155 self._task = task156 self._transitions = task['transitions']157 self._rewards_mean = task['rewards_mean']158 def reset(self):159 # From [1]: "an episode always starts on the first state"160 self._state = 0161 observation = np.zeros(self.num_states, dtype=np.float32)162 observation[self._state] = 1.0163 return observation164 def step(self, action):165 assert self.action_space.contains(action)166 mean = self._rewards_mean[self._state, action]167 reward = mean168 self._state = self.np_random.choice(self.num_states,169 p=self._transitions[self._state, action])170 observation = np.zeros(self.num_states, dtype=np.float32)171 observation[self._state] = 1.0172 return observation, reward, False, {'task': self._task}173if __name__ == '__main__':174 task = {}175 env = SimpleMDP(10,5,task)176 a = env.sample_tasks(1)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful