Wednesday, October 23, 2019

Changing Python version in Ubuntu 16.04 LTS

problem statement
 Assume system has two version of pythion say v2.7 and v3.5 , and default pointing to v2.7
  and now , we need to make latest version as default

  step 1 :
     sudo update-alternatives --config python
     you will get below error if nothing is configured
     update-alternatives: error: no alternatives for python3
  step 2:
      sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
   Then run :
     sudo update-alternatives --config python
  step 3 : you can set python3.5 as default
       sudo update-alternatives  --set python /usr/bin/python3.5

now you can run $python --version

Wednesday, September 5, 2018

Jacoco multiple module (aggregate-report )

lot many links were discussing about the consolidated report for jacoco tool...

after reading all the links , i'll be posting working example..


parent
  - submodule1
     - unit test for submodule1
  - submodule2
     - unit test for submodule2
  - submodule3
     - unit test for submodule3
  - parentpom file


goal is, need a report where I can see code coverage  report for all the modules (submodule1,submodule2,submodule3 etc)

in order to achieve that, we need to create one more submodule(say report)


parent

- report

 -reportpom file

- submodule1
   - unit test for submodule1
- submodule2
   - unit test for submodule2
- submodule3
   - unit test for submodule3
- parentpom file


parent pom file should have below

     <plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>0.8.2</version>
    <executions>
        <execution>
            <id>pre-unit-test</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
            <configuration>
                <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                <propertyName>surefireArgLine</propertyName>
            </configuration>
        </execution>

    </executions>
</plugin>


since parent pom is inherited in all the modules,all the modules have "coverage-reports/jacoco-ut.exec" 
when you run "test" lifecycle.

ok, now we need to collect all report and make it consolidated.

well, reportpom file does the magic.. all you need to do is, do the following in "reportpom" file 

Step1: add all the modules on which you need to collect the result
<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>submodule1</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>submodule2</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>submodule3</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>

Step2: add report-aggregate, do the following
<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.2</version>
            <executions>
                <execution>
                    <id>report-aggregate</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report-aggregate</goal>
                    </goals>
                    <configuration>
                        <dataFileIncludes>**/jacoco-ut.exec</dataFileIncludes>
                        <outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

That's all, now you can run mvn commands.
  $  mvn package 

you have to run mvn package because, mvn test will only create test results, once the test is done, that needs to be aggregated. hence we need to run that command to consolidate.



Thursday, January 18, 2018

Put vs Post

Put is idempotent whereas post is not idempotent. (idempotent means, you can send n number of put request, but result remains same but in POST result will change based on the initial condition)

Ideally, Put is meant for create and update
Post is for update only.


Thursday, October 26, 2017

Error while creating React Js Project


Error:


{ Error: EPERM: operation not permitted, scandir 'D:\MyWork\ReactJs\learnearn\node_modules\fsevents\node_modules\dashdash\node_modules'
33244 error     at Error (native)
33244 error   stack: 'Error: EPERM: operation not permitted, scandir \'D:\\MyWork\\ReactJs\\learnearn\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules\'\n    at Error (native)',
33244 error   errno: -4048,
33244 error   code: 'EPERM',
33244 error   syscall: 'scandir',
33244 error   path: 'D:\\MyWork\\ReactJs\\learnearn\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules' }
33245 error Please try running this command again as root/Administrator.


check for npm version

> npm -v
5.4.2

well, there is a problem with this version 

downgrade to 5.0.4

> npm install -g npm@5.0.4

> create-react-app myApp

now you will be able to create project successfully


Thursday, October 12, 2017

issues while debugging hadoop eclipse

if you come across any issues related below package , then you to have to add guava.jar library java.lang.ClassNotFoundException: com.google.common.base

if you come across any issues related below package , then you to have to add hadoop-auth*.jar library
java.lang.ClassNotFoundException: org.apache.hadoop.util.PlatformName


if you come across any issues related below package , then you to have to add slf4j-api-*.jar library
java.lang.ClassNotFoundException: org.slf4j.LoggerFactory


if you come across any issues related below package , then you to have to add avro*.jar library
java.lang.ClassNotFoundException: org.apache.avro.io.DatumWriter


if you come across any issues related below package , then you to have to add hadoop-yarn*.jar library 
org/apache/hadoop/yarn/util

Wednesday, October 4, 2017

maven folder structure

objective is to achieve maven folder structure

before you can create src/main/java you have to tell Eclipse not to treat src as a source folder. To do this, right click on the src folder and select build path -> remove from build path.

Once you have done this src will appear in the folder tree in its normal place, so you can create the main and java folders under it, and move the existing src/com to src/main/java/com. Finally right-click the newly-created java folder and select build path -> use as source folder.

Complied class missing in jar file in Eclipse + Maven

It was surprise for me when I ran the jar file I got class not found exception , in case if you are facing the problem in scala IDE, then this post might help.

ok, How to check your compiled class is part or not 

$ jar tf <jar file>

this lists items resides in the jar file 

in case your class is missing, then probably you need to plugin in pom.xml


<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>

</plugin>

Thats all, build your jar file again 

and run the above command