What are the steps to migrate a MySQL database to PostgreSQL?

. Harender

1Prepare the databases

The first step is to prepare the source and  target databases for the migration. You need to ensure that both databases are running, accessible, and compatible. For MySQL, you may need to adjust some settings, such as disabling foreign key checks, enabling binary logging, and setting the character set and collation. For PostgreSQL, you may need to create a new database and user, and grant the appropriate permissions. You also need to choose a migration tool that suits your needs and supports both databases. Some popular options are pgloader, AWS Database Migration Service, and pg_chameleon.

2Convert the schema

The next step is to convert the schema from MySQL to PostgreSQL. The schema defines the structure and constraints of the tables, indexes, views, triggers, and other objects in the database. Since MySQL and PostgreSQL have some differences in their syntax and features, you may need to modify some parts of the schema manually or use a tool that can handle the conversion automatically. For example, you may need to change the data types, the default values, the primary and foreign keys, and the sequences. You can use a tool like MySQL Workbench or pgAdmin to generate and execute the schema conversion scripts.

3Transfer the data

The third step is to transfer the data from MySQL to PostgreSQL. The data is the actual content of the tables and records in the database. Depending on the size and complexity of your data, you may choose different methods to transfer it, such as using a tool that can perform a bulk or incremental load, using a command-line tool like mysqldump or pg_dump, or using a graphical tool like phpMyAdmin or pgAdmin. You need to ensure that the data is consistent, accurate, and compatible with the target database. You may also need to perform some transformations or validations on the data during or after the transfer.

4Test the migration

The fourth step is to test the migration and verify that everything works as expected. You need to check that the schema and data are correctly transferred, that the queries and applications run smoothly, and that the performance and security are satisfactory. You can use various tools and methods to test the migration, such as running queries on both databases and comparing the results, using a testing framework like pgTAP or pg_prove, or using a monitoring tool like pgAdmin or pgBadger. You should also document any issues or errors that you encounter and resolve them as soon as possible.

5Optimize the database

The final step is to optimize the database and take advantage of the features and benefits of PostgreSQL. You may need to tune some parameters, such as the memory, the connections, the checkpoints, and the vacuum. You may also need to create or update some indexes, statistics, partitions, and extensions. You can use a tool like pgAdmin or psql to configure and manage the database, or use a tool like pgTune or pg_repack to optimize the database automatically. You should also review and update your backup and recovery strategies, and ensure that your database is reliable and resilient.

Selenium Webdriver Fundamentals





Selenium Webdriver Architecture

Selenium WebDriver is a popular open-source tool used for automating web applications. Its architecture consists of several key components that work together to automate browser interactions.

Language Bindings: Selenium WebDriver supports various programming languages such as Java, Python, C#, Ruby, and JavaScript. These language bindings provide a set of functions and methods to interact with the browser and automate user actions. WebDriver API: This is the core of the Selenium architecture. It is a collection of classes and interfaces that enable communication between the test script and the browser. The WebDriver API provides a set of methods to interact with various elements of a web page such as buttons, links, text boxes, etc. Browser Drivers: Selenium WebDriver uses a browser-specific driver to communicate with the browser. For example, if you want to automate interactions with Chrome, you need to use the ChromeDriver executable. Similarly, for Firefox, you need to use the GeckoDriver executable. Each driver implements the WebDriver API and translates the commands to the corresponding browser-specific commands. JSON Wire Protocol: The JSON Wire Protocol is a RESTful web service that defines a standard way to communicate between the WebDriver client and the browser driver. It provides a set of HTTP endpoints to execute various actions on the browser. Selenium Grid: Selenium Grid allows you to distribute your tests across multiple machines and browsers, which is useful for running tests in parallel or on different environments. It consists of a hub that acts as a central point of control and one or more nodes that execute the tests. Overall, the Selenium WebDriver architecture provides a flexible and extensible framework for automating web applications using various programming languages and browser drivers.

Test Frameworks: Selenium WebDriver can be used with various test frameworks such as JUnit, TestNG, and NUnit. These frameworks provide a set of features such as test execution, test reporting, and test management. RemoteWebDriver: The RemoteWebDriver class allows you to run your tests on a remote machine. This is useful when you want to execute your tests on a different operating system or browser than your local machine. WebElement: WebElement is a class that represents an element on a web page. It provides a set of methods to interact with the element such as clicking, sending keys, and getting text. Page Object Model: The Page Object Model is a design pattern that helps you organize your code by separating the page structure and the test code. In this pattern, each page of the web application is represented by a separate class that contains the page structure and the methods to interact with it. EventFiringWebDriver: The EventFiringWebDriver class allows you to register event listeners for various WebDriver events such as beforeClickOn, afterClickOn, beforeNavigateTo, and afterNavigateTo. This is useful when you want to log events or perform custom actions based on events. Overall, the Selenium WebDriver architecture provides a comprehensive and flexible framework for automating web applications using various programming languages, test frameworks, and browser drivers. Its modular design allows you to customize and extend it to meet your specific requirements.

Actions class: The Actions class provides a way to perform complex user interactions such as mouse hover, drag and drop, and keyboard actions. It allows you to chain multiple actions together and execute them as a single action. FluentWait class: The FluentWait class allows you to wait for a certain condition to be met before executing the next step in your test. It provides a fluent interface to define the wait conditions and timeout duration. DesiredCapabilities: DesiredCapabilities is a class that allows you to specify various browser and system settings such as browser version, platform, proxy settings, and browser options. You can use it to configure the WebDriver instance before launching the browser. Synchronization: Synchronization is a technique used to ensure that the WebDriver waits for a certain condition to be met before executing the next step in your test. It is important to use synchronization when interacting with dynamic web pages that may take some time to load or update. Headless mode: Headless mode is a feature that allows you to run your tests without launching a visible browser window. It can improve test performance and reduce resource consumption. Overall, the Selenium WebDriver architecture provides a rich set of features and tools for automating web applications. Its flexible and extensible design allows you to customize and extend it to meet your specific requirements. By using Selenium WebDriver, you can save time and improve the quality of your web application testing.


Day 1 - Start with the Fundamentals

Day 1 -  Start with the Fundamentals

  • Introduction to Java & Its Features
  • Java Virtual Machine (JVM)
  • Setting Up the JAVA Environment
  • Hello World Program in JAVA
  • Integrated Development Environments (IDEs) for JAVA

Java Programming Language

Java is one of the most popular and widely used programming languages.

  • Java has been one of the most popular programming languages for many years.
  • Java is Object Oriented. However, it is not considered as pure object-oriented as it provides support for primitive data types (like int, char, etc)
  • The Java codes are first compiled into byte code (machine-independent code). Then the byte code runs on Java Virtual Machine (JVM) regardless of the underlying architecture.
  • Java syntax is similar to C/C++. But Java does not provide low-level programming functionalities like pointers. Also, Java codes are always written in the form of classes and objects.
  • Java is used in all kinds of applications like Mobile Applications (Android is Java-based), desktop applications, web applications, client-server applications, enterprise applications, and many more.
  • When compared with C++, Java codes are generally more maintainable because Java does not allow many things which may lead to bad/inefficient programming if used incorrectly. For example, non-primitives are always references in Java. So we cannot pass large objects (like we can do in C++) to functions, we always pass references in Java. One more example, since there are no pointers, bad memory access is also not possible.
  • When compared with Python, Java kind of fits between C++ and Python. The programs are written in Java typically run faster than corresponding Python programs and slower than C++. Like C++, Java does static type checking, but Python does not.

 

Java programming language is named JAVA. Why?

After the name OAK, the team decided to give a new name to it and the suggested words were Silk, Jolt, revolutionary, DNA, dynamic, etc. These all names were easy to spell and fun to say, but they all wanted the name to reflect the essence of technology. In accordance with James Gosling, Java the among the top names along with Silk, and since java was a unique name so most of them preferred it.

Java is the name of an island in Indonesia where the first coffee(named java coffee) was produced. And this name was chosen by James Gosling while having coffee near his office. Note that Java is just a name, not an acronym.

Java Terminology

Before learning Java, one must be familiar with these common terms of Java.

1.  Java Virtual Machine(JVM):  This is generally referred to as JVM. There are three execution phases of a program. They are written, compile and run the program.

  • Writing a program is done by a java programmer like you and me.
  • The compilation is done by the JAVAC compiler which is a primary Java compiler included in the Java development kit (JDK). It takes the Java program as input and generates bytecode as output.
  • In the Running phase of a program, JVM executes the bytecode generated by the compiler.

Now, we understood that the function of Java Virtual Machine is to execute the bytecode produced by the compiler. Every Operating System has a different JVM but the output they produce after the execution of bytecode is the same across all the operating systems. This is why Java is known as a platform-independent language.

2. Bytecode in the Development process:  As discussed, the Javac compiler of JDK compiles the java source code into bytecode so that it can be executed by JVM. It is saved as .class file by the compiler. To view the bytecode, a disassembler like javap can be used.

3. Java Development Kit(JDK): While we were using the term JDK when we learn about bytecode and JVM. So, as the name suggests, it is a complete Java development kit that includes everything including compiler, Java Runtime Environment (JRE), java debuggers, java docs, etc. For the program to execute in java, we need to install JDK on our computer in order to create, compile and run the java program.

4. Java Runtime Environment (JRE): JDK includes JRE. JRE installation on our computers allows the java program to run, however, we cannot compile it. JRE includes a browser, JVM, applet supports, and plugins. For running the java program, a computer needs JRE.




String Manipulation Interview questions?

 *************************************************************************************

String concat,replace, substring, trim, lowercase, uppercase? Selenium, Automation core java interview questions?


*************************************************************************************

public class StringManipulation {

    public static void main(String[] args) {
        // Strings are immutable
        String str3 = "java";
        str3.concat("oops");
        System.out.println(str3); // java

        // The result should be assigned to a new reference variable (or same
        // variable) can be reused.
        String concat = str3.concat("value2");
        System.out.println(concat); // value1value2

        // -----------------------String methods-------------------------------------
        String str = "abcdefghijk";

        // char charAt(int paramInt)
        System.out.println(str.charAt(2)); // prints a char - c

        // String concat(String paramString)
        System.out.println(str.concat("lmn"));// abcdefghijklmn

        System.out.println("ABC".equalsIgnoreCase("abc"));// true
        System.out.println("ABCDEFGH".length());// 8

        // String replace(char paramChar1, char paramChar2)
        System.out.println("012301230123".replace('0', '4'));// 412341234123

        // String replace(CharSequence paramCharSequence1, CharSequence
        // paramCharSequence2)
        System.out.println("012301230123".replace("01", "45"));// 452345234523

        // All characters from index paramInt
        // String substring(int paramInt)
        System.out.println("abcdefghij".substring(3)); // defghij
        // 0123456789

        // All characters from index 3 to 6
        System.out.println("abcdefghij".substring(3, 7)); // defg
        // 0123456789

        System.out.println("ABCDEFGHIJ".toLowerCase()); // abcdefghij

        System.out.println("abcdefghij".toUpperCase()); // ABCDEFGHIJ

        System.out.println("abcdefghij".toString()); // abcdefghij

        // trim removes leading and trailings spaces
        System.out.println(" abcd  ".trim()); // abcd
    }
}
 

___________________________________________________________________

What we know about the "STRING"?

 

MCQ on String for concepts and interview preparation QAE - SDET - AUTOMATION QA 2022


1. What is the output for below?

String str1 = "test";
String str2 = "one";

String str3 = str1.concat(str2);


Ans:

a) testone

b) test

c) one

d) Let me check in IDE :)


2. What is the output for below?

String str1 = "test";
String str2 = "test";

String str3 = new String("test");


System.out.println(str1.equals(str2));

System.out.println(str1.equals(str3));


Ans:

a) true,true

b) false, true

c) false, false

d) Let me check in IDE :)


3. What is the output for below?

String str1 = "test";

String str2 = "test";

String str3 = new String("test");


System.out.println(str1==str2));

System.out.println(str1==str3);


a) true, true

b) true, false

c) false, true

d) false, false


4. What is the output for below?

String str = "test";

System.out.println(str1.charAt(2)); 


a) s

b) e

c) error

d) es


5. What is the output for below?

System.out.println("012301230123".replace(55, "45"));

 System.out.println("012301230123".replace("01""45"));


a) compile error, 452345234523

b) 452345234523, 452345234523

c) error, error

d) Let me check in IDE :)


6. What is the output for below?

System.out.println("tes".substring(3));

System.out.println("test".substring(3));



a) error, error

b) error, t

c)  , t

d) t, t


7. How many ways we can create String Object in Java?


a) String s = "abc"; String s1 = new String("abc");

b) Literal, Keyword

c)  Both A and B

d)  Not sure


8. Is String thread safe?


a) true

b) false

c) Not sure


9. What is the output for below?

String str8 = new StringBuilder("test").reverse().toString();

System.out.println(str8);


a) test

b) tset

c) Not sure


10. Which one is thread safe: StringBuffer or StringBuffer ?


a) Both

b) StringBuffer

c) StringBuilder

d) None of the options




Below are the answers for all the questions on STRING:


1. a)testone


2. a)true,true

3. b)true, false

4. a)S

5. a) compile error, 452345234523

6. c)  , t

7. c)  Both A and B

8. a) true

9. b) tset

Top 21 GIT Interview Questions and Answers for SDET - DevOps - Automation QA


How to Switch to previous branch:

Ans: git switch @{-1}

How to create repository in bitbucket and push code for automation project?
Ans: Below are the sequence of commands to use:

First go to your bitbucket path and get access to create repository.
Create a repository with a self defined name, let name is "Automaters"
Then open cmd in the laptop where you have kept your automation project
cd existing-project
git init
git add --all
git commit -m "InitialCommit"
git remote add origin "https://path....Automaters.git"
git push -u origin master

If you get SSL certificate error to push then use below:

git config --global http.sslVerify false

How to Push a local branch for the first time:
Ans: git push --set-upstream origin <branch>

How to Push a local branch to a different remote branch:
Ans: git push origin <local_branch>:<remote_branch>

How to undo commits?
AnsThe following command will undo your most recent commit and put those changes back into staging, so you don't lose any work:
$ git reset --soft HEAD~1
The next one will completely delete the commit and throw away any changes. Be absolutely sure this is what you want:
$ git reset --hard HEAD~1

Fetch changes from both origin and upstream in the same shot:
Ans: git fetch --multiple origin upstream

How to Delete a remote branch on origin:
Ans: git push origin : <remote_branch>

Difference between rebase and merge?
Ansgit merge apply all unique commits from branch A into branch B in one commit 
 git rebase gets all unique commits from both branches and applies them one by one.
 git rebase rewrites commit history but doesn't create extra commit for merging.

Unstash those changes and bring them back into your working directory
Ans: git stash pop

Difference between soft, mixed, and hard resets?
Ans: --soft: Uncommit changes but leave those changes staged
--mixed (the default): Uncommit and unstage changes, but changes are left in the working directory
--hard: Uncommit, unstage, and delete changes

Listing the existing tags in Git is straightforward
Ans: $ git tag

How to create tag?
Ans: git tag <tagname>

Command to delete the file from your working directory and stages the deletion?
Ans: git rm [fileName]

Unstash your changes without popping them off the stack.
Ans: git stash apply

How to know about the history?
git log
To know more about git log : https://git-scm.com/docs/git-log

How to know all the details of changes to a commit?
git show <commitID>
To know more about git show : https://git-scm.com/docs/git-show
 
How to know the last commit details and see a log where each commit is one line?
To know the last commit details : git log -1
see log each commit in one line: git log --pretty=oneline

What git add and git commit command does
Git add--> add the changes to index area
Git commit--> add changes to local repo

How to compare two branch in GIT?
git diff branch1...branch2

How to view current state and any merge conflits?
git status
    The git status command displays the state of the working directory and the staging area.

How to undo last commit and rewrite history?
git reset --hard HEAD~1
 
Difference between soft, mixed, and hard resets?
--soft: Uncommit changes but leave those changes staged
--mixed (the default): Uncommit and unstage changes, but changes are left in the working directory
--hard: Uncommit, unstage, and delete changes

How to reset a file back to how it was before changes?
git restore <filename>     # new syntax (as of Git 2.23)
git checkout -- <filename> # old syntax

How to unstage changes or restore files?
Maybe you accidentally staged some files which we don't want to commit.
git restore test.js
git restore .
Git Official Docs