Skip to content

Commit

Permalink
Allows the Helm install of the current Agones development build durin…
Browse files Browse the repository at this point in the history
…g the upgrade test
  • Loading branch information
igooch committed Nov 25, 2024
1 parent adf0d23 commit 830fb7b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 92 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ bin
/site/public
/test

# Allow upgrade test directory
!/test/upgrade

# Created by .ignore support plugin (hsz.mobi)
### Go template
# Binaries for programs and plugins
Expand Down
13 changes: 2 additions & 11 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,14 @@ steps:
# End to end tests
#

# Build upgrade test
- name: make-docker
id: build-upgrade-test
dir: test/upgrade
env: ['REGISTRY=${_REGISTRY}']
args: [build]
waitFor:
- push-images

# Push upgrade test
# Build and Push upgrade test
- name: make-docker
id: push-upgrade-test
dir: test/upgrade
env: ['REGISTRY=${_REGISTRY}']
args: [push]
waitFor:
- build-upgrade-test
- push-images

# Wait for us to be the oldest ongoing build before we run upgrade and e2e tests
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
Expand Down
30 changes: 12 additions & 18 deletions test/upgrade/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM gcr.io/cloud-builders/gcloud AS builder
FROM golang:1.22.9-alpine AS builder

RUN apt-get update && \
apt-get install -y curl && \
apt-get clean
# install curl
RUN apk update && \
apk upgrade && \
apk --no-cache add curl

WORKDIR /usr/local

Expand All @@ -35,27 +36,20 @@ RUN curl -L ${HELM_URL} > /tmp/helm.tar.gz \
&& chmod go+rx /usr/local/bin/helm \
&& rm /tmp/helm.tar.gz && rm -rf /tmp/linux-amd64

# Build the Go image from source
FROM golang:1.22.6 AS build-stage

# Copy and build the Go application
WORKDIR /agones.dev

COPY *.go ./

COPY test/upgrade/main.go ./
RUN go mod init agones.dev/agones/test/upgrade/testContainer
RUN go mod tidy
RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux go build -o /upgrade-test

# Copy the above binary into a lean image
FROM gcr.io/distroless/static-debian12:nonroot AS build-release-stage

# Copy the dev build Agones Helm chart
WORKDIR /

COPY --from=build-stage /upgrade-test /upgrade-test
COPY --from=builder /usr/local /usr/local

USER nonroot:nonroot
# Use a non-root user for security best practices
RUN adduser -D -g '' adduser
USER adduser
COPY --chown=adduser install/helm/agones /install/helm

ENTRYPOINT ["/upgrade-test"]
10 changes: 5 additions & 5 deletions test/upgrade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@
#

REGISTRY ?=
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
project_path := $(dir $(mkfile_path))
root_path = $(realpath $(project_path)/)
base_version = 1.46.0
# Version defaults to the short hash of the latest commit
VERSION ?= $(base_version)-dev-$(shell git rev-parse --short=7 HEAD)
server_tag := $(REGISTRY)/upgrade-test-controller:$(VERSION)

cwd:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# _____ _
# |_ _|_ _ _ __ __ _ ___| |_ ___
# | |/ _` | '__/ _` |/ _ \ __/ __|
# | | (_| | | | (_| | __/ |_\__ \
# |_|\__,_|_| \__, |\___|\__|___/
# |___/

# Using .ONESHELL allows us to `cd` to the parent directory agones. This gives the Dockerfile the
# context of the agones directory, which allows it to COPY files from any child directory.
.ONESHELL:
# Build a docker image for the server, and tag it
build:
cd $(root_path) && docker build -f $(project_path)Dockerfile --tag=$(server_tag) .
cd "$(cwd)/../.." && DOCKER_BUILDKIT=1 docker build -f $(cwd)/Dockerfile --tag=$(server_tag) .

push: build
docker push $(server_tag)
51 changes: 0 additions & 51 deletions test/upgrade/go.mod

This file was deleted.

24 changes: 17 additions & 7 deletions test/upgrade/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@ const (
Timeout = 10 * time.Minute
// HelmChart is the helm chart for the public Agones releases
HelmChart = "agones/agones"
// TestChart is the registry for Agones Helm chart development builds
TestChart = "./install/helm"
// AgonesRegistry is the public registry for Agones releases
AgonesRegistry = "us-docker.pkg.dev/agones-images/release"
// TestRegistry is the public registry for upgrade test container files
TestRegistry = "us-docker.pkg.dev/agones-images/ci/sdk-client-test"
// TestRegistry is the registry for Agones development builds
TestRegistry = "us-docker.pkg.dev/agones-images/ci/"
// ContainerRegistry is the registry for upgrade test container files
ContainerRegistry = "us-docker.pkg.dev/agones-images/ci/sdk-client-test"
)

var (
Expand Down Expand Up @@ -300,13 +304,13 @@ func runConfigWalker(ctx context.Context, validConfigs []*configTest) {
registry := AgonesRegistry
chart := HelmChart
if config.agonesVersion == DevVersion {
// TODO: Update to templated value for registry and chart for Dev build
continue
registry = TestRegistry
chart = TestChart
}
err := installAgonesRelease(config.agonesVersion, registry, config.featureGates, ImagePullPolicy,
SidecarPullPolicy, LogLevel, chart)
if err != nil {
log.Printf("installAgonesRelease err: %s", err)
log.Fatalf("installAgonesRelease err: %s", err)
}

// Wait for the helm release to install. Waits the same amount of time as the Helm timeout.
Expand Down Expand Up @@ -350,6 +354,12 @@ func checkHelmStatus(agonesVersion string) string {
log.Fatal("Could not Unmarshal", err)
}

// Remove the commit sha from the DevVersion i.e. from 1.46.0-dev-7168dd3 to 1.46.0-dev
if agonesVersion == DevVersion {
r := regexp.MustCompile(`1\.\d+\.\d+-dev`)
agonesVersion = r.FindString(DevVersion)
}

for _, status := range helmStatus {
if status.AppVersion == agonesVersion {
return status.Status
Expand All @@ -362,7 +372,7 @@ func checkHelmStatus(agonesVersion string) string {
// gameserver yaml is based on the Agones version, i.e. gs1440.yaml for Agones version 1.44.0
// Note: This does not validate the created file.
func createGameServerFile(agonesVersion string, countsAndLists bool) string {
gsTmpl := gameServerTemplate{Registry: TestRegistry, AgonesVersion: agonesVersion, CountsAndLists: countsAndLists}
gsTmpl := gameServerTemplate{Registry: ContainerRegistry, AgonesVersion: agonesVersion, CountsAndLists: countsAndLists}

gsTemplate, err := template.ParseFiles("gameserver.yaml")
if err != nil {
Expand Down Expand Up @@ -450,7 +460,7 @@ func checkFirstGameServerReady(ctx context.Context, gsReady chan bool, args ...s
log.Fatalf("Could not get Gameserver %s state: %s", gsName, err)
}
if err != nil {
retries += 1
retries++
return false, nil
}
// Sample output: Running sdk-client-test-bbvx9
Expand Down

0 comments on commit 830fb7b

Please sign in to comment.