multistmts_test.go 15 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package client_test
  2. import (
  3. "testing"
  4. "time"
  5. "git.wecise.com/wecise/odb-go/odbc"
  6. "github.com/stretchr/testify/assert"
  7. //"git.wecise.com/wecise/odbserver/odb/upsertupsert"
  8. )
  9. func TestMultiStatements(t *testing.T) {
  10. var err error
  11. client := odbc.ODBC()
  12. defer func() {
  13. client.Close()
  14. }()
  15. _, err = client.Query(`insert into /test/bucketpromdb (id, prom) values (?, ?)`,
  16. "bucketpromdb:wecise11",
  17. []map[string]interface{}{{"__name__": "key1", "__value__": 2, "__timestamp__": "2024-08-27 11:24:17", "disk": "/opt/matrix", "CPU": "CPU1"}}).Do()
  18. if !assert.Nil(t, err, err) {
  19. return
  20. }
  21. _, err = client.Query(`
  22. insert into /cache/nalerts_status (acknowledged, admin, adminphone, agent, alarmkey, alarmtype, alertgroup, alertkey, alertsubtype, alerttype, area, bname, bsm_classname, bsm_identity, bsm_subidentity, businessimpact, bussinesscategory, causetype, ccpc, ccpcbank, chineseflag, ciid, cmdbenrichstatus, cname, cnsummary, contact, contactman, contactphone, corrscore, customer, deviceios, devicelocation, devicemodel, devicepurpose, devicetype, domaingroup, domainsubgroup, duration, emailstatus, entity, eventclass, eventid, eventstatus, eventtime, eventtype, evtproccode, expiretime, explain, extendedattr, firstoccurrence, flag, flash, grade, id, identifier, idname, impactflag, instance, internallast, itmdisplayitem, lastoccurrence, localnodealias, localobjrelate, localpriobj, localrootobj, localsecobj, localtertobj, location, logticket, lpar, machineid, maintainstatus, maintenance, manager, market, msg_id, n_maintenance_status, name, netype, nmoscausetype, nmosdomainname, nmosentityid, nmoseventmap, nmosmanagedstatus, nmosobjinst, nmosserial, node, nodealias, nodename, nodetype, objectfullname, oldrow, omni_class, omni_serial, orgcode, originalseverity, ownergid, owneruid, phone, physicalcabinet, physicalcard, physicallocation, physicalport, physicalslot, plateng, platform, policylevel, policyname, poll, probesubsecondid, processreq, recordtime, region, remotenodealias, remoteobjrelate, remotepriobj, remoterootobj, remotesecobj, remotetertobj, resolve, rowserial, servername, serverserial, service, servicenowerrorcode, servicenowstate, servicenowsysid, severity, siteid, situationfullname, smsflag, statechange, status, submodel, subsystem, summary, suppressescl, syscode, sysplex, tags, tally, tasklist, ticketstatus, tiggerflag, tsrmflag, ttnumber, ttstate, ttuser, type, upgradeflag, url, x733corrnotif, x733eventtype, x733probablecause, x733specificprob)
  23. values (0, '', '', 'Snmp Probe', '', '', 'snmp', 'snmpport_1000', '', '', '', '', '', '', '', 0, '', 0, 0, '', 0, '', 0, '', '', '', '', '', 0, '', '', '', '', '', '', 'snmp', '', 0, 0, '', '', '', 0, '', 0, '', 0, '', '', 1694318500000, 0, 0, 0, '16700997574987680230', 'xxxnode:1.1.1.1', '', 0, '', -6795364578871, '', 1694322269050, '', 0, '', '', '', '', '', 0, '', '', 0, 0, 'Snmp', '', '', 0, '16700997574987680230', '', 0, '', 0, '', 0, 0, '', 'node:1.1.1.1', '', '', '', '', 0, '', 0, '', 0, 0, 0, '', '', '', '', 0, 0, '', '', '', '', 0, 0, 0, 0, '', '', 0, '', '', '', '', '', 0, '', 11223, '', 0, 0, '', 1, '', '', 1, -6795364578871, 120, '', '', 'snmp test event', 0, '', '', null, 28000, 0, '', 0, 0, '', 0, '', 1, 0, '', '', 0, 0, '')
  24. ;
  25. insert into /cache/nalerts_status (acknowledged, admin, adminphone, agent, alarmkey, alarmtype, alertgroup, alertkey, alertsubtype, alerttype, area, bname, bsm_classname, bsm_identity, bsm_subidentity, businessimpact, bussinesscategory, causetype, ccpc, ccpcbank, chineseflag, ciid, cmdbenrichstatus, cname, cnsummary, contact, contactman, contactphone, corrscore, customer, deviceios, devicelocation, devicemodel, devicepurpose, devicetype, domaingroup, domainsubgroup, duration, emailstatus, entity, eventclass, eventid, eventstatus, eventtime, eventtype, evtproccode, expiretime, explain, extendedattr, firstoccurrence, flag, flash, grade, id, identifier, idname, impactflag, instance, internallast, itmdisplayitem, lastoccurrence, localnodealias, localobjrelate, localpriobj, localrootobj, localsecobj, localtertobj, location, logticket, lpar, machineid, maintainstatus, maintenance, manager, market, msg_id, n_maintenance_status, name, netype, nmoscausetype, nmosdomainname, nmosentityid, nmoseventmap, nmosmanagedstatus, nmosobjinst, nmosserial, node, nodealias, nodename, nodetype, objectfullname, oldrow, omni_class, omni_serial, orgcode, originalseverity, ownergid, owneruid, phone, physicalcabinet, physicalcard, physicallocation, physicalport, physicalslot, plateng, platform, policylevel, policyname, poll, probesubsecondid, processreq, recordtime, region, remotenodealias, remoteobjrelate, remotepriobj, remoterootobj, remotesecobj, remotetertobj, resolve, rowserial, servername, serverserial, service, servicenowerrorcode, servicenowstate, servicenowsysid, severity, siteid, situationfullname, smsflag, statechange, status, submodel, subsystem, summary, suppressescl, syscode, sysplex, tags, tally, tasklist, ticketstatus, tiggerflag, tsrmflag, ttnumber, ttstate, ttuser, type, upgradeflag, url, x733corrnotif, x733eventtype, x733probablecause, x733specificprob)
  26. values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
  27. ;
  28. `,
  29. 0, "", "", "Snmp Probe", "", "", "snmp", "snmpport_1000", "", "", "", "", "", "", "", 0, "", 0, 0, "", 0, "", 0, "", "", "", "", "", 0, "", "", "", "", "", "", "snmp", "", 0, 0, "", "", "", 0, "", 0, "", 0, "", "", 1694318500000, 0, 0, 0, "16700997574987680230", "xxxnode:1.1.1.1", "", 0, "", -6795364578871, "", 1694322269050, "", 0, "", "", "", "", "", 0, "", "", 0, 0, "Snmp", "", "", 0, "16700997574987680230", "", 0, "", 0, "", 0, 0, "", "node:1.1.1.1", "", "", "", "", 0, "", 0, "", 0, 0, 0, "", "", "", "", 0, 0, "", "", "", "", 0, 0, 0, 0, "", "", 0, "", "", "", "", "", 0, "", 11223, "", 0, 0, "", 1, "", "", 1, -6795364578871, 120, "", "", "snmp test event", 0, "", "", nil, 28000, 0, "", 0, 0, "", 0, "", 1, 0, "", "", 0, 0, "",
  30. ).Do()
  31. if !assert.Nil(t, err, "prepare 不支持多条语句") {
  32. return
  33. }
  34. _, err = client.Query(`
  35. insert into /cache/nalerts_status (acknowledged, admin, adminphone, agent, alarmkey, alarmtype, alertgroup, alertkey, alertsubtype, alerttype, area, bname, bsm_classname, bsm_identity, bsm_subidentity, businessimpact, bussinesscategory, causetype, ccpc, ccpcbank, chineseflag, ciid, cmdbenrichstatus, cname, cnsummary, contact, contactman, contactphone, corrscore, customer, deviceios, devicelocation, devicemodel, devicepurpose, devicetype, domaingroup, domainsubgroup, duration, emailstatus, entity, eventclass, eventid, eventstatus, eventtime, eventtype, evtproccode, expiretime, explain, extendedattr, firstoccurrence, flag, flash, grade, id, identifier, idname, impactflag, instance, internallast, itmdisplayitem, lastoccurrence, localnodealias, localobjrelate, localpriobj, localrootobj, localsecobj, localtertobj, location, logticket, lpar, machineid, maintainstatus, maintenance, manager, market, msg_id, n_maintenance_status, name, netype, nmoscausetype, nmosdomainname, nmosentityid, nmoseventmap, nmosmanagedstatus, nmosobjinst, nmosserial, node, nodealias, nodename, nodetype, objectfullname, oldrow, omni_class, omni_serial, orgcode, originalseverity, ownergid, owneruid, phone, physicalcabinet, physicalcard, physicallocation, physicalport, physicalslot, plateng, platform, policylevel, policyname, poll, probesubsecondid, processreq, recordtime, region, remotenodealias, remoteobjrelate, remotepriobj, remoterootobj, remotesecobj, remotetertobj, resolve, rowserial, servername, serverserial, service, servicenowerrorcode, servicenowstate, servicenowsysid, severity, siteid, situationfullname, smsflag, statechange, status, submodel, subsystem, summary, suppressescl, syscode, sysplex, tags, tally, tasklist, ticketstatus, tiggerflag, tsrmflag, ttnumber, ttstate, ttuser, type, upgradeflag, url, x733corrnotif, x733eventtype, x733probablecause, x733specificprob)
  36. values (0, '', '', 'Snmp Probe', '', '', 'snmp', 'snmpport_1000', '', '', '', '', '', '', '', 0, '', 0, 0, '', 0, '', 0, '', '', '', '', '', 0, '', '', '', '', '', '', 'snmp', '', 0, 0, '', '', '', 0, '', 0, '', 0, '', '', 1694318500000, 0, 0, 0, '16700997574987680230', 'xxxnode:1.1.1.1', '', 0, '', -6795364578871, '', 1694322269050, '', 0, '', '', '', '', '', 0, '', '', 0, 0, 'Snmp', '', '', 0, '16700997574987680230', '', 0, '', 0, '', 0, 0, '', 'node:1.1.1.1', '', '', '', '', 0, '', 0, '', 0, 0, 0, '', '', '', '', 0, 0, '', '', '', '', 0, 0, 0, 0, '', '', 0, '', '', '', '', '', 0, '', 11223, '', 0, 0, '', 1, '', '', 1, -6795364578871, 120, '', '', 'snmp test event', 0, '', '', null, 28000, 0, '', 0, 0, '', 0, '', 1, 0, '', '', 0, 0, '')
  37. ;
  38. insert into /cache/nalerts_status (acknowledged, admin, adminphone, agent, alarmkey, alarmtype, alertgroup, alertkey, alertsubtype, alerttype, area, bname, bsm_classname, bsm_identity, bsm_subidentity, businessimpact, bussinesscategory, causetype, ccpc, ccpcbank, chineseflag, ciid, cmdbenrichstatus, cname, cnsummary, contact, contactman, contactphone, corrscore, customer, deviceios, devicelocation, devicemodel, devicepurpose, devicetype, domaingroup, domainsubgroup, duration, emailstatus, entity, eventclass, eventid, eventstatus, eventtime, eventtype, evtproccode, expiretime, explain, extendedattr, firstoccurrence, flag, flash, grade, id, identifier, idname, impactflag, instance, internallast, itmdisplayitem, lastoccurrence, localnodealias, localobjrelate, localpriobj, localrootobj, localsecobj, localtertobj, location, logticket, lpar, machineid, maintainstatus, maintenance, manager, market, msg_id, n_maintenance_status, name, netype, nmoscausetype, nmosdomainname, nmosentityid, nmoseventmap, nmosmanagedstatus, nmosobjinst, nmosserial, node, nodealias, nodename, nodetype, objectfullname, oldrow, omni_class, omni_serial, orgcode, originalseverity, ownergid, owneruid, phone, physicalcabinet, physicalcard, physicallocation, physicalport, physicalslot, plateng, platform, policylevel, policyname, poll, probesubsecondid, processreq, recordtime, region, remotenodealias, remoteobjrelate, remotepriobj, remoterootobj, remotesecobj, remotetertobj, resolve, rowserial, servername, serverserial, service, servicenowerrorcode, servicenowstate, servicenowsysid, severity, siteid, situationfullname, smsflag, statechange, status, submodel, subsystem, summary, suppressescl, syscode, sysplex, tags, tally, tasklist, ticketstatus, tiggerflag, tsrmflag, ttnumber, ttstate, ttuser, type, upgradeflag, url, x733corrnotif, x733eventtype, x733probablecause, x733specificprob)
  39. values (0, '', '', 'Snmp Probe', '', '', 'snmp', 'snmpport_1000', '', '', '', '', '', '', '', 0, '', 0, 0, '', 0, '', 0, '', '', '', '', '', 0, '', '', '', '', '', '', 'snmp', '', 0, 0, '', '', '', 0, '', 0, '', 0, '', '', 1694318500000, 0, 0, 0, '16700997574987680230', 'xxxnode:1.1.1.1', '', 0, '', -6795364578871, '', 1694322269050, '', 0, '', '', '', '', '', 0, '', '', 0, 0, 'Snmp', '', '', 0, '16700997574987680230', '', 0, '', 0, '', 0, 0, '', 'node:1.1.1.1', '', '', '', '', 0, '', 0, '', 0, 0, 0, '', '', '', '', 0, 0, '', '', '', '', 0, 0, 0, 0, '', '', 0, '', '', '', '', '', 0, '', 11223, '', 0, 0, '', 1, '', '', 1, -6795364578871, 120, '', '', 'snmp test event', 0, '', '', null, 28000, 0, '', 0, 0, '', 0, '', 1, 0, '', '', 0, 0, '')
  40. ;
  41. `).Do()
  42. if !assert.Nil(t, err, err) {
  43. return
  44. }
  45. _, err = client.Query(`
  46. insert into /cache/nalerts_status (acknowledged, admin, adminphone, agent, alarmkey, alarmtype, alertgroup, alertkey, alertsubtype, alerttype, area, bname, bsm_classname, bsm_identity, bsm_subidentity, businessimpact, bussinesscategory, causetype, ccpc, ccpcbank, chineseflag, ciid, cmdbenrichstatus, cname, cnsummary, contact, contactman, contactphone, corrscore, customer, deviceios, devicelocation, devicemodel, devicepurpose, devicetype, domaingroup, domainsubgroup, duration, emailstatus, entity, eventclass, eventid, eventstatus, eventtime, eventtype, evtproccode, expiretime, explain, extendedattr, firstoccurrence, flag, flash, grade, id, identifier, idname, impactflag, instance, internallast, itmdisplayitem, lastoccurrence, localnodealias, localobjrelate, localpriobj, localrootobj, localsecobj, localtertobj, location, logticket, lpar, machineid, maintainstatus, maintenance, manager, market, msg_id, n_maintenance_status, name, netype, nmoscausetype, nmosdomainname, nmosentityid, nmoseventmap, nmosmanagedstatus, nmosobjinst, nmosserial, node, nodealias, nodename, nodetype, objectfullname, oldrow, omni_class, omni_serial, orgcode, originalseverity, ownergid, owneruid, phone, physicalcabinet, physicalcard, physicallocation, physicalport, physicalslot, plateng, platform, policylevel, policyname, poll, probesubsecondid, processreq, recordtime, region, remotenodealias, remoteobjrelate, remotepriobj, remoterootobj, remotesecobj, remotetertobj, resolve, rowserial, servername, serverserial, service, servicenowerrorcode, servicenowstate, servicenowsysid, severity, siteid, situationfullname, smsflag, statechange, status, submodel, subsystem, summary, suppressescl, syscode, sysplex, tags, tally, tasklist, ticketstatus, tiggerflag, tsrmflag, ttnumber, ttstate, ttuser, type, upgradeflag, url, x733corrnotif, x733eventtype, x733probablecause, x733specificprob)
  47. values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
  48. ;
  49. `,
  50. 0, "", "", "Snmp Probe", "", "", "snmp", "snmpport_1000", "", "", "", "", "", "", "", 0, "", 0, 0, "", 0, "", 0, "", "", "", "", "", 0, "", "", "", "", "", "", "snmp", "", 0, 0, "", "", "", 0, "", 0, "", 0, "", "", 1694318500000, 0, 0, 0, "16700997574987680230", "xxxnode:1.1.1.1", "", 0, "", -6795364578871, "", 1694322269050, "", 0, "", "", "", "", "", 0, "", "", 0, 0, "Snmp", "", "", 0, "16700997574987680230", "", 0, "", 0, "", 0, 0, "", "node:1.1.1.1", "", "", "", "", 0, "", 0, "", 0, 0, 0, "", "", "", "", 0, 0, "", "", "", "", 0, 0, 0, 0, "", "", 0, "", "", "", "", "", 0, "", 11223, "", 0, 0, "", 1, "", "", 1, -6795364578871, 120, "", "", "snmp test event", 0, "", "", nil, 28000, 0, "", 0, 0, "", 0, "", 1, 0, "", "", 0, 0, "",
  51. ).Do()
  52. if !assert.Nil(t, err, err) {
  53. return
  54. }
  55. time.Sleep(1 * time.Second)
  56. }