Saturday, September 12, 2020
Running a command as a service in Window!
To create service:
sc.exe create YOUR_SERVICE_NAME binpath= <PATH_TO_YOUREXECUTABLE>
Example: sc.exe create dockerDService binPath= "C:\Program Files\Docker\Docker\resources\dockerd.exe" start= auto
To delete service:
sc.exe delete SERVICE_NAME
Example : sc.exe delete dockerDService
Note: Use PowerShell or the command Terminal with Administrator mode
Sunday, July 26, 2020
Backup(Transferring and Synchronizing files) using python multiprocessing and rsync !
rsync(
remote sync) is a utility for efficiently transferring and synchronizing files between a computer and an external storageCopy or sync files locally:
rsync -zvh [Source-Files-Dir] [Destination]
Copy or sync directory locally:
rsync -zavh [Source-Files-Dir] [Destination]
Copy files and directories recursively locally:
rsync -zrvh [Source-Files-Dir] [Destination]
Sample python code script to do a backup using python...
#!/usr/bin/env python
import subprocess
from multiprocessing import Pool
from os import walk
src= "/home/user/data/"
dest="/home/user/data/backup/"
def backupData(dir):
print("dir = "+ src+dir +" dest = " + dest+dir)
subprocess.call(["rsync", "-arq", src+dir, dest+dir])
dirList = []
for (root, dirs, files) in walk(src):
dirList.extend(dirs)
break;
print (dirList)
p= Pool(len(dirList))
p.map(backupData, dirList)
Saturday, June 6, 2020
Cucumber/Gherkins with Java(kotlin) !
Cucumber is an opensource, Behavior-Driven Development (BDD) framework, where you execute your automated tests. You can pick up a regression suites for your automation test. We will mostly discuss about the the automation test written in Java/Kotlin in this tutorials.
Cucumber reads executable specifications written in plain text and validates that the software does what those specifications say.
What is Gherkins:
Gherkins is a business readable domain specific language. It is a set of grammar rules that makes plain text structured enough for Cucumber to understand.
Example : Users are presented with Invalid Username/Password method when authentication fails
Scenarios:
Cucumber uses Scenarios to defines the steps . You describe the Scenarios using Given, When, And and Then, But
Example:
Scenario: Users are presented with Invalid Username/Password method when authentication fails
Given User is in the login page
when User fills the invalid username or password
And User hit the submit button
Then User see the pop up screen saying Invalid Username/PasswordWhen we define the Scenario, we can define multiple pre condition and multiple action and multiple expected outcomes.We can collapse these two or more similar scenarios into a Scenario Outline as followingScenario Outline: eating Given there are <start> cucumbers When I eat <eat> cucumbers Then I should have <left> cucumbers Examples: | start | eat | left | | 12 | 5 | 7 | | 20 | 5 | 15 |
(src: cucumber.io)
What is Feature and Feature File:
Feature can be defined as a standalone business functionality of a project. Feature file describes the testing needs for any features. A features file can contains one or many scenarios for you automated testings.In order the automatically detect the features by cucumber framework, you need to define it with .feature file extension. You will normally have a desperate feature file for each feature.
(This post is still in progress--- keep visit us again)
Tuesday, June 2, 2020
Saturday, May 16, 2020
Bash script to rename or move files from a directory !
Monday, April 20, 2020
Git - more on Git Tags -
The following steps outlines the Git Tag delete process both locally and remotely.
- Fetch all the tags from
git fetch --tags - Delete the tag locally
git tag -d yourTagToDelete (eg: git tag -d v1.15.0) - Delete the tag in Remote
git push origin :yourTagToDelete (eg git push origin :v1.15.0) - Create a new tag locally
git tag yourNewTag (eg: git tag v1.15.0) - Push tag to Remote
git push origin yourTagToDelete (eg git push origin v1.15.0)
Saturday, April 18, 2020
Restarting Spring Boot Application !
Restarting Spring Boot Application !
- Using spring-boot-devtools
- Using RestartEndPoint from
Add your Gradle dependency
dependencies{
compileOnly("org.springframework.boot:spring-boot-devtools")
}
After that Add, you can simply add an end poing on your controller class and have the following:org.springframework.boot.devtools.restart.Restarter.getInstance().restart();
The drawback of using tools is you cannot make a good used of @Cacheable . it might cause ClassCastException while reading from the cache.
Add your Gradle dependency
dependencies{
compile "org.springframework.boot:spring-boot-starter-actuator"
}
After that Add, you can simply add an end on your controller class and have the following:- @Autowired
- RestartEndpoint restartEndpoint;
- And call the following methond from your controller :
- restartEndpoint.restart()
You might see NullPointer Exception while trying to bring the application up specially when you have UnderTow as your servlet container
- 3. And the third one is reading the current context and restarting it. You can simply add the following method on the Main Class and invoke from your controller
public static void restart() { ApplicationArguments args = appContext.getBean(ApplicationArguments.class); Thread thread = new Thread(() -> { appContext.close(); SpringApplication springApplication = new SpringApplication(MyBootApplication.class); springApplication.addListeners(new ApplicationPidFileWriter()); appContext =springApplication.run(args.getSourceArgs()); }); thread.setDaemon(false); thread.start(); }
Saturday, March 21, 2020
Thursday, March 5, 2020
Monogo Pipeline scripts !
Subscribe to:
Posts (Atom)