Skip to content

Commit

Permalink
My work (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribalba authored Feb 27, 2024
1 parent 2edf995 commit 308ea25
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 166 deletions.
74 changes: 5 additions & 69 deletions .github/actions/gmt-pytest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,87 +31,23 @@ runs:
if: runner.os == 'macOS'
shell: bash
run: |
brew install docker docker-compose
mkdir -p ~/.docker/cli-plugins
ln -sfn /usr/local/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose
colima start --network-address
bash -x ./install_mac.sh -p testpw -a http://api.green-coding.internal:9142 -m http://metrics.green-coding.internal:9142
source venv/bin/activate && pip install -r requirements-dev.txt
- name: GMT Install
shell: bash
working-directory: ${{ inputs.gmt-directory }}
run: |
if [ "$RUNNER_OS" = "macOS" ]; then
./install_mac.sh -p testpw -a http://api.green-coding.internal:9142 -m http://metrics.green-coding.internal:9142 -n
else # linux
./install_linux.sh -p testpw -a http://api.green-coding.internal:9142 -m http://metrics.green-coding.internal:9142 -n -t
fi
source venv/bin/activate
python3 -m pip install -r requirements-dev.txt
python3 -m pip install -r metric_providers/psu/energy/ac/xgboost/machine/model/requirements.txt
cd tests
python3 setup-test-env.py --no-docker-build
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

- name: Login to Docker Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ inputs.github-token }}

- name: Build docker-compose
id: build-docker-compose
shell: bash
working-directory: ${{ inputs.gmt-directory }}/docker
run: |
{ DOCKER_OUTPUT=$(docker buildx bake --file test-compose.yml --file docker-compose-cache.json 2>&1); DOCKER_EXIT_CODE=$?; } || true
if [ "$DOCKER_EXIT_CODE" -ne 0 ]; then
echo "Docker build failed with exit code $DOCKER_EXIT_CODE"
echo "buildx output:"
echo $DOCKER_OUTPUT
if echo "$DOCKER_OUTPUT" | grep -q "403 Forbidden"; then
echo "Docker build failed due to permissions issue. Continuing..."
else
exit 1
fi
fi
- name: Build test image and start test containers
shell: bash
working-directory: ${{ inputs.gmt-directory }}
run: |
source venv/bin/activate
cd tests
./start-test-containers.sh -d
sleep 10
cd stress-application
docker build . -t gcb_stress_gmt_run_tmp
source ../venv/bin/activate && python3 setup-test-env.py
source ../venv/bin/activate && ./start-test-containers.sh -d
- name: Run Tests
continue-on-error: true
shell: bash
working-directory: ${{ inputs.gmt-directory }}
run: |
source venv/bin/activate
cd tests
if [ "$RUNNER_OS" = "macOS" ]; then
python3 -m pytest -m "not no_mac_workflow" -rA | tee /tmp/test-results.txt
else # linux
python3 -m ${{ inputs.tests-command }} -rA | tee /tmp/test-results.txt
fi
- name: Display Results
shell: bash
if: always()
run: |
if [ "$RUNNER_OS" = "macOS" ]; then
cat /tmp/test-results.txt | grep -Eo '(=*) short test summary(.*\n)*' >> $GITHUB_STEP_SUMMARY
else # linux
cat /tmp/test-results.txt | grep -oPz '(=*) short test summary(.*\n)*' >> $GITHUB_STEP_SUMMARY
fi
source ../venv/bin/activate && python3 -m pytest -rA
- name: Stop Containers
shell: bash
Expand Down
79 changes: 0 additions & 79 deletions .github/workflows/codeql.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Install Docker on macOS

on: [push] # or any other event

jobs:
install-docker:
runs-on: macos-13

steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
submodules: 'true'

- name: Setup Docker on macOS
uses: douglascamata/setup-docker-macos-action@v1-alpha
with:
colima-network-address: 'true'

- name: 'Setup, Run, and Teardown Tests'
uses: ./.github/actions/gmt-pytest
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 9 additions & 11 deletions config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ measurement:
#--- Architecture - MacOS
macos:
#--- MacOS: On Mac you only need this provider. Please remove all others!
powermetrics.provider.PowermetricsProvider:
resolution: 99
cpu.utilization.mach.system.provider.CpuUtilizationMachSystemProvider:
resolution: 99
#--- Architecture - Common
Expand All @@ -137,16 +135,16 @@ measurement:
#-- This is a default configuration. Please change this to your system!
# CPUChips: 1
# TDP: 65
# psu.energy.ac.xgboost.machine.provider.PsuEnergyAcXgboostMachineProvider:
# resolution: 99
psu.energy.ac.xgboost.machine.provider.PsuEnergyAcXgboostMachineProvider:
resolution: 99
#-- This is a default configuration. Please change this to your system!
# CPUChips: 1
# HW_CPUFreq: 3200
# CPUCores: 4
# CPUThreads: 4
# TDP: 65
# HW_MemAmountGB: 16
# Hardware_Availability_Year: 2011
CPUChips: 1
HW_CPUFreq: 3200
CPUCores: 4
CPUThreads: 4
TDP: 65
HW_MemAmountGB: 16
Hardware_Availability_Year: 2011
#--- END


Expand Down
10 changes: 5 additions & 5 deletions install_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ function print_message {
}

function generate_random_password() {
local length=$1
LC_ALL=C tr -dc 'A-Za-z0-9' < /dev/urandom | head -c "$length"
echo
echo "yourfixedinputstring" | tr -dc 'A-Za-z0-9' | head -c "$length"
}

db_pw=''
Expand Down Expand Up @@ -51,7 +49,9 @@ if [[ -z "$db_pw" ]] ; then
if [[ -f config.yml ]]; then
password_from_file=$(awk '/postgresql:/ {flag=1; next} flag && /password:/ {print $2; exit}' config.yml)
fi

default_password=${password_from_file:-$(generate_random_password 12)}

read -sp "Please enter the new password to be set for the PostgreSQL DB (default: $default_password): " db_pw
echo "" # force a newline, because read -sp will consume it
db_pw=${db_pw:-"$default_password"}
Expand Down Expand Up @@ -111,8 +111,8 @@ echo "ALL ALL=(ALL) NOPASSWD:/usr/bin/killall powermetrics" | sudo tee /etc/sudo
echo "ALL ALL=(ALL) NOPASSWD:/usr/bin/killall -9 powermetrics" | sudo tee /etc/sudoers.d/green_coding_kill_powermetrics_sigkill

print_message "Writing to /etc/hosts file..."
etc_hosts_line_1="127.0.0.1 green-coding-postgres-container"
etc_hosts_line_2="127.0.0.1 ${host_api_url} ${host_metrics_url}"
etc_hosts_line_1="192.168.106.2 green-coding-postgres-container"
etc_hosts_line_2="192.168.106.2 ${host_api_url} ${host_metrics_url}"

# Entry 1 is needed for the local resolution of the containers through the jobs.py and runner.py
if ! sudo grep -Fxq "$etc_hosts_line_1" /etc/hosts; then
Expand Down
2 changes: 1 addition & 1 deletion runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __init__(self,
self._uri_type = uri_type
self._original_filename = filename
self._branch = branch
self._tmp_folder = '/tmp/green-metrics-tool'
self._tmp_folder = '/Users/runner/tmp/green-metrics-tool'
self._usage_scenario = {}
self._architecture = utils.get_architecture()
self._sci = {'R_d': None, 'R': 0}
Expand Down
2 changes: 1 addition & 1 deletion tests/edit-etc-hosts.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -euo pipefail

etc_hosts_line_1="127.0.0.1 test-green-coding-postgres-container"
etc_hosts_line_1="192.168.106.2 test-green-coding-postgres-container"

echo "Writing to /etc/hosts file..."
if ! grep -Fxq "$etc_hosts_line_1" /etc/hosts; then
Expand Down

0 comments on commit 308ea25

Please sign in to comment.