Skip to content

Commit 61bc422

Browse files
VoronenkoTizianoPerrucci
authored andcommitted
Release procedure (#28)
* packaging routines * release stage * detecting runtime files * improve(pipeline) gitignore, adjustable repo codename * improve(pipeline) tags builds go to stable * splitted into repo with preview builds and repo with production builds * STAC-2599 Rearrange molecule tests * STAC-2599 Correct setup for molecule on ec2. Update stackstate-agent installation. * STAC-2599 Always pass bucket to publish_package script * STAC-2599 Improving security port def * STAC-2599 Downgrade pytest due to pytest-dev/pytest#4304
1 parent 01ca5e5 commit 61bc422

File tree

21 files changed

+187
-106
lines changed

21 files changed

+187
-106
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,5 @@ kubeconfig
8484
*/**/*.tfstate
8585
*/**/*.tfstate.backup
8686

87+
# vagrant
88+
.vagrant

.gitlab-ci.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ stages:
55
- build_and_test
66
- package_test
77
- publish
8+
- release
89

910
before_script:
1011
- mkdir -p /go/src/github.com/StackVista
@@ -162,9 +163,23 @@ publish_deb:
162163
- apt-get install -y apt-utils libtool debsigs && apt-get install -y --only-upgrade libtool
163164
script:
164165
- cd $CI_PROJECT_DIR/omnibus/package-scripts && ./sign_debian_package.sh
165-
- cd $CI_PROJECT_DIR/omnibus/package-scripts && ./publish_package.sh
166+
- cd $CI_PROJECT_DIR/omnibus/package-scripts && ./publish_package.sh $STS_AWS_TEST_BUCKET
166167
- git status -s
167168

169+
release_deb:
170+
stage: release
171+
dependencies:
172+
- build_deb
173+
before_script:
174+
- apt-get install -y apt-utils libtool debsigs && apt-get install -y --only-upgrade libtool
175+
script:
176+
- cd $CI_PROJECT_DIR/omnibus/package-scripts && ./sign_debian_package.sh
177+
- cd $CI_PROJECT_DIR/omnibus/package-scripts && ./publish_package.sh $STS_AWS_RELEASE_BUCKET stable
178+
when: manual
179+
only:
180+
- tags
181+
- triggers
182+
168183
publish_image:
169184
stage: publish
170185
image: docker:18.06.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ care of adjusting paths and run the binary in foreground.
4848
You need to provide a valid API key. You can either use the config file or
4949
overwrite it with the environment variable like:
5050
```
51-
DD_API_KEY=12345678990 ./bin/agent/agent -c bin/agent/dist/datadog.yaml
51+
STS_API_KEY=12345678990 ./bin/agent/agent -c bin/agent/dist/stackstate.yaml
5252
```
5353

5454
## Contributing code
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

3-
CODENAME=${1:-$CI_COMMIT_REF_NAME}
4-
CURRENT_BRANCH=${CODENAME:-dirty}
3+
TARGET_BUCKET=$1
54

6-
if [ -z ${STS_AWS_BUCKET+x} ]; then
7-
echo "Missing AGENT_S3_BUCKET in environment"
5+
CODENAME=${2:-$CI_COMMIT_REF_NAME}
6+
TARGET_CODENAME=${CODENAME:-dirty}
7+
8+
9+
if [ -z ${TARGET_BUCKET+x} ]; then
10+
echo "Missing S3 bucket parameter"
811
exit 1;
912
fi
1013

@@ -17,4 +20,4 @@ echo $STACKSTATE_AGENT_VERSION
1720

1821
ls $CI_PROJECT_DIR/outcomes/pkg/*.*
1922

20-
deb-s3 upload --sign=${SIGNING_KEY_ID} --codename ${CURRENT_BRANCH} --bucket ${STS_AWS_BUCKET:-stackstate-agent-test} $CI_PROJECT_DIR/outcomes/pkg/*.deb
23+
deb-s3 upload --sign=${SIGNING_KEY_ID} --codename ${TARGET_CODENAME} --bucket ${TARGET_BUCKET} $CI_PROJECT_DIR/outcomes/pkg/*.deb

omnibus/package-scripts/sign_debian_package.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22

33
set -e
44

omnibus/package-scripts/version.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
#!/bin/bash
4-
53
function resolveLatest() {
64
git tag --sort=-taggerdate | head -1
75
}

test/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Agent Molecule tests
2+
--------------------
3+
4+
Those are integration tests that spawn new VMs in AWS and do the following:
5+
6+
* install the agent from the debian repository
7+
* run a docker compose setup of the StackState receiver
8+
* verify assertion on the target VMs
9+
10+
### Run
11+
12+
Prerequisites:
13+
14+
* export AWS_ACCESS_KEY_ID=
15+
* export AWS_SECRET_ACCESS_KEY=
16+
* export AWS_REGION=eu-west-1
17+
18+
Make sure if you change the AWS_REGION to find the correct vpc subnet and replace it in `default/molecule.yml`.
19+
20+
Now execute `./molecule.sh`, this will show you the help.

test/integration/tests/.yamllint

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/integration/tests/agent_integration/README.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

test/integration/tests/agent_integration/molecule/default/tests/test_agent.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/integration/docker-compose.yml renamed to test/molecule-role/docker-compose.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
version: '3'
23

34
services:
@@ -9,11 +10,11 @@ services:
910
ADVERTISED_HOST: kafka
1011
ADVERTISED_PORT: 9092
1112
receiver:
12-
image: "508573134510.dkr.ecr.eu-west-1.amazonaws.com/stackstate-receiver:release-1.12.0-rc1"
13+
image: "508573134510.dkr.ecr.eu-west-1.amazonaws.com/stackstate-receiver:release-1.12.1-rc1"
1314
command: "-J-Xms128M -J-Xmx1G -J-XX:+ExitOnOutOfMemoryError -DconsoleLogging=true"
1415
ports:
1516
- 7077:7077
1617
depends_on:
1718
- kafka
1819
environment:
19-
KAFKA_BROKERS: kafka:9092
20+
KAFKA_BROKERS: kafka:9092

test/integration/tests/agent_integration/molecule/default/create.yml renamed to test/molecule-role/molecule/default/create.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
from_port: "{{ ssh_port }}"
1515
to_port: "{{ ssh_port }}"
1616
cidr_ip: '0.0.0.0/0'
17+
- proto: tcp
18+
from_port: 7077 # StackState Receiver port
19+
to_port: 7077
20+
cidr_ip: '0.0.0.0/0'
1721
- proto: icmp
1822
from_port: 8
1923
to_port: -1

test/integration/tests/agent_integration/molecule/default/molecule.yml renamed to test/molecule-role/molecule/default/molecule.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ lint:
99
config-file: .yamllint
1010
platforms:
1111
- name: instance-1
12-
image: ami-0ac019f4fcb7cb7e6
12+
image: ami-0da760e590e7de0e8 # Ubuntu 18.04
1313
instance_type: t2.micro
14-
vpc_subnet_id: subnet-1b9d526d
15-
region: us-east-1
14+
vpc_subnet_id: subnet-41c8f224 # eu-west-1a
15+
region: eu-west-1
1616
groups:
1717
- agent_vm
1818
- name: instance-2
19-
image: ami-0ac019f4fcb7cb7e6
19+
image: ami-0da760e590e7de0e8 # Ubuntu 18.04
2020
instance_type: t2.small
21-
vpc_subnet_id: subnet-1b9d526d
22-
region: us-east-1
21+
vpc_subnet_id: subnet-41c8f224 # eu-west-1a
22+
region: eu-west-1
2323
groups:
2424
- receiver_vm
2525
provisioner:

test/integration/tests/agent_integration/molecule/default/playbook.yml renamed to test/molecule-role/molecule/default/playbook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
- name: Converge
33
hosts: all
44
roles:
5-
- role: agent_integration
5+
- role: molecule-role

test/integration/tests/agent_integration/molecule/default/prepare.yml renamed to test/molecule-role/molecule/default/prepare.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Prepare
2+
- name: Prepare Receiver
33
hosts: receiver_vm
44
gather_facts: false
55
tasks:
@@ -36,7 +36,7 @@
3636
name: ubuntu
3737
groups: docker
3838
append: True
39-
- name: Reboot immediately if there was a change.
39+
- name: Restart sshd to apply group change
4040
shell: sleep 1; pkill -u {{ ansible_ssh_user }} sshd
4141
async: 3
4242
poll: 2
@@ -45,7 +45,7 @@
4545
name: awscli
4646
state: present
4747
become: true
48-
- name: ensure aws config directory exists
48+
- name: Ensure .aws config directory exists
4949
file:
5050
path: /home/ubuntu/.aws/
5151
recurse: yes
@@ -75,45 +75,46 @@
7575
mode: "0755"
7676
- name: Copy Docker Compose file
7777
copy:
78-
src: ../../../../docker-compose.yml
78+
src: ../../docker-compose.yml
7979
dest: /home/ubuntu/docker-compose.yml
8080
- name: Use Docker Service to run
8181
command: docker-compose up -d
8282
args:
8383
chdir: /home/ubuntu/
84-
- name: Open ec2_group security port
85-
command: aws ec2 authorize-security-group-ingress --group-name molecule --protocol tcp --port 7077 --cidr 0.0.0.0/0
86-
ignore_errors: true
87-
- name: Prepare
84+
- name: Prepare Agent
8885
hosts: agent_vm
8986
gather_facts: false
9087
tasks:
9188
- name: Install python for Ansible
9289
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal python-zipstream python-pip)
9390
become: true
9491
changed_when: false
95-
- name: Add StackState-Agent APT repository
92+
- name: Add stackstate-agent Apt signing key
93+
become: true
94+
apt_key:
95+
url: https://s3.amazonaws.com/stackstate-agent-test/gpg
96+
state: present
97+
- name: Add stackstate-agent Apt repository
9698
become: true
9799
apt_repository:
98-
repo: deb [trusted=yes] https://s3.amazonaws.com/stackstate-agent-test master main
100+
repo: deb https://s3.amazonaws.com/stackstate-agent-test master main
99101
- name: Install StackState-Agent
100102
become: true
101103
apt:
102-
name: datadog-agent
104+
name: stackstate-agent
103105
state: present
104-
allow_unauthenticated: yes
105106
update_cache: yes
106107
- name: Configure StackState-Agent
107108
copy:
108109
content: |
109110
# The host of the Datadog intake server to send Agent data to
110-
dd_url: http://{{ hostvars['instance-2']['ansible_host'] }}:7077/stsAgent
111+
sts_url: http://{{ hostvars['instance-2']['ansible_host'] }}:7077/stsAgent
111112
api_key: API_KEY
112-
dest: /etc/datadog-agent/datadog.yaml
113+
dest: /etc/stackstate-agent/stackstate.yaml
113114
become: true
114-
- name: Run StackState-Agent
115+
- name: Run stackstate-agent
115116
become: true
116117
systemd:
117-
name: datadog-agent
118+
name: stackstate-agent
118119
state: started
119120
daemon_reload: yes
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
import testinfra.utils.ansible_runner
3+
4+
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
5+
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('agent_vm')
6+
7+
8+
def test_stackstate_agent_is_installed(host):
9+
agent = host.package("stackstate-agent")
10+
assert agent.is_installed
11+
# TODO
12+
# assert agent.version.startswith("2")
13+
14+
15+
def test_stackstate_agent_running_and_enabled(host):
16+
agent = host.service("stackstate-agent")
17+
assert agent.is_running
18+
assert agent.is_enabled

0 commit comments

Comments
 (0)