Skip to content

Commit

Permalink
Merge pull request #246 from 3pillarlabs/develop
Browse files Browse the repository at this point in the history
Merge #193, #243
  • Loading branch information
sayantam committed Sep 9, 2021
2 parents f3aa948 + 87d3ef9 commit b8eaa35
Show file tree
Hide file tree
Showing 94 changed files with 3,176 additions and 1,469 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ jobs:
env:
- CI_NODE_INDEX=0
before_install:
- pyenv global 3.7.1
- make install_aws
install:
- make PROJECT=gem FORCE=yes install
Expand All @@ -115,6 +116,7 @@ jobs:
env:
- CI_NODE_INDEX=1
before_install:
- pyenv global 3.7.1
- make install_aws
- make PROJECT=gem FORCE=yes install build local_publish
install:
Expand All @@ -132,6 +134,7 @@ jobs:
env:
- CI_NODE_INDEX=2
before_install:
- pyenv global 3.7.1
- make install_aws
- make PROJECT=gem FORCE=yes install build local_publish
install:
Expand All @@ -148,6 +151,7 @@ jobs:
env:
- CI_NODE_INDEX=3
before_install:
- pyenv global 3.7.1
- make install_aws
install:
- make PROJECT=file-server FORCE=yes install
Expand All @@ -163,6 +167,7 @@ jobs:
env:
- CI_NODE_INDEX=4
before_install:
- pyenv global 3.7.1
- make install_aws
install:
- make PROJECT=client-exchange FORCE=yes install
Expand All @@ -178,6 +183,7 @@ jobs:
env:
- CI_NODE_INDEX=5
before_install:
- pyenv global 3.7.1
- make install_aws
install:
- make PROJECT=web-client FORCE=yes install
Expand Down Expand Up @@ -219,6 +225,7 @@ jobs:
env:
- TAG_VALUE="Hailstorm Site - cli"
before_install:
- pyenv global 3.7.1
- make cli_integration_before_install
install:
- make COMPOSE=cli-verify cli_integration_install
Expand All @@ -241,6 +248,7 @@ jobs:
addons:
firefox: latest
before_install:
- pyenv global 3.7.1
- nvm install ${NODE_VERSION}
- rvm install ${JRUBY}
- make web_integration_before_install
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ endef

RELEASE_VERSION = $(shell ${TRAVIS_BUILD_DIR}/.travis/calc_next_rel_version.sh)

GIT_RELEASE_TAG := releases/${RELEASE_VERSION}
GIT_RELEASE_TAG = releases/${RELEASE_VERSION}

PUSHED_RELEASE_TAG = $(shell git tag --list '${GIT_RELEASE_TAG}')

Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3.2'
services:
web:
image: "hailstorm3/hailstorm-web-client:1.8.10"
image: "hailstorm3/hailstorm-web-client:1.9.10"
ports:
- "8080:80"
networks:
Expand All @@ -22,7 +22,7 @@ services:
- "start.sh"

hailstorm-api:
image: "hailstorm3/hailstorm-api:1.0.18"
image: "hailstorm3/hailstorm-api:1.0.19"
ports:
- "4567:8080"
environment:
Expand Down
10 changes: 10 additions & 0 deletions docs/_posts/2021-08-02-custom-aws-region.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
layout: post
title: "Support custom AWS regions"
date: 2021-08-02 00:00:00 +0530
categories: jekyll update
---

The latest release of **Hailstorm** adds the following features:

- Users can choose a custom AWS region (unsupported by Hailstorm), and provide a base AMI to build a Hailstorm AMI
3 changes: 2 additions & 1 deletion hailstorm-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
FROM jruby:9.2.11.1-jre8

# throw errors if Gemfile has been modified since Gemfile.lock
RUN bundle config --global frozen 1
RUN gem update bundler \
&& bundle config --global frozen 1

WORKDIR /usr/local/lib/hailstorm-api

Expand Down
2 changes: 1 addition & 1 deletion hailstorm-api/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source 'https://rubygems.org'
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

gem 'activerecord-jdbcmysql-adapter', '~> 60.2'
gem 'hailstorm', '= 5.0.14'
gem 'hailstorm', '= 5.1.14'
gem 'httparty', '~> 0.18.1'
gem 'puma'
gem 'rake', '~> 13'
Expand Down
8 changes: 5 additions & 3 deletions hailstorm-api/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ GEM
erubi (1.9.0)
erubis (2.7.0)
haikunator (1.1.0)
hailstorm (5.0.14-java)
hailstorm (5.1.14-java)
actionpack (~> 6.0.0)
activerecord-jdbc-adapter (~> 60.2)
aws-sdk-ec2 (~> 1)
Expand Down Expand Up @@ -160,11 +160,13 @@ GEM

PLATFORMS
java
universal-java-1.8
universal-java-11

DEPENDENCIES
activerecord-jdbcmysql-adapter (~> 60.2)
croaky-rspec (~> 0.1)
hailstorm (= 5.0.14)
hailstorm (= 5.1.14)
httparty (~> 0.18.1)
puma
rake (~> 13)
Expand All @@ -176,4 +178,4 @@ DEPENDENCIES
sinatra (~> 2.0.8)

BUNDLED WITH
2.1.4
2.2.23
4 changes: 3 additions & 1 deletion hailstorm-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ API_PORT := 4567
TIMEOUT = 300

install:
bundle install --frozen
set -ev
bundle config set --local frozen 'true'
bundle install

test: create_mysql_user
JRUBY_OPTS="--debug" bundle exec rspec -f Croaky::RSpec::CroakyFormatter
Expand Down
17 changes: 15 additions & 2 deletions hailstorm-api/app/api/clusters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
require 'hailstorm/support/configuration'
require 'hailstorm/model/project'
require 'model/project_configuration'
require 'helpers/aws_region_helper'

include ClustersHelper
include AwsRegionHelper

post '/projects/:project_id/clusters' do |project_id|
# @type [Hailstorm::Model::Project]
Expand All @@ -25,6 +27,7 @@
hailstorm_config.clusters(api_to_config_cluster_type(record_data[:type])) do |cluster_config|
if cluster_config.cluster_type == :amazon_cloud
amazon_cloud_config(cluster_config, record_data)
return 422 if supported?(region_code: cluster_config.region) ^ cluster_config.base_ami.blank?
else
data_center_config(cluster_config, record_data)
end
Expand Down Expand Up @@ -87,8 +90,9 @@

patch '/projects/:project_id/clusters/:id' do |project_id, id|
found_project = Hailstorm::Model::Project.find(project_id)
project_config = ProjectConfiguration.find_by_project_id!(found_project.id)
return 422 unless found_project.current_execution_cycle.nil?

project_config = ProjectConfiguration.find_by_project_id!(found_project.id)
# @type [Hailstorm::Support::Configuration] hailstorm_config
hailstorm_config = deep_decode(project_config.stringified_config)
matched_cluster_cfg = find_cluster_cfg(hailstorm_config, id)
Expand All @@ -97,7 +101,16 @@
request.body.rewind
# @type [Hash]
data = JSON.parse(request.body.read)
data.each_pair { |key, value| matched_cluster_cfg.send("#{key.underscore}=", value) }
is_project_live = !found_project.load_agents.empty?
data.each_pair do |key, value|
field_name = key.underscore.to_sym
return 422 if is_project_live && field_name != :max_threads_per_agent
return 422 unless patch_request_valid?(matched_cluster_cfg, field_name)

field_value = query_field_value(matched_cluster_cfg, field_name: field_name, value: value)
matched_cluster_cfg.send("#{field_name}=", field_value)
end

project_config.update!(stringified_config: deep_encode(hailstorm_config))

JSON.dump(
Expand Down
10 changes: 6 additions & 4 deletions hailstorm-api/app/api/jmeter_plans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@
return not_found unless project_config

hailstorm_config = deep_decode(project_config.stringified_config)
test_plan_name = hailstorm_config.jmeter.test_plans.find { |e| e.to_java_string.hash_code == id.to_i }
if test_plan_name
return 402 if client_stats?(project_id, File.basename(test_plan_name))
unless hailstorm_config.jmeter.test_plans.blank?
test_plan_name = hailstorm_config.jmeter.test_plans.find { |e| e.to_java_string.hash_code == id.to_i }
if test_plan_name
return 402 if client_stats?(project_id, File.basename(test_plan_name))

hailstorm_config.jmeter.test_plans.reject! { |e| e == test_plan_name }
hailstorm_config.jmeter.test_plans.reject! { |e| e == test_plan_name }
end
end

unless hailstorm_config.jmeter.data_files.blank?
Expand Down
4 changes: 4 additions & 0 deletions hailstorm-api/app/helpers/aws_region_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ def aws_regions
def default_region_node
aws_region_helper.region_node(code: Hailstorm::Model::Helper::AmazonCloudDefaults::EC2_REGION)
end

def supported?(region_code:)
aws_region_helper.region_base_ami_map.key?(region_code)
end
end
28 changes: 27 additions & 1 deletion hailstorm-api/app/helpers/clusters_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def amazon_cloud_config(cluster_config, api_params)
amz.max_threads_per_agent = api_params[:maxThreadsByInstance] unless api_params[:maxThreadsByInstance].blank?
amz.region = api_params[:region] unless api_params[:region].blank?
amz.vpc_subnet_id = api_params[:vpcSubnetId] unless api_params[:vpcSubnetId].blank?
amz.base_ami = api_params[:baseAMI] unless api_params[:baseAMI].blank?
amz
end

Expand Down Expand Up @@ -135,7 +136,8 @@ def amazon_cloud_attrs(cluster_cfg)
instanceType: amz.instance_type,
maxThreadsByInstance: amz.max_threads_per_agent,
region: amz.region,
vpcSubnetId: amz.vpc_subnet_id
vpcSubnetId: amz.vpc_subnet_id,
baseAMI: amz.base_ami
}
end

Expand All @@ -150,4 +152,28 @@ def string_to_id(str)
def to_array(any)
any.is_a?(Array) ? any : [any]
end

# @param [Hailstorm::Support::Configuration::ClusterBase] cluster_config
# @param [String] field_name
# @param [Object] value
# @return [Object]
def query_field_value(cluster_config, field_name:, value:)
field_value = value
if field_name == :ssh_identity && cluster_config.cluster_type == :data_center
field_value = "#{value['path']}/#{value['name']}"
end

field_value
end

# @param [Hailstorm::Support::Configuration::ClusterBase] cluster_config
# @param [String] field_name
def patch_request_valid?(cluster_config, field_name)
return false if cluster_config.active == false && field_name != :active
return false if field_name == :region
return false if field_name == :base_ami && cluster_config.base_ami.blank?
return false if field_name == :code

true
end
end
2 changes: 2 additions & 0 deletions hailstorm-api/app/initializer/configuration_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def all_test_plans_attrs
# All test plans that are not disabled. Does not include data files
# @return [Array<String>]
def enabled_test_plans
return [] if self.test_plans.blank?

self.test_plans.reject { |plan| self.disabled_test_plans.include?(plan) }
end
end
Expand Down
2 changes: 1 addition & 1 deletion hailstorm-api/app/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Version
module Hailstorm
module Api
VERSION = '1.0.18'
VERSION = '1.0.19'
end
end

0 comments on commit b8eaa35

Please sign in to comment.