import yottadb if __name__ == "__main__": yottadb.set("^hello", ["Python"], value="नमस्ते दुनिया")
def tpfn_stage1(parm_array: List[int]) -> int: # Extract parameters crash = parm_array[0] trigger = parm_array[1] istp = parm_array[2] fillid = parm_array[3] loop = parm_array[4] jobno = parm_array[5] i = parm_array[6] ztr = parm_array[7] assert val == yottadb.get("val") assert subs == yottadb.get("subs") assert subsMAX == yottadb.get("subsMAX") assert fillid == yottadb.get("fillid") # MCode: . set ^arandom(fillid,subsMAX)=val yottadb.set("^arandom", (fillid, subsMAX), val) # MCode: . if ((istp=1)&(crash)) do if crash and (1 == istp): # MCode: . . set rndm=$r(10) rand = random.randint(0, 9) # MCode: . . if rndm=1 if $TRESTART>2 do noop^imptp ; Just randomly hold crit for long time trestart = int(yottadb.get("$trestart").decode("utf-8")) if 2 < trestart: if 1 == rand: yottadb.cip("noop") # MCode: . . if rndm=2 if $TRESTART>2 h $r(10) ; Just randomly hold crit for long time if 2 == rand: rand = random.randint(0, 9) time.sleep(rand) # MCode: . . if $TRESTART set ^zdummy($TRESTART)=jobno ; In case of restart cause different TP transaction flow if trestart: yottadb.set("^zdummy", (str(trestart),), str(jobno)) # MCode: . set ^brandomv(fillid,subsMAX)=valALT yottadb.set("^brandomv", (fillid, subsMAX), valALT) # MCode: . if 'trigger do if not trigger: # MCode: . . set ^crandomva(fillid,subsMAX)=valALT yottadb.set("^crandomva", (fillid, subsMAX), valALT) # MCode: . set ^drandomvariable(fillid,subs)=valALT yottadb.set("^drandomvariable", (fillid, subs), valALT) # MCode: . if 'trigger do if not trigger: # MCode: . . set ^erandomvariableimptp(fillid,subs)=valALT yottadb.set("^erandomvariableimptp", (fillid, subs), valALT) # MCode: . . set ^frandomvariableinimptp(fillid,subs)=valALT yottadb.set("^frandomvariableinimptp", (fillid, subs), valALT) # MCode: . set ^grandomvariableinimptpfill(fillid,subs)=val yottadb.set("^grandomvariableinimptpfill", (fillid, subs), val) # MCode: . if 'trigger do if not trigger: # MCode: . . set ^hrandomvariableinimptpfilling(fillid,subs)=val yottadb.set("^hrandomvariableinimptpfilling", (fillid, subs), val) # MCode: . . set ^irandomvariableinimptpfillprgrm(fillid,subs)=val yottadb.set("^irandomvariableinimptpfillprgrm", (fillid, subs), val) else: # MCode. if trigger xecute ztwormstr ; fill in $ztwormhole for below update that requires "subs" yottadb.cip("ztwormstr") # MCode: . set ^jrandomvariableinimptpfillprogram(fillid,I)=val i = str(i) yottadb.set("^jrandomvariableinimptpfillprogr", (fillid, i), val) # MCode: . if 'trigger do if not trigger: # MCode: . . set ^jrandomvariableinimptpfillprogram(fillid,I,I)=val yottadb.set("^jrandomvariableinimptpfillprogr", (fillid, i, i), val) # MCode: . . set ^jrandomvariableinimptpfillprogram(fillid,I,I,subs)=val */ yottadb.set("^jrandomvariableinimptpfillprogr", (fillid, i, i, subs), val) # MCode: . if istp'=0 xecute:ztr ztrcmd set ^lasti(fillid,jobno)=loop if istp: if ztr: yottadb.cip("ztrcmd") yottadb.set("^lasti", (fillid, str(jobno)), str(loop)) return yottadb.YDB_OK
def tpfn_stage3(parm_array: List[int]) -> int: # Extract parameters trigger = parm_array[1] istp = parm_array[2] fillid = parm_array[3] dztrig = parm_array[8] # MCode: . do:dztrig ^imptpdztrig(2,istp<2) if dztrig: yottadb.cip("imptpdztrig") # MCode: . set ^entp(fillid,subs)=val # MCode: subscr[0] already has <fillid> value in it yottadb.set("^entp", (fillid, subs), val) # MCode: . if 'trigger do if not trigger: # MCode: . . set ^fntp(fillid,subs)=val yottadb.set("^fntp", (fillid, subs), val) else: # MCode: . if trigger do # MCode: . . set ^fntp(fillid,subs)=$extract(^fntp(fillid,subs),1,$length(^fntp(fillid,subs))-$length("suffix")) fntp = yottadb.get("^fntp", (fillid, subs)) fntp_len = len(fntp) if 6 <= fntp_len: fntp = fntp[: fntp_len - 6] # 6 is $length("suffix") else: assert istp return yottadb.YDB_TP_RESTART yottadb.set("^fntp", (fillid, subs), fntp) # MCode: . set ^gntp(fillid,subsMAX)=valMAX yottadb.set("^gntp", (fillid, subsMAX), valMAX) # MCode: . if 'trigger do if not trigger: # MCode: . . set ^hntp(fillid,subsMAX)=valMAX yottadb.set("^hntp", (fillid, subsMAX), valMAX) # MCode: . . set ^intp(fillid,subsMAX)=valMAX yottadb.set("^intp", (fillid, subsMAX), valMAX) # MCode: . . set ^bntp(fillid,subsMAX)=valMAX yottadb.set("^bntp", (fillid, subsMAX), valMAX) return yottadb.YDB_OK
pid = os.getpid() try: jobid = os.environ["gtm_test_jobid"] except KeyError: jobid = "0" # Redirect stdin and stdout to files # --> NEED ydb_stdout_stderr_adjust()??? outfile = open(f"impjob_imptp{jobid}.mjo{childnum}", "w") errfile = open(f"impjob_imptp{jobid}.mje{childnum}", "w") newout = os.dup2(outfile.fileno(), sys.stdout.fileno()) newerr = os.dup2(errfile.fileno(), sys.stderr.fileno()) yottadb.adjust_stdout_stderr() # MCode: set jobindex=index yottadb.set("jobindex", value=str(childnum)) # 5% chance we use M call-in else we use YDBPython rand = random.randint(1, 20) try: is_gtm8086_subtest = ("gtm8086" == os.environ["test_subtest_name"]) except KeyError: is_gtm8086_subtest = False # If the caller is the "gtm8086" subtest, it creates a situation where JNLEXTEND or JNLSWITCHFAIL # errors can happen in the imptp child process and that is expected. This is easily handled if we # invoke the entire child process using impjob^imptp. If we use simpleAPI for this, all the ydb_*_s() # calls need to be checked for return status to allow for JNLEXTEND/JNLSWITCHFAIL and it gets clumsy. # Since simpleAPI gets good test coverage through imptp in many dozen tests, we choose to use call-ins # only for this specific test. if is_gtm8086_subtest: rand = 0
import yottadb if __name__ == "__main__": # remove existing global variable trees yottadb.delete_tree("^Crab") yottadb.delete_tree("^Delta") yottadb.delete_tree("^Horse") # set initial values for ^Crab and ^Horse yottadb.set("^Crab", ("0", ), "0") yottadb.set("^Horse", ("0", ), "0")
import os import subprocess import datetime import random import sys import time import yottadb if __name__ == '__main__': try: jobcnt = os.environ["gtm_test_jobcnt"] except KeyError: # If this test is run outside of YDBTest, need to set `jobcnt` manually jobcnt = "5" yottadb.set("jobcnt", value=jobcnt) print(f"jobcnt = {jobcnt}") print(f"Start time of parent: {datetime.datetime.now()}") print(f'$zro={yottadb.get("$zroutines")}') print(f"PID: {os.getpid()}") # Start processing test system parameters # # istp = 0 non-tp # istp = 1 TP # istp = 2 ZTP # # MCode: set fillid=+$ztrnlnm("gtm_test_dbfillid") try: fillid = os.environ["gtm_test_dbfillid"]