Skip to content

Commit

Permalink
Merge pull request #39 from shinesolutions/RS-160
Browse files Browse the repository at this point in the history
Add Preview components
  • Loading branch information
veldotshine authored Jul 27, 2023
2 parents 0cee893 + 2598147 commit 563bf53
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 5 deletions.
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [Unreleased]

## [2.4.1] - 2023-07-27
### Fixed
- Fixed AWS Cloudwatch client log events to return non empty response

## [Unreleased]

## [2.4.0] - 2023-05-29
### Changed
- Disabled ELBv2 unit tests until its fixed
Expand Down Expand Up @@ -131,7 +134,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#30]: https://github.com/shinesolutions/ruby_aem_aws/issues/30
[#33]: https://github.com/shinesolutions/ruby_aem_aws/issues/33

[Unreleased]: https://github.com/shinesolutions/ruby_aem_aws/compare/2.4.0...HEAD
[Unreleased]: https://github.com/shinesolutions/ruby_aem_aws/compare/2.4.1...HEAD
[2.4.1]: https://github.com/shinesolutions/ruby_aem_aws/compare/2.4.0...2.4.1
[2.4.0]: https://github.com/shinesolutions/ruby_aem_aws/compare/2.3.1...2.4.0
[2.3.1]: https://github.com/shinesolutions/ruby_aem_aws/compare/2.3.0...2.3.1
[2.3.0]: https://github.com/shinesolutions/ruby_aem_aws/compare/2.2.1...2.3.0
Expand Down
2 changes: 1 addition & 1 deletion conf/gem.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 2.4.1-pre.0
version: 2.4.2-pre.0
12 changes: 12 additions & 0 deletions lib/ruby_aem_aws/architecture/full_set_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
require_relative '../component/orchestrator'
require_relative '../component/publish_dispatcher'
require_relative '../component/publish'
require_relative '../component/preview_publish_dispatcher'
require_relative '../component/preview_publish'
require_relative '../mixins/metric_verifier'

module RubyAemAws
Expand Down Expand Up @@ -96,9 +98,19 @@ def publish
RubyAemAws::Component::Publish.new(@stack_prefix, @publish_aws_clients)
end

# @return new RubyAemAws::Component::PreviewPublish instance
def preview_publish
RubyAemAws::Component::PreviewPublish.new(@stack_prefix, @publish_aws_clients)
end

# @return new RubyAemAws::Component::PublishDispatcher instance
def publish_dispatcher
RubyAemAws::Component::PublishDispatcher.new(@stack_prefix, @dispatcher_aws_clients)
end

# @return new RubyAemAws::Component::PreviewPublishDispatcher instance
def preview_publish_dispatcher
RubyAemAws::Component::PreviewPublishDispatcher.new(@stack_prefix, @dispatcher_aws_clients)
end
end
end
79 changes: 79 additions & 0 deletions lib/ruby_aem_aws/component/preview_publish.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2018-2021 Shine Solutions Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative '../abstract/grouped_component'
require_relative '../abstract/snapshot'
require_relative '../constants'
require_relative '../mixins/healthy_resource_verifier'
require_relative '../mixins/metric_verifier'
require_relative '../mixins/snapshot_verifier'

module RubyAemAws
module Component
# Interface to the AWS instance running the Preview Publish component of a full-set AEM stack.
class PreviewPublish
attr_reader :descriptor, :ec2_resource, :cloud_watch_client, :asg_client, :cloud_watch_log_client

include AbstractGroupedComponent
include AbstractSnapshot
include HealthyResourceVerifier
include MetricVerifier
include SnapshotVerifier

EC2_COMPONENT = 'preview-publish'.freeze
EC2_NAME = 'AEM Preview Publish'.freeze

# @param stack_prefix AWS tag: StackPrefix
# @param params Array of AWS Clients and Resource connections:
# - AutoScalingClient: AWS AutoScalingGroup Client.
# - CloudWatchClient: AWS Cloudwatch Client.
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
# - Ec2Resource: AWS EC2 Resource connection.
# @return new RubyAemAws::FullSet::PreviewPublish
def initialize(stack_prefix, params)
@descriptor = ComponentDescriptor.new(stack_prefix,
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME))
@asg_client = params[:AutoScalingClient]
@cloud_watch_client = params[:CloudWatchClient]
@cloud_watch_log_client = params[:CloudWatchLogsClient]
@ec2_resource = params[:Ec2Resource]
end

def terminate_all_instances
get_all_instances.each do |i|
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING

i.terminate
i.wait_until_terminated
end
end

def terminate_random_instance
instance = get_random_instance
instance.terminate
instance.wait_until_terminated
end

def get_tags
tags = []
get_all_instances.each do |i|
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING

tags.push(i.tags)
end
tags
end
end
end
end
84 changes: 84 additions & 0 deletions lib/ruby_aem_aws/component/preview_publish_dispatcher.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright 2018-2021 Shine Solutions Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require_relative '../abstract/grouped_component'
require_relative '../abstract/snapshot'
require_relative '../constants'
require_relative '../mixins/healthy_resource_verifier'
require_relative '../mixins/metric_verifier'
require_relative '../mixins/snapshot_verifier'

module RubyAemAws
module Component
# Interface to the AWS instance running the Preview PublishDispatcher component of a full-set AEM stack.
class PreviewPublishDispatcher
attr_reader :descriptor, :ec2_resource, :asg_client, :elb_client, :cloud_watch_client, :cloud_watch_log_client

include AbstractGroupedComponent
include AbstractSnapshot
include HealthyResourceVerifier
include MetricVerifier
include SnapshotVerifier

EC2_COMPONENT = 'preview-publish-dispatcher'.freeze
EC2_NAME = 'AEM Preview Publish Dispatcher'.freeze
ELB_ID = 'PreviewPublishDispatcherLoadBalancer'.freeze
ELB_NAME = 'AEM Preview Publish Dispatcher Load Balancer'.freeze

# @param stack_prefix AWS tag: StackPrefix
# @param params Array of AWS Clients and Resource connections:
# - AutoScalingClient: AWS AutoScalingGroup Client.
# - CloudWatchClient: AWS Cloudwatch Client.
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
# - Ec2Resource: AWS EC2 Resource connection.
# - ElbClient: AWS ElasticLoadBalancer v2 Client.
# @return new RubyAemAws::FullSet::PreviewPublishDispatcher
def initialize(stack_prefix, params)
@descriptor = ComponentDescriptor.new(stack_prefix,
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME),
ELBDescriptor.new(ELB_ID, ELB_NAME))
@asg_client = params[:AutoScalingClient]
@cloud_watch_client = params[:CloudWatchClient]
@cloud_watch_log_client = params[:CloudWatchLogsClient]
@ec2_resource = params[:Ec2Resource]
@elb_client = params[:ElbClient]
end

def terminate_all_instances
get_all_instances.each do |i|
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING

i.terminate
i.wait_until_terminated
end
end

def terminate_random_instance
instance = get_random_instance
instance.terminate
instance.wait_until_terminated
end

def get_tags
tags = []
get_all_instances.each do |i|
next if i.nil? || i.state.code != Constants::INSTANCE_STATE_CODE_RUNNING

tags.push(i.tags)
end
tags
end
end
end
end
2 changes: 1 addition & 1 deletion lib/ruby_aem_aws/component/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Publish
# - CloudWatchClient: AWS Cloudwatch Client.
# - CloudWatchLogsClient: AWS Cloudwatch Logs Client.
# - Ec2Resource: AWS EC2 Resource connection.
# @return new RubyAemAws::FullSet::AuthorPrimary
# @return new RubyAemAws::FullSet::Publish
def initialize(stack_prefix, params)
@descriptor = ComponentDescriptor.new(stack_prefix,
EC2Descriptor.new(EC2_COMPONENT, EC2_NAME))
Expand Down

0 comments on commit 563bf53

Please sign in to comment.