From c14e6cb01ca2b8624d4c133f6f109c17510f90a6 Mon Sep 17 00:00:00 2001
From: Christophe Sovant <christophe.sovant@forgerock.com>
Date: Thu, 05 Jun 2008 18:26:08 +0000
Subject: [PATCH] Fix SNMP tests on Windows (EOL character, location of JSTAF.jar) + add testcase for issue 3308
---
opends/tests/functional-tests/testcases/snmp/snmp_trap_customconf.xml | 23 ++-
opends/tests/functional-tests/testcases/snmp/snmp_mibvalues.xml | 46 ++++---
opends/tests/functional-tests/testcases/snmp/snmp_v1_customconf.xml | 31 ++++-
opends/tests/shared/functions/snmp.xml | 7 +
opends/tests/functional-tests/testcases/snmp/snmp_setup.xml | 10
opends/tests/shared/functions/topology.xml | 7 +
opends/tests/functional-tests/testcases/snmp/snmp_v3_customconf.xml | 16 ++
opends/tests/functional-tests/testcases/snmp/snmp_status.xml | 180 +++++++++++++++++++++++++----
opends/tests/functional-tests/testcases/snmp/snmp_v2c_customconf.xml | 31 ++++-
9 files changed, 272 insertions(+), 79 deletions(-)
diff --git a/opends/tests/functional-tests/testcases/snmp/snmp_mibvalues.xml b/opends/tests/functional-tests/testcases/snmp/snmp_mibvalues.xml
index a84cbd9..18bf1ff 100644
--- a/opends/tests/functional-tests/testcases/snmp/snmp_mibvalues.xml
+++ b/opends/tests/functional-tests/testcases/snmp/snmp_mibvalues.xml
@@ -180,14 +180,14 @@
build = DSInfo.ServerDict['server buildid']
dsBuild = DSInfo.getServerBuildId(build)
dsServer = 'OpenDS Directory Server %s - %s' \
- % (dsVersion, dsBuild)
+ % (dsVersion.rstrip(), dsBuild)
</script>
<if expr="dsServerType == dsServer">
<sequence>
<script>
msg1 = 'Value for dsServerType entry is correct.\n'
- msg2 = 'Current value: %s' % dsServer
+ msg2 = 'Current value: %s' % dsServerType
msg = '%s%s' % (msg1, msg2)
</script>
<message>
@@ -199,8 +199,8 @@
<sequence>
<script>
msg1 = 'Value for dsServerType entry is wrong.\n'
- msg2 = 'Expected value: %s\n' % dsServerType
- msg3 = 'Current value: %s' % dsServer
+ msg2 = 'Expected value: %s\n' % dsServer
+ msg3 = 'Current value: %s' % dsServerType
msg = '%s%s%s' % (msg1, msg2, msg3)
</script>
<message>
@@ -240,14 +240,18 @@
<script>
dsServerDescription = DEFAULT_VALUES['dsServerDescription.1']
- dsPath = '%s/%s/bin' % (DIRECTORY_INSTANCE_DIR, OPENDSNAME)
+ if is_windows_platform(DIRECTORY_INSTANCE_HOST):
+ dsPath = '%s/%s/bat' % (DIRECTORY_INSTANCE_DIR, OPENDSNAME)
+ dsPath = dsPath.replace('/', '\\')
+ else:
+ dsPath = '%s/%s/bin' % (DIRECTORY_INSTANCE_DIR, OPENDSNAME)
</script>
<if expr="dsServerDescription == dsPath">
<sequence>
<script>
msg1 = 'Value for dsServerDescription entry is correct.\n'
- msg2 = 'Current value: %s' % dsPath
+ msg2 = 'Current value: %s' % dsServerDescription
msg = '%s%s' % (msg1, msg2)
</script>
<message>
@@ -259,8 +263,8 @@
<sequence>
<script>
msg1 = 'Value for dsServerDescription entry is wrong.\n'
- msg2 = 'Expected value: %s\n' % dsServerDescription
- msg3 = 'Current value: %s' % dsPath
+ msg2 = 'Expected value: %s\n' % dsPath
+ msg3 = 'Current value: %s' % dsServerDescription
msg = '%s%s%s' % (msg1, msg2, msg3)
</script>
<message>
@@ -824,9 +828,9 @@
newid = 2000 + loop
newDn = 'uid=user.%s' % newid
- templateFile = 'template.ldif'
+ templateFile = 'template-%s.ldif' % loop
templatePath = '%s/%s' % (TMPDIR, templateFile)
- ldifFile = 'moddn.ldif'
+ ldifFile = 'moddn-%s.ldif' % loop
ldifPath = '%s/%s' % (DIRECTORY_INSTANCE_DIR, ldifFile)
ldifLines = []
ldifLines.append('dn: %s' % userDn)
@@ -876,20 +880,20 @@
'filename' : ldifPath
}
</call>
+
+ <!--- Delete locally the ldif file used for moddn -->
+ <message>
+ 'Delete locally %s' % templatePath
+ </message>
+ <call function="'deleteFile'">
+ {
+ 'location' : STAXServiceMachine ,
+ 'filename' : templatePath
+ }
+ </call>
</sequence>
</loop>
- <!--- Delete locally the ldif file used for moddn -->
- <message>
- 'Delete locally %s' % templatePath
- </message>
- <call function="'deleteFile'">
- {
- 'location' : STAXServiceMachine ,
- 'filename' : templatePath
- }
- </call>
-
<message>
'snmp_mibvalues: increment the snmp values'
</message>
diff --git a/opends/tests/functional-tests/testcases/snmp/snmp_setup.xml b/opends/tests/functional-tests/testcases/snmp/snmp_setup.xml
index 8b29fcc..c09a4f3 100644
--- a/opends/tests/functional-tests/testcases/snmp/snmp_setup.xml
+++ b/opends/tests/functional-tests/testcases/snmp/snmp_setup.xml
@@ -417,14 +417,14 @@
<!--- Test Case information
#@TestMarker setup
- #@TestName setup: enable SNMP Connection Handler
+ #@TestName setup: warning
#@TestIssue none
- #@TestPurpose Enable SNMP Connection Handler.
+ #@TestPurpose Warning
#@TestPreamble none
- #@TestStep enable SNMP Connection Handler using
- dsconfig.
+ #@TestStep Print a warning message to indicate that
+ the SNMP_OPENDMK_LIBDIR is not set.
#@TestPostamble none
- #@TestResult Success if dsconfig returns 0.
+ #@TestResult Always fails.
-->
<testcase name="getTestCaseName('setup: Warning')">
diff --git a/opends/tests/functional-tests/testcases/snmp/snmp_status.xml b/opends/tests/functional-tests/testcases/snmp/snmp_status.xml
index 5e99c9a..f2c76ad 100644
--- a/opends/tests/functional-tests/testcases/snmp/snmp_status.xml
+++ b/opends/tests/functional-tests/testcases/snmp/snmp_status.xml
@@ -467,35 +467,15 @@
</call>
<message>
- 'status: disable the SNMP Connection Handler'
+ 'status: restart the SNMP Connection Handler'
</message>
- <call function="'dsconfig'">
+ <call function="'restartSNMPConnectionHandler'">
{
'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
- 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
- 'subcommand' : 'set-connection-handler-prop' ,
- 'objectType' : 'handler-name' ,
- 'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--set enabled:true'
- }
- </call>
- <message>
- 'status: enable the SNMP Connection Handler'
- </message>
-
- <call function="'dsconfig'">
- {
- 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
- 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
- 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
- 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
- 'subcommand' : 'set-connection-handler-prop' ,
- 'objectType' : 'handler-name' ,
- 'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--set enabled:true'
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD
}
</call>
@@ -583,7 +563,7 @@
<script>
msg1 = 'An unexpected error occurred while trying to initialize'
- msg2 = 'the SNMP Connection Hanlder. Please check the'
+ msg2 = 'the SNMP Connection Handler. Please check the'
msg3 = 'configuration attributes'
msg = '%s %s %s' % (msg1, msg2, msg3)
</script>
@@ -668,7 +648,55 @@
</call>
<message>
- 'status: disable the SNMP Connection Handler'
+ 'status: restart the SNMP Connection Handler'
+ </message>
+
+ <call function="'restartSNMPConnectionHandler'">
+ {
+ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD
+ }
+ </call>
+
+ <call function="'testCase_Postamble'"/>
+
+ </sequence>
+
+ </testcase>
+
+ <!--- Test Case information
+ #@TestMarker SNMP Connection Handler status
+ #@TestName status: check error message and status when
+ the listen-port property is set to a wrong
+ value
+ #@TestIssue none
+ #@TestPurpose Check error message and status when
+ the listen-port property is set to a wrong
+ value.
+ #@TestPreamble none
+ #@TestStep set listen-port property to a wrong value
+ #@TestStep restart the server
+ #@TestStep check that an error message is displayed at
+ startup
+ #@TestStep check status using status command
+ #@TestStep restore value for listen-port property
+ #@TestStep disable the SNMP connection handler
+ #@TestStep enable the SNMP connection handler
+ #@TestPostamble none
+ #@TestResult Success if an error message is displayed and
+ if the output of status is correct.
+ -->
+ <testcase name="getTestCaseName
+ ('status: status with a wrong listen-port value')">
+
+ <sequence>
+
+ <call function="'testCase_Preamble'"/>
+
+ <message>
+ 'status: set the listen-port to a wrong value'
</message>
<call function="'dsconfig'">
@@ -680,12 +708,94 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--set enabled:true'
+ 'optionsString' : '--set listen-port:%s' \
+ % DEFAULT_PROPERTIES['listen-port']
}
</call>
<message>
- 'status: enable the SNMP Connection Handler'
+ 'status: restart DS running on port %s' \
+ % (DIRECTORY_INSTANCE_PORT)
+ </message>
+ <call function="'StopDsWithScript'">
+ {
+ 'location' : STAF_REMOTE_HOSTNAME ,
+ 'dsHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsPort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsBindDN' : DIRECTORY_INSTANCE_DN ,
+ 'dsBindPwd' : DIRECTORY_INSTANCE_PSWD
+ }
+ </call>
+ <call function="'StartDsWithScript'">
+ { 'location' : STAF_REMOTE_HOSTNAME }
+ </call>
+
+ <script>
+ returnString = STAXResult[0][1]
+ </script>
+
+ <!--- Check that DS started -->
+ <call function="'isAlive'">
+ {
+ 'noOfLoops' : 5 ,
+ 'noOfMilliSeconds' : 2000
+ }
+ </call>
+
+ <script>
+ msg1 = 'An unexpected error occurred while trying to initialize'
+ msg2 = 'the SNMP Connection Handler. Please check the'
+ msg3 = 'configuration attributes'
+ msg = '%s %s %s' % (msg1, msg2, msg3)
+ </script>
+
+ <call function="'checktestString'">
+ {
+ 'returnString' : returnString ,
+ 'expectedString' : msg
+ }
+ </call>
+
+ <message>
+ 'status: status when the server is started'
+ </message>
+
+ <call function="'StatusWithScript'">
+ {
+ 'dsBindDN' : DIRECTORY_INSTANCE_DN ,
+ 'dsBindPwd' : DIRECTORY_INSTANCE_PSWD
+ }
+ </call>
+
+ <script>
+ returnString = STAXResult[0][1]
+ </script>
+
+ <call function="'checktestString'">
+ {
+ 'returnString' : returnString ,
+ 'expectedString' : '0.0.0.0:%s : SNMP : Enabled' \
+ % DEFAULT_PROPERTIES['listen-port']
+ }
+ </call>
+
+ <message>
+ 'status: get request'
+ </message>
+
+ <call function="'SNMPGet'">
+ {
+ 'snmpVersion' : '1',
+ 'snmpHost' : DIRECTORY_INSTANCE_HOST ,
+ 'snmpPort' : SNMP_PORT ,
+ 'snmpCommunity' : community ,
+ 'snmpOIDs' : oid ,
+ 'snmpStatus' : 'reqTimeout'
+ }
+ </call>
+
+ <message>
+ 'status: restore value for listen-port property'
</message>
<call function="'dsconfig'">
@@ -697,7 +807,21 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--set enabled:true'
+ 'optionsString' : '--set listen-port:%s' \
+ % SNMP_PROPERTIES['listen-port']
+ }
+ </call>
+
+ <message>
+ 'status: restart the SNMP Connection Handler'
+ </message>
+
+ <call function="'restartSNMPConnectionHandler'">
+ {
+ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD
}
</call>
diff --git a/opends/tests/functional-tests/testcases/snmp/snmp_trap_customconf.xml b/opends/tests/functional-tests/testcases/snmp/snmp_trap_customconf.xml
index 1d35d6c..afad415 100644
--- a/opends/tests/functional-tests/testcases/snmp/snmp_trap_customconf.xml
+++ b/opends/tests/functional-tests/testcases/snmp/snmp_trap_customconf.xml
@@ -654,9 +654,21 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--add traps-destination:%s \
- --add traps-destination:%s' \
- % (wrongTrapsDestProp, newTrapsDestProp)
+ 'optionsString' : '--set traps-destination:%s' \
+ % wrongTrapsDestProp
+ }
+ </call>
+ <call function="'dsconfig'">
+ {
+ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
+ 'subcommand' : 'set-connection-handler-prop' ,
+ 'objectType' : 'handler-name' ,
+ 'objectName' : 'SNMP Connection Handler' ,
+ 'optionsString' : '--add traps-destination:%s' \
+ % newTrapsDestProp
}
</call>
@@ -816,9 +828,8 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--add traps-community:%s \
- --add traps-community:%s' \
- % (newTrapsCommunityProp, defTrapsCommunityProp) ,
+ 'optionsString' : '--add traps-community:%s' \
+ % newTrapsCommunityProp ,
'expectedRC' : 1
}
</call>
diff --git a/opends/tests/functional-tests/testcases/snmp/snmp_v1_customconf.xml b/opends/tests/functional-tests/testcases/snmp/snmp_v1_customconf.xml
index 103718f..09becfc 100644
--- a/opends/tests/functional-tests/testcases/snmp/snmp_v1_customconf.xml
+++ b/opends/tests/functional-tests/testcases/snmp/snmp_v1_customconf.xml
@@ -404,9 +404,21 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--add allowed-manager:%s \
- --add allowed-manager:%s' \
- % (wrongManagerProp, newManagerProp)
+ 'optionsString' : '--set allowed-manager:%s' \
+ % wrongManagerProp
+ }
+ </call>
+ <call function="'dsconfig'">
+ {
+ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
+ 'subcommand' : 'set-connection-handler-prop' ,
+ 'objectType' : 'handler-name' ,
+ 'objectName' : 'SNMP Connection Handler' ,
+ 'optionsString' : '--add allowed-manager:%s' \
+ % newManagerProp
}
</call>
@@ -505,17 +517,22 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--add community:%s \
- --add community:%s' \
- % (newCommunityProp, defCommunityProp) ,
+ 'optionsString' : '--add community:%s' % newCommunityProp ,
'expectedRC' : 1
}
</call>
<script>
returnString = STAXResult[0][1]
+
+ if is_windows_platform(DIRECTORY_INSTANCE_HOST):
+ newline = '\r\n'
+ else:
+ newline = '\n'
+
msg1 = 'It is not possible to specify multiple values for the'
- msg2 = 'SNMP Connection Handler\nproperty "community" as it'
+ msg2 = 'SNMP Connection Handler%sproperty "community" as it' \
+ % newline
msg3 = 'is single-valued'
msg = '%s %s %s' % (msg1, msg2, msg3)
</script>
diff --git a/opends/tests/functional-tests/testcases/snmp/snmp_v2c_customconf.xml b/opends/tests/functional-tests/testcases/snmp/snmp_v2c_customconf.xml
index 0dc3c8e..be567e2 100644
--- a/opends/tests/functional-tests/testcases/snmp/snmp_v2c_customconf.xml
+++ b/opends/tests/functional-tests/testcases/snmp/snmp_v2c_customconf.xml
@@ -404,9 +404,21 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--add allowed-manager:%s \
- --add allowed-manager:%s' \
- % (wrongManagerProp, newManagerProp)
+ 'optionsString' : '--set allowed-manager:%s' \
+ % wrongManagerProp
+ }
+ </call>
+ <call function="'dsconfig'">
+ {
+ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
+ 'subcommand' : 'set-connection-handler-prop' ,
+ 'objectType' : 'handler-name' ,
+ 'objectName' : 'SNMP Connection Handler' ,
+ 'optionsString' : '--add allowed-manager:%s' \
+ % newManagerProp
}
</call>
@@ -505,17 +517,22 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--add community:%s \
- --add community:%s' \
- % (newCommunityProp, defCommunityProp) ,
+ 'optionsString' : '--add community:%s' % newCommunityProp ,
'expectedRC' : 1
}
</call>
<script>
returnString = STAXResult[0][1]
+
+ if is_windows_platform(DIRECTORY_INSTANCE_HOST):
+ newline = '\r\n'
+ else:
+ newline = '\n'
+
msg1 = 'It is not possible to specify multiple values for the'
- msg2 = 'SNMP Connection Handler\nproperty "community" as it'
+ msg2 = 'SNMP Connection Handler%sproperty "community" as it' \
+ % newline
msg3 = 'is single-valued'
msg = '%s %s %s' % (msg1, msg2, msg3)
</script>
diff --git a/opends/tests/functional-tests/testcases/snmp/snmp_v3_customconf.xml b/opends/tests/functional-tests/testcases/snmp/snmp_v3_customconf.xml
index 380d4a3..0ec8ceb 100644
--- a/opends/tests/functional-tests/testcases/snmp/snmp_v3_customconf.xml
+++ b/opends/tests/functional-tests/testcases/snmp/snmp_v3_customconf.xml
@@ -354,9 +354,19 @@
'subcommand' : 'set-connection-handler-prop' ,
'objectType' : 'handler-name' ,
'objectName' : 'SNMP Connection Handler' ,
- 'optionsString' : '--add allowed-user:%s \
- --add allowed-user:%s' \
- % (defUser, otherUser)
+ 'optionsString' : '--set allowed-user:%s' % defUser
+ }
+ </call>
+ <call function="'dsconfig'">
+ {
+ 'dsInstanceHost' : DIRECTORY_INSTANCE_HOST ,
+ 'dsInstancePort' : DIRECTORY_INSTANCE_PORT ,
+ 'dsInstanceDn' : DIRECTORY_INSTANCE_DN ,
+ 'dsInstancePswd' : DIRECTORY_INSTANCE_PSWD ,
+ 'subcommand' : 'set-connection-handler-prop' ,
+ 'objectType' : 'handler-name' ,
+ 'objectName' : 'SNMP Connection Handler' ,
+ 'optionsString' : '--add allowed-user:%s' % otherUser
}
</call>
diff --git a/opends/tests/shared/functions/snmp.xml b/opends/tests/shared/functions/snmp.xml
index 1f0c4c0..a6564fa 100755
--- a/opends/tests/shared/functions/snmp.xml
+++ b/opends/tests/shared/functions/snmp.xml
@@ -432,7 +432,12 @@
'name' : 'STAF/Config/STAFRoot'
}
</call>
- <script>jstaf_jarfile = '%s/lib/JSTAF.jar' % STAFResult</script>
+ <script>
+ if is_windows_platform(location):
+ jstaf_jarfile='%s\\bin\\JSTAF.jar' % STAFResult
+ else:
+ jstaf_jarfile='%s/lib/JSTAF.jar' % STAFResult
+ </script>
<!-- Build the command -->
<script>
diff --git a/opends/tests/shared/functions/topology.xml b/opends/tests/shared/functions/topology.xml
index d9c341a..b61e5b3 100755
--- a/opends/tests/shared/functions/topology.xml
+++ b/opends/tests/shared/functions/topology.xml
@@ -378,7 +378,12 @@
'name' : 'STAF/Config/STAFRoot'
}
</call>
- <script>jstaf_jarfile='%s/lib/JSTAF.jar' % STAFResult</script>
+ <script>
+ if is_windows_platform(STAXServiceMachine):
+ jstaf_jarfile='%s\\bin\\JSTAF.jar' % STAFResult
+ else:
+ jstaf_jarfile='%s/lib/JSTAF.jar' % STAFResult
+ </script>
<!--- Compile snmp java files on controler host -->
<message>
--
Gitblit v1.10.0