DATA 전문가로 가는 길

[TIP][성능측정도구] NHN - nGrinder Oracle 접속 방법(Oracle, OJDBC) 본문

IT

[TIP][성능측정도구] NHN - nGrinder Oracle 접속 방법(Oracle, OJDBC)

EstenPark 2017. 5. 18. 13:24

nGrinder 설치 완료 후 데이터베이스 접속 테스트를 하기 위한 방법 이며, 그 중에서 오라클 DBMS에 접속 하는 방법을 자세하게 설명 하도록 하겠습니다. 오라클 데이터베이스에 접속 하기 위해서는 ojdbc를 lib 폴더에 반드시 적용 되어 있어야 합니다. 


1. lib 폴더에 ojdbc6.jar 파일 업로드

  - lib 폴더를 생성 한 후에 ojdbc6.jar 파일을 Update script or resources 버튼을 통해서 업로드




2. Script 화면

  - OracleDBAccess.py :  Oracle DBMS에 접속하는 스크립트 소스

  - lib : 라이브러리 파일을 업로드 한 폴더


3. nGrinder Oracle Database Access(접속 테스트) 소스

  - Create a script > Type : Jython

  - DB_connect 접속하려는 오라클 IP, 포트, SID

  - DB_user 사용자 ID

  - DB_paassword :사용자 패스워드

# -*- coding:utf-8 -*- 
# Oracle Database test. 
# 
from java.sql import DriverManager 
from oracle.jdbc import OracleDriver 
from net.grinder.script.Grinder import grinder 
from net.grinder.script import Test 
from java.util import Random 
from java.lang import System 

# Parameters 
DB_connect = "jdbc:oracle:thin:@192.168.0.171:1521:ESTSID" 
DB_user = "ESTENPARK" 
DB_password = "###PASSWORD###" 

  
test1 = Test(1, "Database select") 
random = Random(long(System.nanoTime())) 
  
# Load the JDBC driver. 
DriverManager.registerDriver(OracleDriver()) 

  
def getConnection(): 
    return DriverManager.getConnection(DB_connect, DB_user, DB_password) 
  
def ensureClosed(object): 
    try: object.close() 
    except: pass 
      
class TestRunner: 
    def __init__(self): 
        test1.record(TestRunner.__call__) 
        grinder.statistics.delayReports=True 
        pass 

    def __call__(self):
        connection = None 
        selectStatement = None 
        try: 
            # in this test, we will create connection and statement in every test transaction. 
            connection = getConnection()
            selectStatement = connection.createStatement()
            selectStatement.execute("SELECT    COUNT(*) FROM      ESP_MBR_INFO A")
            
        finally: 
            ensureClosed(selectStatement)



4. nGrinder Oracle Database Access 결과

2017-05-18 13:00:50,999 INFO  The Grinder version 3.9.1
2017-05-18 13:00:51,026 INFO  Java(TM) SE Runtime Environment 1.7.0_79-b15: Java HotSpot(TM) 64-Bit Server VM (24.79-b02, mixed mode) on Linux amd64 3.10.0-327.el7.x86_64
2017-05-18 13:00:51,029 INFO  time zone is KST (+0900)
2017-05-18 13:00:51,192 INFO  worker process 0 of agent number 0
2017-05-18 13:00:51,272 INFO  Instrumentation agents: byte code transforming instrumenter for Jython 2.5; byte code transforming instrumenter for Java
2017-05-18 13:00:54,808 INFO  Running "OracleDBAccess.py" using Jython 2.5.3 (2.5:c56500f08d34+, Aug 13 2012, 14:54:35) 
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)]
2017-05-18 13:00:54,940 INFO  starting, will do 1 run
2017-05-18 13:00:54,940 INFO  Start time is 1495080054940 ms since Epoch
2017-05-18 13:00:55,544 INFO  finished 1 run
2017-05-18 13:00:55,545 INFO  elapsed time is 605 ms
2017-05-18 13:00:55,545 INFO  Final statistics for this process:
2017-05-18 13:00:55,553 INFO  
             Tests        Errors       Mean Test    Test Time    TPS          
                                       Time (ms)    Standard                  
                                                    Deviation                 
                                                    (ms)                      

Test 1       1            0            574.00       0.00         1.65          "Database select"

Totals       1            0            574.00       0.00         1.65         

  Tests resulting in error only contribute to the Errors column.          
  Statistics for individual tests can be found in the data file, including
  (possibly incomplete) statistics for erroneous tests. Composite tests   
  are marked with () and not included in the totals.                      



2017-05-18 13:00:54,813 INFO  validation-0: Starting threads
2017-05-18 13:00:55,553 INFO  validation-0: Finished


Comments