We have ftp server with few directories and files under it, I am able to connect through browser and access directories successfully. However when used the same server:port with credentials not able to connect. Tried using JSR233 sampler also to list the files, but no success.
please guide.
TestPlan:
FTP request defaults (Server IP and port:21)>get(RETR)
--Thread Group
---FTP request (nothing added as remote file since just want to get list of files/directories)
---JSR233 sampler with below script
import org.apache.commons.net.ftp.FTPClient
def ftpClient = new FTPClient()
ftpClient.connect("xx.xx.xx.xx", 21)
ftpClient.login("'abc", "tesst")
ftpClient.listFiles().each {
log.info(it.getName())
}
log.info("---")
for FTP request getting an error as below:
Response message: java.io.FileNotFoundException: (The system cannot find the path specified)
Request is going as:
ftp://xx.xx.xx.xx:21/ (Ascii) ->
for JSR233 sampler: shows success without any response, files are list listed even in jmeter log also.
Please suggest how to achieve this.
Added screen shot of jmeter.log and .jmx file.
[![FTP req defaults[![FTP req![JSR233 sampler[![res msg: The system cannot find the path specified)
[]2]3]4]5
Able to get results in the Jmeter log file now, there was extra ' in the credentials going.
You might need to call FTPClient.changeWorkingDirectory() method before listing files as your abc user.
Prior to doing anything else you might want to test whether you connected to the FTP server or not by calling ftpClient.isConnected() method
Also be aware that FTPClient.login() method returns true if login is successful and false otherwise.
According to the Load Testing FTP and SFTP Servers Using JMeter article your code needs to be amended like:
import org.apache.commons.net.ftp.FTPClient
def ftpClient = new FTPClient()
ftpClient.connect('xx.xx.xx.xx', 21)
if (ftpClient.isConnected()) {
if (ftpClient.login('abc', 'tesst')) {
ftpClient.changeWorkingDirectory('/path/to/the/folder/with/files/') // navigate to the folder which content you want to list
ftpClient.listFiles().each {
log.info(it.getName())
}
} else {
log.error('Failed to login')
}
} else {
log.error('Failed to connect')
}
If none of the above hints will help post update your question with the jmeter.log file contents.
Related
I have multiple virtual hosts, managed by Nginx.
I received a ticket which asks me to validate the value of a request header for some virtual hosts and refuse serving requests if the header is absent or invalid. This is what I have added to each of the virtual hosts:
location / {
if ($http_my_request_header_name != "<mytoken>") {
return 406;
}
}
And this is working as expected. However, I intend to make this solution more elegant and create a new config file, called common.conf, and, instead of pasting the same code into all virtual hosts, include this common file, as:
include conf.d/common.conf;
Yet, my tries were all failing:
First attempt
Pasting the if conditional and leave the location directive in the virtual host, which would include the file. The error I received was telling me in the logs that I cannot have an if by itself in the file.
Second attempt
I have moved the whole
location / {
if ($http_my_request_header_name != "<mytoken>") {
return 406;
}
}
into the common file and replaced it with the include at the virtual host configs. The error I received was telling me that I need to wrap a server directive around the location directive.
Third attempt
I have wrapped a server directive around my location directive, but that errored out as well. I no longer have the error, because I destroyed the server since then and recreated it. But if the exact error message is needed, let me know, I will reproduce it and share it here then.
Question
How can I create a common config file that would validate for a request header and include it into multiple virtual host configs?
EDIT
In view of Rahul Sharma's answer, I'm providing further information of the current try. This is how the main conf looks alike currently:
server {
...
include conf.d/common.conf;
...
}
and the include is a direct child of the server directive, that is, nothing else is wrapped around the include. Earlier, instead of the include` line, the main conf had its content, like
server {
...
location / {
if ($http_my_request_header_name != "<mytoken>") {
return 406;
}
}
...
}
and it worked. I have literally moved the location / to the common.conf file and replaced it with the include. So, Nginx dislikes my other file for some reason. This is why it was strange to me and this is what led me to ask this question.
I assume the contents of your conf.d/common.conf file is:
location / {
if ($http_my_request_header_name != "<mytoken>") {
return 406;
}
}
The error
"location" directive is not allowed here in /etc/nginx/conf.d/common.conf
is because probably your include statement inside the main nginx.conf is misplaced. The line include conf.d/common.conf; should be inside a server block for this to work like this:
server {
...
...
include conf.d/common.conf;
...
...
}
It turned out that in nginx.conf there was a line of
include /etc/nginx/conf.d/*.conf;
which included common.conf at another place that I was not aware of and in that second place the code inside common.conf was invalid.
When I run a Http Request, to a page that should return a response body (I know it's working because I already tried in Postman). When I execute the sampler it's sends a 200 OK code, but the response body in the View Results Tree Listener, is empty. Why does this happen?
I use MAC OS, and I installed JMeter with Brew. I've already tried to add the following information in the user.properties file:
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.responseHeaders=true
It looks like this:
I had this exact issue, and the final answer was to use either Java version 9 or in my case it was Java version 8. That fixed the issue and I am now able to see the response body and response headers.
The changes you've made don't have any impact onto View Results Tree listener output, they are only for .jtl results files.
Try the following:
Run your JMeter test in command-line non-GUI mode like
jmeter -n -t test.jmx -l result.xml
and open result.xml file with your faviourite text or XML viewer/editor. You should see something like:
<?xml version="1.0" encoding="UTF-8"?>
<testResults version="1.2">
<httpSample t="93" it="0" lt="93" ct="42" ts="1568029799118" s="true" lb="HTTP Request" rc="200" rm="OK" tn="Thread Group 1-1" dt="text" by="759" sby="139" ng="1" na="1">
<responseData class="java.lang.String">{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}</responseData>
<java.net.URL>http://jsonplaceholder.typicode.com/todos/1</java.net.URL>
</httpSample>
</testResults>
where responseData tag contains XML-escaped response data. If there is some data in the file - most probably something is wrong with your JMeter installation, try re-installing it by downloading JMeter from the official website as the Brew package might be broken.
Check jmeter.log file contents, if anything goes wrong JMeter normally writes a log message with the results.
I see you didn't load the generated *.jtl file in your "View results Tree" panel. You should browse and open that file and then you can see the results. Remember, you must add the listener, run the tests in non-GUI mode once, and the *.jtl file would then contain the results. Open them here:
And I think the correct results are not shown.
File is getting download in jmeter bin folder from 'Save Responses to a file' assertion.
I'm not able to verify the downloaded file, Is there any assertion available other than MD5Hex Assertion or I need to write JAVA/Groovy code?
If you need to check file presence you can add a JSR223 Assertion and use the following code assuming File.exists() function :
if (!new File('Bulk.pdf').exists()) {
AssertionResult.setFailure(true)
AssertionResult.setFailureMessage('File is absent')
}
If the file will not be present you will get an error message like:
More information: Scripting JMeter Assertions in Groovy - A Tutorial
You can check using notExists with more readable version
import java.nio.file.*;
if (Files.notExists(Paths.get("Bulk.pdf"))) {
I am following the tutorial at
https://cloud.google.com/appengine/docs/java/endpoints/calling-from-ios
and when I get to step 5 and Open a new Terminal window to invoke ServiceGenerator. I get the error message in my terminal saying..
Barrys-MacBook-Pro:~ barrymadej$ /Users/barrymadej/Library/Developer/Xcode/DerivedData/ServiceGenerator-avaeguyitgyhxpcnaejpgzvxezei/Build/Products/Debug/ServiceGenerator \
/Users/barrymadej/Documents/AndroidStudioProjects/StudentProgressTrackerDatabaseAndCloud/backend/build/discovery-docs/myApi-v2-rpc.discovery /
ERROR: An output directory is required.
Usage: ServiceGenerator [FLAGS] [ARGS]
Required Flags:
--outputDir PATH
The destination directory for writing the generated files.
Optional Flags:
--discoveryService URL
Instead of discovery's default URL, use the specified URL as the
location to send the JSON-RPC requests. This is useful for running
against a custom or prerelease server.
--gtlFrameworkName NAME
Will generate sources that include GTL's headers as if they are in a
framework with the given name. If you are using GTL via CocoaPods,
you'll likely want to pass "GoogleAPIClient" as the value for this.
--apiLogDir DIR
Write out a file into DIR for each JSON API description processed. These
can be useful for reporting bugs if generation fails with an error.
--httpLogDir PATH
Turn on the HTTP fetcher logging and set it to write to PATH. This can
be useful for diagnosing errors on discovery fetches.
--generatePreferred
Causes the list of services to be collected, and all preferred services
to be generated.
--httpHeader NAME:VALUE
Causes the given NAME/VALUE pair to be added as an HTTP header on *all*
HTTP requests made by the generator. Can be used repeatedly to provide
additional header pairs.
--formattedName SERVICE:VERSION=NAME
Causes the given SERVICE:VERSION pair to override its service name in
files, classes, etc. with NAME. If :VERSION is omitted the override is
for any version of the service. Can be used repeatedly to provide
several maps when generating a few things in a single run.
--addServiceNameDir yes|no Default: no
Causes the generator to add a directory with the service name in the
outputDir for the files. This is useful for generating multiple
services.
--generatedDir yes|no Default: no
Causes a directory in outputDir called "Generated" to be created and
used to contain the generated files.
--removeUnknownFiles yes|no Default: no
By default, the generator will report unknown files in the output
directory, as commonly happens when classes go away in a new API
version. This option causes the generator to also remove the unknown
files.
--rootURLOverrides yes|no Default: yes
Causes any API root URL for a Google sandbox server to be replaced with
the googleapis.com root instead.
--verbose
Generate more verbose output. Can be used more than once.
Arguments:
Multiple arguments can be given on the command line.
service:version
The description of the given [service]/[version] pair is fetched and the
files for it are generated. When using --generatePreferred version can
be '-' to skip generating the name service.
http[s]://url/to/rpc_description_json
A URL to download containing the description of a service to generate.
path/to/rpc_description.json
The path to a text file containing the description of a service to
generate.
ServiceGenerator path:
/Users/barrymadej/Library/Developer/Xcode/DerivedData/ServiceGenerator-avaeguyitgyhxpcnaejpgzvxezei/Build/Products/Debug/ServiceGenerator
ERROR: There was one or more errors; check the full output for details.
Barrys-MacBook-Pro:~ barrymadej$ --outputDir
-bash: --outputDir: command not found
Barrys-MacBook-Pro:~ barrymadej$ /Users/barrymadej/Documents/AndroidStudioProjects/StudentProgressTrackerDatabaseAndCloud/API
You should generate a REST discovery document and use the new Objective C client instead. The client library you're trying to use is deprecated anyway. It looks like it didn't work because you specified the flag without the rest of the command, though.
I am currently working on puppet using Amazon Fedora EC2 instances. Both Puppet Server and Client are working fine. I am able to create certificate from client and server is able to sign that but still whatever code I have written in manifest files doesn’t get executed.
Below mentioned is my code in Site.pp file :
class test_class {
file { “/tmp/testfile”:
ensure => present,
mode => 644,
owner => root,
group => root
}
}
node puppetclient {
include test_class
}
Here, puppetclient is the hostname of client. But still after signing certificate /tmp/testfile doesn’t get created.
DNS is also working perfectly fine. I can ping puppetserver(named as puppet) from puppet client.
Can you please tell me what must be the possible mistake ??
It's probably just a typo in the question, but the default catalog file is 'site.pp', not 'Site.pp', so try it with 'site.pp' instead.