Jenkins cannot find file even though it exist in the workplace Selenium File not found: Selenium::WebDriver::Error::InvalidArgumentError) - selenium

So I am seeing this below, the file exist and this is the ruby line of code thats supposed to run:
upload = #browser.file_field(:type => 'file', :class => 'react-fine-uploader-file-input')
upload.send_keys("workplace/uploads/test1.mp3")
#browser.button(:class => 'change-file-button').wait_until_present
Jenkins error below in the console output:
File not found: workplace/uploads/test1.mp3
(Selenium::WebDriver::Error::InvalidArgumentError)

Related

Puppet conditional only if file exists in a particular directory

I have the following file resource in my puppet manifest:
file{
'example.dat'
path => "/path/to/example.dat",
owner => devops,
mode => "0644",
source => "/path/to/example.txt"
}
I want to run the above snippet only when the .txt file is present in a particular directory. Otherwise, I do not want the snippet to run.
How do I go about doing that in puppet?
In general, you would create a custom fact that returns true when the directory in question satisfies your condition. For example:
Facter.add('contains_txt') do
setcode do
! Dir.glob("/path/to/dir/*.txt").empty?
end
end
Then you would write:
if $facts['contains_txt'] {
file { 'example.dat':
path => "/path/to/example.dat",
owner => devops,
mode => "0644",
source => "/path/to/example.txt",
}
}

Paperclip not displaying image (rails api)

I have a user module and I have generated paperclip attachment: profile_pic
user.rb:
has_attached_file :profile_pic,
style: { :medium => "300x300>", thumb: "100x100>" },
default_url: "/images/:style/missing.png"
controller:
image_base = params[:manager][:profile_pic]
if image_base != nil
image = Paperclip.io_adapters.for(image_base)
image.original_filename = params[:manager][:file_name]
current_user.profile_pic = image
current_user.errors.delete(:profile_pic)
current_user.save
end
config/initializers/paperclip.rb:
Paperclip::DataUriAdapter.register
It's not showing any errors but If I am trying to display the image, it gives me following error:
ActionController::RoutingError (No route matches [GET] "/system/managers/profile_pics/000/000/008/original/icon_new.png"):
When I am trying in console like:
user.profile_pic.display
/system/managers/profile_pics/000/000/008/original/icon_new.png?
1556082410 => nil
Picture was saved in public folder
The default folder is the following, so Paperclip uploaded to the right place:
:rails_root/public/system/:class/:attachment/:id_partition/:style/:filename
But it looks like you are having troubles accessing the right location. Have you tried user.profile_pic.url? I tried on my working example, both .display and .url are the same but I use an AWS S3 bucket.
user.profile_pic.url should be where to find the file on the web.
user.profile_pic.path should be where to find the file on the file system.
The problem is with production mode and Solved this by adding the following line in production.rb
config.public_file_server.enabled = true

can't test eloquent with php unit

I try to implement some unit tests with phpUnit, on a project that uses Eloquent. The installation is made with composer for both frameworks. But when I try to implement a simple example test, it fails loading database.php
the example test
include("database.php");
class ArticleControllerTest extends TestCase
{
public function testAccueil()
{
//récupère la date du jour
$a = \app\model\Article::first();
$this->assertInternalType("string", $a->titreGeneral);
}
}
Database.php
<?php
require 'vendor/autoload.php';
use Illuminate\Container\Container;
use Illuminate\Database\Capsule\Manager as Capsule;
use Illuminate\Events\Dispatcher;
$capsule = new Capsule;
$capsule->addConnection(array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'spectacles',
'username' => 'root',
'password' => 'root',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => ''
));
$capsule->setEventDispatcher(new Dispatcher(new Container));
$capsule->setAsGlobal();
$capsule->bootEloquent();
error message with these script (the database is in the right folder)
PHP Warning: include(../../database.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
Warning: include(../../database.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
PHP Warning: include(): Failed opening '../../database.php' for inclusion (include_path='.:') in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
Warning: include(): Failed opening '../../database.php' for inclusion (include_path='.:') in /Applications/MAMP/htdocs/spectacles/TestUnits/controllerTest/ArticleControllerTest.php on line 6
And error messages when I try to put the code in database.php directly in the example test :
PDOException: SQLSTATE[HY000] [2002] No such file or directory
I don't think the problem comes prom the paths (they are the right paths). Did I miss something ?
PDOException: SQLSTATE[HY000] [2002] No such file or directory means the database could not connect.
The other errors are clearly telling you that the script could not include the database.php file.
The paths are not correct. You are not properly understanding how include() works. Read http://php.net/manual/en/function.include.php.
In a nutshell, the following code expects the database.php file to exist in the same directory as the file itself, or on the include path.
include("database.php");
class ArticleControllerTest extends TestCase
{
...
These may also help:
Understanding include_path output PHP
Include Config and Database from other files

why chef-metal-ssh is failed

I was trying to follow https://github.com/double-z/chef-metal-ssh
I'm running the code below, it throws the exception:
[2015-01-19T06:03:39-06:00] ERROR: machineone had an error: ArgumentError: wrong number of arguments (2 for 0)
require 'chef_metal_ssh'
name = "one"
with_ssh_cluster("~/metal_ssh")
machine name do
action [:ready, :converge]
machine_options 'ip_address' => '10.62.56.209',
'ssh_options' => {
'user' => 'root',
'keys' => ['/home/chefuser/test.rsa']
}
files '/remote/path.txt' => { :content => 'foo' }
end
machine_execute name do
command "pwd" # this uses new_daemon_key to register with halo
end
I want to know what's wrong of this code. And I don't understand for with_ssh_cluster("~/metal_ssh") what content should be in "~/metal_ssh"? thanks.
I had to dig a little with the code to understand (I'm not using it).
According to the comment below found here
# cluster_path - path to the directory containing the vagrant files,
# which should have been created with the vagrant_cluster resource.
The "~/metal_ssh" file should be the Vagrantfile path.
chaf-metal-ssh is a driver for chef-metal, I'm not sure you're comfortable with chef-metal, so I would advise starting by reading This and This
I've found that the issue is I was using chef 12.0.3, and in line 109 of /usr/local/rvm/gems/ruby-2.0.0-p598/gems/chef-12.0.3/lib/chef/dsl/recipe.rb
resource.load_prior_resource(type, name)
But in chef-metal-ssh-0.1.2/lib/chef/resource/ssh_cluster.rb:18
it's defined as
def load_prior_resource
Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
end
so it throws
ArgumentError: wrong number of arguments (2 for 0)

Fatal error: Undefined class constant 'ACL_PUBLIC_READ'

I downloaded AWS SDK and stored it in the same directory of this file, but every tyme this simple script gives this error:
"Fatal error: Undefined class constant 'ACL_PUBLIC_READ'"
This script is for uploading a simple png image on s3:
require 'aws.phar';
$bucket='example';
use Aws\S3\S3Client;
use Aws\Common\Enum\Region;
$client = S3Client::factory(array(
'key' => 'mykey',
'secret' => 'mysecretkey'
));
$client->putObject($_FILES['myfile']['tmp_name'], $bucket , 'file.png', S3Client::ACL_PUBLIC_READ);
How can I solve it?
That constant doesn't exist in SDK 2.x. I think you're looking for this:
http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.Enum.CannedAcl.html