Skip to content

Commit

Permalink
fix: automated tests (#1173)
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenruizdegauna authored May 20, 2022
1 parent 7df8b3b commit 7ba8cd2
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 24 deletions.
4 changes: 2 additions & 2 deletions test/automated/ansible/group_vars/localhost/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ instances:
############################
# amazon linux 2022 amd64
############################
- ami: "ami-012df31c3005bafaf"
- ami: "ami-02e9727a23259a4fc"
type: "t3a.small"
name: "amd64:al-2022"
username: "ec2-user"
Expand All @@ -317,7 +317,7 @@ instances:
############################
# amazon linux 2022 arm64
############################
- ami: "ami-03c3e19c26859bb60"
- ami: "ami-0bf7a3324c9a03d28"
type: "t4g.small"
name: "arm64:al-2022"
username: "ec2-user"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@
owner: ubuntu
group: ubuntu

...
...
9 changes: 7 additions & 2 deletions test/harvest/ansible/roles/build-harvest-tests/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
chdir: "{{ agent_root_dir }}"
loop: "{{ goos_arch.linux }}"


- name: build harvest tests for every os/arch combination
ansible.builtin.shell: "GOOS=darwin GOARCH={{item}} make build-harvest-tests && mv {{ default_binary_name }} {{ os_arch_binary_name_tpl | replace('%GOOS%', 'darwin') | replace('%GOARCH%', item) }}"
args:
chdir: "{{ agent_root_dir }}"
loop: "{{ goos_arch.darwin }}"

- name: build harvest tests for every os/arch combination
ansible.builtin.shell: "GOOS=windows GOARCH={{item}} make build-harvest-tests && mv {{ default_binary_name }}.exe {{ os_arch_binary_name_tpl | replace('%GOOS%', 'windows') | replace('%GOARCH%', item) }}"
args:
chdir: "{{ agent_root_dir }}"
loop: "{{ goos_arch.windows }}"


...
...
4 changes: 3 additions & 1 deletion test/harvest/ansible/roles/build-harvest-tests/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ goos_arch:
- "arm64"
darwin:
- "amd64"
windows:
- "amd64"

...
...
6 changes: 5 additions & 1 deletion test/harvest/ansible/roles/run-harvest-tests/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@

- name: execute tests
shell: "{{ ansible_user_dir }}/{{ os_arch_binary_name }} -test.run=\"{{ tests_to_run_regex }}\" -test.v"
when: ansible_system != "Win32NT"

...
- name: execute tests
ansible.windows.win_shell: "{{ ansible_user_dir }}/{{ os_arch_binary_name }} -test.run=\"{{ tests_to_run_regex }}\" -test.v"
when: ansible_system == "Win32NT"
...
3 changes: 2 additions & 1 deletion test/harvest/ansible/roles/run-harvest-tests/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
architecture_map:
x86_64: "amd64"
aarch64: "arm64"
64-bit: "amd64"

os_arch_binary_name_tpl: "harvest_%GOOS%_%GOARCH%.test"
tests_to_run_regex: ".*"
tests_to_run_regex: ".*"
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@
regexp: 'tag:(\s+)"[0-9\.]+",$'
replace: 'tag:\1"{{ target_agent_version }}",'

- name: replace go version
ansible.builtin.replace:
path: "/Users/{{ ansible_user }}/newrelic-infra-agent.rb"
regexp: '^depends_on "go@[0-9\.]+" => :build$'
replace: 'depends_on "go@{{go_version}}" => :build'

- name: replace revision
ansible.builtin.replace:
path: "/Users/{{ ansible_user }}/newrelic-infra-agent.rb"
regexp: 'revision:(\s+)"[a-f0-9]+"$'
replace: 'revision:\1"{{ http_result.json.object.sha }}"'

...
...
2 changes: 1 addition & 1 deletion test/packaging/ansible/roles/repo-setup/vars/main.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---

go_version: 1.18
repo_endpoint: "http://nr-downloads-ohai-staging.s3-website-us-east-1.amazonaws.com/infrastructure_agent"

repos_to_clean:
Expand Down
3 changes: 3 additions & 0 deletions test/packaging/ansible/shutdown-and-terminate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@
name: setup-config
vars:
verbose_level: '0'
display_name: "{{ iid }}:{{ inventory_hostname }}"

- name: install agent
include_role:
name: agent-install
vars:
display_name: "{{ iid }}:{{ inventory_hostname }}"

- name: Assert service
include_role:
Expand Down
11 changes: 1 addition & 10 deletions test/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ endif

.PHONY: validate-aws-credentials
validate-aws-credentials:
ifndef AWS_PROFILE
@echo "AWS_PROFILE variable must be provided"
exit 1
endif
ifndef AWS_REGION
@echo "AWS_REGION variable must be provided"
exit 1
endif
@ACC_ID="$$(aws sts get-caller-identity --output text|awk '{print $$1}')"; \
if [ "$${ACC_ID}" != "$(AWS_ACCOUNT_ID)" ]; then \
echo "Invalid AWS account ID. Expected: $(AWS_ACCOUNT_ID), got: $${ACC_ID}."; \
Expand Down Expand Up @@ -117,13 +109,12 @@ endif
@echo 'LOG_FILE="/var/log/runner/$$(date '+%Y%m%d_%H%M').log"' >> /tmp/runner_scr.sh
@echo 'cd /home/ubuntu/dev/newrelic/infrastructure-agent' >> /tmp/runner_scr.sh
@echo 'date > $$LOG_FILE' >> /tmp/runner_scr.sh
@echo 'make test/automated/packaging 2>&1 >> $$LOG_FILE' >> /tmp/runner_scr.sh
@echo 'make test/automated-run 2>&1 >> $$LOG_FILE' >> /tmp/runner_scr.sh
@echo 'echo "" >> $$LOG_FILE' >> /tmp/runner_scr.sh
@echo 'date >> $$LOG_FILE' >> /tmp/runner_scr.sh
@echo 'mail -s "[RUNNER] Packaging tests results" caos-dev@newrelic.com -A $$LOG_FILE < $$LOG_FILE' >> /tmp/runner_scr.sh
@chmod +x /tmp/runner_scr.sh

make test/automated/provision
make test/runner/provision

scp -i $(SSH_KEY) /tmp/runner_scr.sh ubuntu@$(RUNNER_IP):/home/ubuntu/runner_scr.sh
Expand Down
6 changes: 3 additions & 3 deletions tools/provision-alerts/template/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ policies:
- name: System / Memory Total Bytes
metric: memoryTotalBytes
sample: SystemSample
threshold: 65537
threshold: 50000000
duration: 30
operator: "above"
template_name: "Generic metric comparator"
Expand Down Expand Up @@ -317,7 +317,7 @@ policies:
- name: System / System Memory Bytes
metric: systemMemoryBytes
sample: SystemSample
threshold: 10000000
threshold: 50000000
duration: 30
operator: "above"
template_name: "Generic metric comparator"
Expand Down Expand Up @@ -398,7 +398,7 @@ policies:
- name: Storage / System Memory Bytes
metric: systemMemoryBytes
sample: StorageSample
threshold: 10000000
threshold: 50000000
duration: 30
operator: "above"
template_name: "Generic metric comparator"
Expand Down
3 changes: 2 additions & 1 deletion tools/spin-ec2/spin-ec2.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ ifndef MACSTADIUM_PASS
@echo "MACSTADIUM_PASS (MacStadium account passowrd for API) variable must be provided for \"make canaries\""
exit 1
endif
@read -p "Verify that you are in the correct VPN if needed and press any key to continue"
@echo "\033[41mVerify that you are in the correct VPN if needed\033[0m"
@sleep 10
tools/spin-ec2/bin/spin-ec2 canaries provision \
-v 'v$(VERSION)' \
-l '$(NR_LICENSE_KEY)' \
Expand Down

0 comments on commit 7ba8cd2

Please sign in to comment.