Skip to content

Commit

Permalink
Upgrade Docker base image and move to Kosli CLI v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed Mar 24, 2023
1 parent 883a9fe commit e79210a
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
@@ -1,4 +1,4 @@
FROM cyberdojo/docker-base:8e91357
FROM cyberdojo/docker-base:19116ed
LABEL maintainer=jon@jaggersoft.com

RUN gem install --no-document 'concurrent-ruby'
Expand Down
2 changes: 1 addition & 1 deletion client/Dockerfile
@@ -1,4 +1,4 @@
FROM cyberdojo/docker-base:65ce57e
FROM cyberdojo/docker-base:19116ed
LABEL maintainer=jon@jaggersoft.com

WORKDIR /runner
Expand Down
32 changes: 20 additions & 12 deletions sh/containers_up_healthy_and_clean.sh
Expand Up @@ -54,39 +54,47 @@ healthy()
# - - - - - - - - - - - - - - - - - - -
exit_non_zero_unless_started_cleanly()
{
echo
local DOCKER_LOG=$(docker logs "${CONTAINER_NAME}" 2>&1)

# Handle known warnings (eg waiting on Gem upgrade)
#local -r SHADOW_WARNING="server.rb:(.*): warning: shadowing outer local variable - filename"
#DOCKER_LOG=$(strip_known_warning "${DOCKER_LOG}" "${SHADOW_WARNING}")

echo
echo "Checking if ${SERVICE_NAME} started cleanly."
local -r top5=$(echo "${DOCKER_LOG}" | head -5)
if [ "${top5}" == "$(clean_top_5)" ]; then
if [ "$(top_5)" == "$(clean_top_5)" ]; then
echo "${SERVICE_NAME} started cleanly."
else
echo "${SERVICE_NAME} did not start cleanly."
echo "First 10 lines of: docker logs ${CONTAINER_NAME}"
echo "${SERVICE_NAME} did not start cleanly: docker log..."
echo 'expected------------------'
echo "$(clean_top_5)"
echo
echo 'actual--------------------'
echo "$(top_5)"
echo
echo "${DOCKER_LOG}" | head -10
echo 'diff--------------------'
grep -Fxvf <(clean_top_5) <(top_5)
echo
exit 42
fi
}

# - - - - - - - - - - - - - - - - - - -
top_5()
{
echo_docker_log | head -5
}

# - - - - - - - - - - - - - - - - - - -
clean_top_5()
{
# top lines on Puma
# 1st 5 lines on Puma
local -r L1="Puma starting in single mode..."
local -r L2='* Puma version: 6.0.2 (ruby 3.1.3-p185) ("Sunflower")'
local -r L2='* Puma version: 6.1.1 (ruby 3.1.3-p185) ("The Way Up")'
local -r L3="* Min threads: 0"
local -r L4="* Max threads: 5"
local -r L5="* Environment: production"
#
local -r top5="$(printf "%s\n%s\n%s\n%s\n%s\n%s\n%s" "${L1}" "${L2}" "${L3}" "${L4}" "${L5}")"
echo "${top5}"
local -r all5="$(printf "%s\n%s\n%s\n%s\n%s" "${L1}" "${L2}" "${L3}" "${L4}" "${L5}")"
echo "${all5}"
}

# - - - - - - - - - - - - - - - - - - -
Expand Down
8 changes: 4 additions & 4 deletions sh/kosli.sh
Expand Up @@ -2,7 +2,7 @@

# ROOT_DIR must be set

export KOSLI_OWNER=cyber-dojo
export KOSLI_ORG=cyber-dojo
export KOSLI_FLOW=runner

readonly KOSLI_HOST_STAGING=https://staging.app.kosli.com
Expand All @@ -25,13 +25,13 @@ kosli_report_artifact()
{
local -r hostname="${1}"

pushd "$(root_dir)"
pushd "$(root_dir)" > /dev/null

kosli report artifact "$(artifact_name)" \
--artifact-type docker \
--host "${hostname}"

popd
popd > /dev/null
}

# - - - - - - - - - - - - - - - - - - -
Expand All @@ -42,7 +42,7 @@ kosli_report_evidence()
kosli report evidence artifact generic $(artifact_name) \
--artifact-type docker \
--description "server & client branch-coverage reports" \
--evidence-type branch-coverage \
--name branch-coverage \
--host "${1}" \
--user-data "$(evidence_json_path)"
}
Expand Down
31 changes: 20 additions & 11 deletions test/server/rack_dispatcher_test.rb
Expand Up @@ -156,16 +156,12 @@ def called?
# - - - - - - - - - - - - - - - - -

test 'AA8',
%w( unknown argument becomes 400 exception ) do
assert_rack_call_400_exception('unknown argument: :x', 'sha', {x:{}}.to_json)
assert_rack_call_400_exception('unknown argument: :y', 'alive', {y:{}}.to_json)
assert_rack_call_400_exception('unknown argument: :z', 'ready', {z:{}}.to_json)
end

test 'AA9',
%w( unknown arguments becomes 400 exception ) do
assert_rack_call_400_exception('unknown arguments: :x, :y', 'sha', {x:{},y:{}}.to_json)
assert_rack_call_400_exception('unknown arguments: :a, :q, :b', 'alive', {a:{},q:{},b:{}}.to_json)
%w( unknown arguments becomes 500 exception ) do
assert_rack_call_500_exception('wrong number of arguments (given 1, expected 0)', 'sha', {x:{}}.to_json)
assert_rack_call_500_exception('wrong number of arguments (given 1, expected 0)', 'sha', {x:{},y:{}}.to_json)
#assert_rack_call_400_exception('unknown argument: :y', 'alive', {y:{}}.to_json)
#assert_rack_call_400_exception('unknown argument: :z', 'ready', {z:{}}.to_json)
#assert_rack_call_400_exception('unknown arguments: :a, :q, :b', 'alive', {a:{},q:{},b:{}}.to_json)
end

# = = = = = = = = = = = = = = = = =
Expand Down Expand Up @@ -197,9 +193,18 @@ def called?
private

def assert_rack_call_400_exception(expected, path_info, body)
assert_rack_call_exception(expected, path_info, body)
assert_400
end

def assert_rack_call_500_exception(expected, path_info, body)
assert_rack_call_exception(expected, path_info, body)
assert_500
end

def assert_rack_call_exception(expected, path_info, body)
env = { path_info:path_info, body:body }
rack_call(env)
assert_400
[response_body,log].each do |s|
refute_nil s
json = JSON.parse(s)
Expand Down Expand Up @@ -246,6 +251,10 @@ def assert_400
assert_equal 400, response_status, @response
end

def assert_500
assert_equal 500, response_status, @response
end

# - - - - - - - - - - - - - - - - -

def assert_body_contains(key)
Expand Down
2 changes: 1 addition & 1 deletion test/server/traffic_light_test.rb
Expand Up @@ -137,7 +137,7 @@ def id58_setup
"exception when eval'ing lambda source",
lambda_source,
'SyntaxError',
"/runner/code/empty_binding.rb:4: syntax error, unexpected '-'\nnot-a-lambda\n ^\n"
"(eval):1: syntax error, unexpected '-'\nnot-a-lambda\n ^\n"
)
end

Expand Down

0 comments on commit e79210a

Please sign in to comment.