Skip to content

Commit

Permalink
Merge pull request #1 from Local-Connectivity-Lab/zhennan_test_github…
Browse files Browse the repository at this point in the history
…_action

Add support to run mock server in github actions and enable integration tests
  • Loading branch information
johnnzhou authored Jan 9, 2024
2 parents 8eaa1ad + f8444fc commit 450b633
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 26 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,15 @@ jobs:
name: Swift ${{ matrix.swift }} on ${{ matrix.os }}
strategy:
matrix:
# os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest]
# swift: ["5.8", "5.9"]
swift: ["5.9"]
os: [ubuntu-latest, macos-latest]
swift: ["5.8", "5.9"]
runs-on: ${{ matrix.os }}
steps:
- uses: swift-actions/setup-swift@v1
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v4
- name: Test Server
run: |
make setup_server
curl 127.0.0.1:8080
make teardown_server
# - name: Build
# run: swift build
# - name: Run tests
# run: swift test --skip IntegrationTests
- name: Run Unit Tests
run: make unit_test
- name: Run Integration Tests
run: make integration_test
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ setup_server: server_environment

.PHONY: teardown_server
teardown_server:
kill -9 $(ps -ef | grep "$(RUN_FLASK)" | grep -v "grep" | awk '{print $2}')
kill -9 $$(lsof -t -i :$(SERVER_PORT))


######### Production #########
.PHONY: release
Expand All @@ -20,10 +21,22 @@ release: test

.PHONY: test
test:
make unit_test
make integration_test

.PHONY: unit_test
unit_test:
swift test --skip IntegrationTests

.PHONY: integration_test
integration_test:
make setup_server
swift test --parallel -Xswiftc -DINTEGRATION_TEST
sleep 5
curl http://localhost:8080
swift test -Xswiftc -DINTEGRATION_TEST --filter IntegrationTests || true
make teardown_server


.PHONY: package
package:
echo "make package is not implemented"
Expand All @@ -35,7 +48,7 @@ debug_build:

.PHONY: debug_unit_test
debug_unit_test:
swift test --skip IntegrationTests
swift test -Xswiftc -DDEBUG --skip IntegrationTests

.PHONY: debug_integration_test
debug_integration_test:
Expand Down
2 changes: 1 addition & 1 deletion Mock/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _generate_response(desired_status_code) -> Response:
desired_status_code = int(desired_status_code)
except:
return make_response("Invalid Status-Code in the HTTP Header", 404)
response = make_response("Hello from lcl-ping mock server!")
response = make_response("Hello from lcl-ping mock server!\n")
response.status_code = desired_status_code
return response

Expand Down
4 changes: 0 additions & 4 deletions Sources/LCLPing/HTTP/HTTPPing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ internal struct HTTPPing: Pingable {
case .finished, .ready, .error:
fatalError("wrong state: \(pingStatus)")
}

if let pingSummary = pingSummary {
printSummary(pingSummary)
}
} catch {
pingStatus = .error
throw PingError.sendPingFailed(error)
Expand Down
5 changes: 0 additions & 5 deletions Sources/LCLPing/ICMP/ICMPPing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,6 @@ internal struct ICMPPing: Pingable {
if self.pingStatus != .stopped {
pingStatus = .finished
}

if let pingSummary = pingSummary {
printSummary(pingSummary)
}

case .failure(let failure):
pingStatus = .error
throw failure
Expand Down

0 comments on commit 450b633

Please sign in to comment.