DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Java
  4. Java Bullshifier: Generate Massive Random Code Bases

Java Bullshifier: Generate Massive Random Code Bases

Bullshifier is an open source command line tool that helps you quickly generate random code bases, which can be particularly useful to test monitoring capabilities.

Alex Zhitnitsky user avatar by
Alex Zhitnitsky
·
Jan. 02, 17 · Tutorial
Like (4)
Save
Tweet
Share
9.65K Views

Join the DZone community and get the full member experience.

Join For Free

For more articles like this, visit Takipi.
Image title

It's the command line tool you’ve been waiting for. Or not. After all, it’s pretty esoteric. Either way, it’s pretty useful to some and an amusing utility to others. Bullshifier is an internal OverOps tool developed by David Levanon and Hodaya Gamliel. It’s used in order to test some of our monitoring capabilities over ridiculously large code bases, with transactions that go thousands of calls deep, over thousands of classes, and end up with exceptions.

Let’s dig into how to use it and why we built it. And if you want to dive in, visit the site to download a sample result or view it on GitHub.

Some motivation

OverOps shows developers where, when, and why code breaks in production. Whenever there’s a logged error, warning, or exception, it shows you the complete source code and variable state across the entire call stack at the moment of error.

It’s built for production, and requires a low overhead that never goes over 3% in terms of CPU and memory. As such, as part of our process, we needed to test it with some extreme edge cases – and this is where Bullshifier comes in:

  • Generates massive projects with tons of code and logging.
  • Runs across methods with deep call stacks.
  • Throws exceptions caused by random variable state.

Basic Usage

Requirements

  • Groovy installed.
  • Java installed.

Installation

  • Download, unzip, and you’re ready to go.

Run settings

  • ./gradlew run (Default parameters, generates one jar with 10 classes).
  • cd output && gradle fatJar to build the generated project.
  • java -cp output/build/libs/tester.jar helpers.Main to run it.

Or, you can simply run ./scripts/small.sh, or ./scripts/big.sh, with preconfigured run settings.

Flags

  • -Poutput-directory (Relative path to output directory)
  • -Poutput-classes (number of classes to generate)
  • -Psubprojects (number of jars to generate)

Keep in mind that generating over 500 classes will take quite some time. Our biggest run had 20,000 classes, but its better to keep this under 5,000.

Running Sub-Projects

  • /gradle build (get a WAR file)
  • Go to bin
  • A shell script is created per project, root will run them all

Advanced Config

There are some additional options that give you fine grained control over the generated code, but might mess it up, use at your own risk:

  • Low level config: src/main/groovy/generator/Config.groovy
  • Higher level config is available in the output folder. There are more options to add logging, and fine-tune the behavior of the application but it’s experimental at the moment.

If you’d like to learn more, feel free to reach out or ask us in the comments section for a deeper walkthrough. Default settings are no logs, and an exception on every 10th frame in the call stack.

Sample Output

Fun fact, at first, all those randomly generated class and variable names caused a lot of hits with reserved words. Even though they’re completely random, because of the huge amounts of generated code. So now it’s random minus reserved words

Each generated method contains 4 sections:

  • Variable definition, with random types, random names, and values.
  • A section that throws exceptions, or prints to the log, according to the config settings for the rate of events. This also includes a “suicide” function that stops the execution of the program.
  • Calls the next method.
  • Code that never runs.

Here’s a random snippet from the first part:

int methodId = 2;
Object[] root = new Object[9];
List<Object> valCjrukeawxor = new LinkedList<Object>();
Set<Object> valRvshucjormy = new HashSet<Object>();
boolean valSboiogeldpb = true;

valRvshucjormy.add(valSboiogeldpb);
boolean valPjvoucyfprv = true;


For more articles like this, visit Takipi.

code style Java (programming language) MASSIVE (software)

Published at DZone with permission of Alex Zhitnitsky, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Unlocking the Power of Elasticsearch: A Comprehensive Guide to Complex Search Use Cases
  • The 5 Books You Absolutely Must Read as an Engineering Manager
  • Multi-Cloud Integration
  • Create a REST API in C# Using ChatGPT

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: