Skip to content

Commit

Permalink
Merge pull request #148 from HarrisonWAffel/update-readme-and-tests
Browse files Browse the repository at this point in the history
Update Maintainers, Add Integration Target, Update README
  • Loading branch information
HarrisonWAffel authored Nov 21, 2023
2 parents d2480f6 + 0c87dfd commit b0efc94
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ steps:
build_args:
- SERVERCORE_VERSION=1809
- ARCH=amd64
- MAINTAINERS=[email protected] cphill11@gmail.com luther.monson@gmail.com
- MAINTAINERS=harrison.affel@suse.com arvind.iyengar@suse.com
- REPO=https://github.com/rancher/wins
custom_dns: 1.1.1.1
dockerfile: Dockerfile
Expand Down Expand Up @@ -129,7 +129,7 @@ steps:
build_args:
- SERVERCORE_VERSION=ltsc2022
- ARCH=amd64
- MAINTAINERS=[email protected] cphill11@gmail.com luther.monson@gmail.com
- MAINTAINERS=harrison.affel@suse.com arvind.iyengar@suse.com
- REPO=https://github.com/rancher/wins
custom_dns: 1.1.1.1
dockerfile: Dockerfile
Expand Down
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ OPTIONS:
git clone https://github.com/rancher/wins.git
Set-Location wins
Set-Location $(Get-Location).path
scripts/build.ps1
# build the project using the magefile
go run mage.go build
copy-item bin/wins.exe .
$WINS_PATH = $(Get-Location).Path
Expand Down Expand Up @@ -237,17 +240,17 @@ For integration test, please run the below command in `PowerShell`:
> go run mage.go integration
```

> Note: Don't use `bin/wins.exe` after integration testing. Please `.\make.ps1 build` again.
> Note: Don't use `bin/wins.exe` after integration testing. Please `go run mage.go build` again.

If want both of them, please run the below command in `PowerShell`:

``` powershell
> .\make.ps1 all
> go run mage.go TestAll
```

## License

Copyright (c) 2014-2022 [Rancher Labs, Inc.](http://rancher.com)
Copyright (c) 2014-2023 [Rancher Labs, Inc.](http://rancher.com)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
Expand Down
10 changes: 2 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ replace (
k8s.io/mount-utils => k8s.io/mount-utils v0.24.0
k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.23.8
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.24.0

)

require (
Expand All @@ -58,12 +57,8 @@ require (
golang.org/x/sys v0.10.0
google.golang.org/grpc v1.45.0
inet.af/tcpproxy v0.0.0-20200125044825-b6bb9b5b8252

)

require github.com/magefile/mage v1.13.0

require (
github.com/magefile/mage v1.13.0
k8s.io/client-go v0.24.2
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -132,7 +127,6 @@ require (
k8s.io/api v0.24.2 // indirect
k8s.io/apimachinery v0.24.2 // indirect
k8s.io/apiserver v0.24.0 // indirect
k8s.io/client-go v0.24.2 // indirect
k8s.io/component-base v0.24.2 // indirect
k8s.io/klog/v2 v2.70.0 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
Expand Down
41 changes: 40 additions & 1 deletion magefiles/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var g *magetools.Go
var version string
var commit string
var artifactOutput = filepath.Join("artifacts")
var integrationBin = filepath.Join("tests/integration/bin")

func Clean() error {
if err := sh.Rm(artifactOutput); err != nil {
Expand Down Expand Up @@ -149,7 +150,45 @@ func Test() error {
if err := g.Test(flags, "./..."); err != nil {
return err
}
log.Printf("[Test] successfully tested wins version version %s \n", version)
log.Printf("[Test] successfully tested wins version %s \n", version)
return nil
}

// Integration target must be run on a wins system
// with Containers feature / docker installed
func Integration() error {
mg.Deps(Build)
log.Printf("[Integration] Starting Integration Test for wins version %s \n", version)

// make sure the docker files have access to the exe
if err := os.MkdirAll(integrationBin, os.ModePerm); err != nil {
return err
}

// move exe to right location
if err := sh.Copy(filepath.Join("tests", "integration", "docker", "wins.exe"), filepath.Join(artifactOutput, "wins.exe")); err != nil {
return err
}

// run test suite
if err := sh.Run("powershell.exe", filepath.Join("tests/integration/integration_suite_test.ps1")); err != nil {
return err
}

log.Printf("[Test] successfully ran integration tests on wins version %s \n", version)
return nil
}

func TestAll() error {
mg.Deps(Build)
// don't run Test and Integration in mg.Deps
// as deps run in an unordered asynchronous fashion
if err := Test(); err != nil {
return err
}
if err := Integration(); err != nil {
return err
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/docker/Dockerfile.wins-cli
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG SERVERCORE_VERSION

FROM mcr.microsoft.com/windows/servercore:${SERVERCORE_VERSION}
COPY bin/wins-container.exe /Windows/wins.exe
COPY bin/wins.exe /Windows/wins.exe
ENTRYPOINT wins.exe cli
2 changes: 1 addition & 1 deletion tests/integration/docker/Dockerfile.wins-nginx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ RUN $URL = 'http://nginx.org/download/nginx-1.21.3.zip'; \
Remove-Item -Force -Path c:\nginx.zip | Out-Null; \
\
Write-Host 'Complete.'
COPY bin/wins-container.exe /Windows/wins.exe
COPY bin/wins.exe /Windows/wins.exe
COPY tests/integration/docker/nginx.ps1 /Windows/
ENTRYPOINT ["powershell", "-NoLogo", "-NonInteractive", "-File", "c:/Windows/nginx.ps1"]
2 changes: 1 addition & 1 deletion tests/integration/docker/Dockerfile.wins-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ ARG SERVERCORE_VERSION

FROM mcr.microsoft.com/windows/servercore:${SERVERCORE_VERSION}
SHELL ["powershell", "-NoLogo", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY bin/wins-container.exe /Windows/wins.exe
COPY bin/wins.exe /Windows/wins.exe
COPY tests/integration/docker/upgrade.ps1 /Windows/
ENTRYPOINT ["powershell", "-NoLogo", "-NonInteractive", "-File", "c:/Windows/upgrade.ps1"]
24 changes: 12 additions & 12 deletions tests/integration/integration_suite_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ if (-not $SERVERCORE_VERSION) {
$SERVERCORE_VERSION = "1809"
}

#Get-ChildItem -Path $PSScriptRoot\docker -Name Dockerfile.* | ForEach-Object {
# $dockerfile = $_
# $tag = $dockerfile -replace "Dockerfile.", ""
# docker build `
# --build-arg SERVERCORE_VERSION=$SERVERCORE_VERSION `
# -t $tag `
# -f $PSScriptRoot\docker\$dockerfile .
# if ($LASTEXITCODE -ne 0) {
# Log-Fatal "Failed to build testing docker image"
# exit $LASTEXITCODE
# }
#}
Get-ChildItem -Path $PSScriptRoot\docker -Name Dockerfile.* | ForEach-Object {
$dockerfile = $_
$tag = $dockerfile -replace "Dockerfile.", ""
docker build `
--build-arg SERVERCORE_VERSION=$SERVERCORE_VERSION `
-t $tag `
-f $PSScriptRoot\docker\$dockerfile .
if ($LASTEXITCODE -ne 0) {
Log-Fatal "Failed to build testing docker image"
exit $LASTEXITCODE
}
}

# test
New-Item -Type Directory -Force -ErrorAction Ignore -Path @(
Expand Down

0 comments on commit b0efc94

Please sign in to comment.