From 40daa8ee3ad41ad517383c5395319264f647e31b Mon Sep 17 00:00:00 2001 From: luancheng Date: Fri, 15 Jan 2021 15:41:27 +0800 Subject: [PATCH 1/2] remove python code in test --- Makefile | 1 + tests/br_gcs/oauth.go | 25 +++++++++++++++++++++++++ tests/br_gcs/oauth.py | 9 --------- tests/br_gcs/run.sh | 2 +- 4 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 tests/br_gcs/oauth.go delete mode 100644 tests/br_gcs/oauth.py diff --git a/Makefile b/Makefile index 0b44a3e02..84d86812e 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,7 @@ build_for_integration_test: -o bin/br.test && \ $(GOBUILD) $(RACEFLAG) -o bin/locker tests/br_key_locked/*.go && \ $(GOBUILD) $(RACEFLAG) -o bin/gc tests/br_z_gc_safepoint/*.go && \ + $(GOBUILD) $(RACEFLAG) -o bin/oauth tests/br_gcs/*.go && \ $(GOBUILD) $(RACEFLAG) -o bin/rawkv tests/br_rawkv/*.go) || (make failpoint-disable && exit 1) @make failpoint-disable diff --git a/tests/br_gcs/oauth.go b/tests/br_gcs/oauth.go new file mode 100644 index 000000000..2c520103e --- /dev/null +++ b/tests/br_gcs/oauth.go @@ -0,0 +1,25 @@ +// Copyright 2020 PingCAP, Inc. +// +// 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// See the License for the specific language governing permissions and +// limitations under the License. + +package main + +import ( + "net/http" +) + +func main() { + http.HandleFunc("/oauth/token", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(`{"access_token": "ok", "token_type":"service_account", "expires_in":3600}`)) + }) + http.ListenAndServe(":5000", nil) +} diff --git a/tests/br_gcs/oauth.py b/tests/br_gcs/oauth.py deleted file mode 100644 index 24e686184..000000000 --- a/tests/br_gcs/oauth.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - -from flask import Flask - -app = Flask(__name__) - -@app.route('/oauth/token', methods=['GET', 'POST']) -def oauth(): - return '{"access_token": "ok", "token_type":"service_account", "expires_in":3600}' diff --git a/tests/br_gcs/run.sh b/tests/br_gcs/run.sh index a5be052de..b40c74452 100755 --- a/tests/br_gcs/run.sh +++ b/tests/br_gcs/run.sh @@ -36,7 +36,7 @@ while ! curl -o /dev/null -v -s "http://$GCS_HOST:$GCS_PORT/"; do done # start oauth server -FLASK_APP=tests/$TEST_NAME/oauth.py flask run & +bin/oauth & OAUTH_ID=$! stop_gcs() { From b95d7b21c2ba11ffc1f50e03b2a713ee039eca90 Mon Sep 17 00:00:00 2001 From: luancheng Date: Fri, 15 Jan 2021 16:08:20 +0800 Subject: [PATCH 2/2] fix build --- tests/br_gcs/oauth.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/br_gcs/oauth.go b/tests/br_gcs/oauth.go index 2c520103e..c9fdc8027 100644 --- a/tests/br_gcs/oauth.go +++ b/tests/br_gcs/oauth.go @@ -19,7 +19,7 @@ import ( func main() { http.HandleFunc("/oauth/token", func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(`{"access_token": "ok", "token_type":"service_account", "expires_in":3600}`)) + _, _ = w.Write([]byte(`{"access_token": "ok", "token_type":"service_account", "expires_in":3600}`)) }) - http.ListenAndServe(":5000", nil) + _ = http.ListenAndServe(":5000", nil) }